View previous topic :: View next topic |
Author |
Message |
Dylanus n00b

Joined: 02 Jun 2018 Posts: 40
|
Posted: Mon Jul 30, 2018 5:36 am Post subject: [SOLVED] Rebuilt kernel: invalid magic number |
|
|
Hi all,
I have recently got my Gentoo installation working, but I configured the wireless drivers as built-in, not modules, which is giving me problems setting up libvirtd. Since these drivers are built-in, my understanding is that I have to recompile the kernel, I can't simply compile the modules and load them. So I recompiled the kernel and copied the vmlinux file to /boot. I did not run make install, as I did not want to remove the working kernel, which turns out to be a good decision, as this one is not working. Then I ran genkernel --luks --lvm initramfs, followed by grub-mkconfig. The new kernel was discovered, along with a second initramfs. Then when I rebooted and selected the new kernel, it told me there was an invalid magic number and I needed to load the kernel first.If I return to Grub and select the old kernel, everything boots fine.
In /usr/src/ I have a directory simply called linux, and one called linux-4.14.52-gentoo. I compiled in linux/ as I assumed this would be the original source I downloaded at installation, after copying across .config. Is everything I have done so far correct? Do I need to post any config files? How can I get a new kernel booted with the modules I need without running make install?
Thanks
Last edited by Dylanus on Thu Aug 02, 2018 7:46 am; edited 1 time in total |
|
Back to top |
|
 |
khayyam Watchman


Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Mon Jul 30, 2018 6:00 am Post subject: |
|
|
Dylanus ...
it's not altogether clear what you're trying to achieve, you want to modularise the wireless driver? If that is the case then you need to run 'make modules_install' subsequent to 'make', and prior to runing 'genkernel' and building the initramfs.
best ... khay |
|
Back to top |
|
 |
Dylanus n00b

Joined: 02 Jun 2018 Posts: 40
|
Posted: Mon Jul 30, 2018 10:16 am Post subject: |
|
|
I did run that. The compilation was fine. Now I just want the system to boot that kernel without running make install, so that it doesn't replace the working kernel. Why the magic number error? |
|
Back to top |
|
 |
toralf Developer


Joined: 01 Feb 2004 Posts: 3943 Location: Hamburg
|
Posted: Mon Jul 30, 2018 12:58 pm Post subject: |
|
|
Dylanus wrote: | Now I just want the system to boot that kernel without running make install, so that it doesn't replace the working kernel |
Usually the new kernel is installed beside the others. It is the grub2 default entry, which usually points to the latest kernel. Take a look at the Gentoo wiki, look there for "grub2" "kernel" and "boot". |
|
Back to top |
|
 |
khayyam Watchman


Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Mon Jul 30, 2018 1:09 pm Post subject: |
|
|
Dylanus wrote: | I did run that. The compilation was fine. Now I just want the system to boot that kernel without running make install, so that it doesn't replace the working kernel. Why the magic number error? |
Dylanus ... because the kernel, and modules/initramfs built in concert with that kernel, are intertwined. So, if your kernel is build with say DRIVER=y, and you rebuild with DRIVER=m, then you can't continue to use the first kernel, because that kernel is not consistent with those modules under /lib/modules-$(uname -r) ... which are included in the (genkernel generated) initramfs.
So, rename the vmlinuz and initramfs to {name}-{version}-fallback, and re-create the vmlinuz, modules, and initramfs. You'll then need to re-run 'grub-install'.
best ... khay |
|
Back to top |
|
 |
Anon-E-moose Watchman


Joined: 23 May 2008 Posts: 6369 Location: Dallas area
|
Posted: Mon Jul 30, 2018 1:11 pm Post subject: |
|
|
A few points, running "make install" will copy the latest built kernel (along with system.map) into boot, BUT it will rename the old kernel (the last one, if same version number) to <whatever>.old.
If you want to keep it around past that point, then rename *.old to whatever name you want.
With grub you can stop the boot process and edit the command line to boot whichever kernel (in boot) that you want.
Hopefully you also do a modules_install after building the modules and kernel or the running kernel will never see them as they wouldn't be installed into /lib/modules/<whatever version>
You should also copy the System.map to /boot to match the name of the "new" kernel image. _________________ UM780 xtx, 6.14 zen kernel, gcc 15, openrc, wayland
Got to love snowflakes, how does the world survive without them. |
|
Back to top |
|
 |
Dylanus n00b

Joined: 02 Jun 2018 Posts: 40
|
Posted: Mon Jul 30, 2018 1:13 pm Post subject: |
|
|
Thank you both, I understand a bit better now. I'll try all that tomorrow afternoon. |
|
Back to top |
|
 |
Anon-E-moose Watchman


Joined: 23 May 2008 Posts: 6369 Location: Dallas area
|
Posted: Mon Jul 30, 2018 1:33 pm Post subject: |
|
|
Sorry, I forget about initramfs as I don't use it. IF you do use one then keep khayyam's advice regarding it, in mind.
Edit to add: as a side note, I didn't use make install for years, but instead copied the files by hand (install is easier ) _________________ UM780 xtx, 6.14 zen kernel, gcc 15, openrc, wayland
Got to love snowflakes, how does the world survive without them. |
|
Back to top |
|
 |
Dylanus n00b

Joined: 02 Jun 2018 Posts: 40
|
Posted: Mon Jul 30, 2018 8:43 pm Post subject: |
|
|
It worked! I originally thought the invalid magic number error may have been caused because I copied the wrong files, but in fact I think my compiled kernel was corrupted. I noticed an error about clock skew, so I had to touch every file, a tip I saw in another post on this forum, which is amazing, by the way. I use initramfs because I have full disk encryption, but the steps for this were very similar to the instructions at installation. I understand the process of booting from a new kernel much better now, thank you.
Unfortunately compiling the wireless drivers as modules has not fixed the problem with libvirtd, but I think it would be best for me to ask that question on another thread.
Thanks again to Anon-E-moose and khayyam. |
|
Back to top |
|
 |
alessio_demarchi n00b


Joined: 03 Nov 2012 Posts: 36
|
Posted: Sat Aug 29, 2020 9:54 am Post subject: |
|
|
Hello everyone
I have the same problem ("invalid magic number" on load kernel at boot).
But I have not understand the solution.
Can You explain me that?
Thanks |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|