Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Rebuilt kernel: invalid magic number
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Dylanus
n00b
n00b


Joined: 02 Jun 2018
Posts: 40

PostPosted: Mon Jul 30, 2018 5:36 am    Post subject: [SOLVED] Rebuilt kernel: invalid magic number Reply with quote

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
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Mon Jul 30, 2018 6:00 am    Post subject: Reply with quote

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
View user's profile Send private message
Dylanus
n00b
n00b


Joined: 02 Jun 2018
Posts: 40

PostPosted: Mon Jul 30, 2018 10:16 am    Post subject: Reply with quote

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
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3652
Location: Hamburg

PostPosted: Mon Jul 30, 2018 12:58 pm    Post subject: Reply with quote

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
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Mon Jul 30, 2018 1:09 pm    Post subject: Reply with quote

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
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 3793
Location: Dallas area

PostPosted: Mon Jul 30, 2018 1:11 pm    Post subject: Reply with quote

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.
_________________
Asus m5a99fx, FX 8320 - nouveau & radeon, oss4
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
5.0.13 zen kernel, profile 17.0 (no-pie) amd64-no-multilib
gcc 8.2.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
Dylanus
n00b
n00b


Joined: 02 Jun 2018
Posts: 40

PostPosted: Mon Jul 30, 2018 1:13 pm    Post subject: Reply with quote

Thank you both, I understand a bit better now. I'll try all that tomorrow afternoon.
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 3793
Location: Dallas area

PostPosted: Mon Jul 30, 2018 1:33 pm    Post subject: Reply with quote

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 :) )
_________________
Asus m5a99fx, FX 8320 - nouveau & radeon, oss4
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
5.0.13 zen kernel, profile 17.0 (no-pie) amd64-no-multilib
gcc 8.2.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
Dylanus
n00b
n00b


Joined: 02 Jun 2018
Posts: 40

PostPosted: Mon Jul 30, 2018 8:43 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
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