Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Grub2 not detecting newly compiled kernel
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
Buuntu
n00b
n00b


Joined: 16 May 2014
Posts: 3

PostPosted: Tue May 27, 2014 3:20 am    Post subject: Grub2 not detecting newly compiled kernel Reply with quote

I just recently installed gentoo and compiled the kernel with the genkernel script (I was lazy at the time). In order to get my wireless driver to be loaded however, I had to re-compile the kernel to allow support for it. The problem now is that grub2 is not recognizing the new kernel after updating grub. After choosing the right modules with 'make menuconfig', I compiled with:
Code:
make && make modules_install
cp arch/x86/boot/bzImage /boot

Grub2 is installed on a separate partition running Ubuntu 11.10, so I had to boot into it each time and run:
Code:
sudo update-grub

but after restarting the only entries that showed up were the Gentoo versions (normal and recovery mode) with the kernel compiled from the genkernel script.

After that didn't show up in the grub menu, I changed the kernel name to begin with 'kernel' (also tried 'vmlinuz'), since I read that is what grub2 looks for. It looked something like:
Code:
kernel-3.12.13-gentoo

The last thing I attempted was manually adding an entry into the 40_custom grub file, which I basically copied from the genkernel entries in grub.cfg, only changing the linux kernel line to the newly compiled kernel. That showed the entry in the grub menu and appeared to begin booting when I selected it but after a while I got an error about my root partition not being set to a proper device. That didn't make sense to me since it was set to the same root partition as the genkernel entries (which boot up properly). All of the gentoo installation is on one partition; no separate /home or /boot partitions.

Am I missing something or going about switching kernels incorrectly?
Back to top
View user's profile Send private message
Logicien
Veteran
Veteran


Joined: 16 Sep 2005
Posts: 1368
Location: Montréal

PostPosted: Tue May 27, 2014 12:26 pm    Post subject: Reply with quote

Your Ubuntu version is quite old now, since the latest stable is 14.04.

If I understand well, you let Ubuntu Grub detect your Gentoo with the os_prober script in the /etc/grub.d directory. I do not use that script. It is possible that os_prober can only add one entry for a Linux operating system.

Anyway, you can use the 40_custom script to add an entry to Grub. First, do you see the kernel-3.12.13-gentoo image in the Gentoo boot directory? If you show us the entry you create in the 40_custom file, we could help you more. Did you set Grub to the good Gentoo partition
Code:
set root=(hdx,y)

Did you set the Gentoo kernel to boot on the good root partition
Code:
linux /boot/kernel-3.12.13-gentoo root=/dev/sdxy

If you use an initrd, you must write a line for it in the entry.

Note that all the scripts you want ot use in /etc/grub.d must be executables. The grub-mkconfig (update-grub) command will not execute a script who is not executable in that directory. Dont forget to execute
Code:
update-grub

from Ubuntu after any Grub configuration modification.
_________________
Paul
Back to top
View user's profile Send private message
Buuntu
n00b
n00b


Joined: 16 May 2014
Posts: 3

PostPosted: Tue May 27, 2014 11:52 pm    Post subject: Reply with quote

My /boot/grub/grub.cfg look like this:
Code:
menuentry "Gentoo 3.12.13" --class gnu-linux --class-gnu --class os {
insmod part_msdos
   insmod ext2
   set root='(hd0,msdos7)'
   search --no-floppy --fs-uuid --set=root cef6e7f4-c4ef-42dd-91aa-1a2ff96553d6
   linux /boot/kernel-3.12.13-gentoo root=UUID=cef6e7f4-c4ef-42dd-91aa-1a2ff96553d6 ro
   initrd /boot/initramfs-genkernel-x86-3.12.13-gentoo
}

I copied the UUID from the working gentoo kernel entries but have also tried just entering /dev/sda7, where the root partition is located. So at this point I guess the problem isn't that the kernel isn't detected since it does appear in the grub menu after manual entry (although it would be nice for grub to automatically identify it) and seems to begin to load before the error message. The error message is about /dev/sda7 not being a working device for the root partition. Interesting because the genkernel entries are set identically and don't give me the error message.
Back to top
View user's profile Send private message
pa1983
Tux's lil' helper
Tux's lil' helper


Joined: 09 Jan 2004
Posts: 100

PostPosted: Wed May 28, 2014 5:37 am    Post subject: Reply with quote

I just started using grub2 a few months ago, use grub on all other systems and used lilo back in the day.

I compiled my kernel manually as always, I just changed how I set up the bootloader on the latest system. I have also upgraded the kernel on that system a few times now since its pretty new hardware so out of the box I did not have full support on all the stuff I needed.

Any way this is what I do.

First find out how many threads your CPU supports. First processor starts at 0 so if the last is 1 you have 2 cores or threads.

cat /proc/cpuinfo | grep processor

before you compile the kernel clean up any old files
cd /usr/src/linux
make clean

Then compile the kernel and use the -j flag to save time. Now add + 1 to the number of processors "cat /proc/cpuinfo | grep processor" gave you for example a duel core CPU with out SMT would be 2+1 so that makes 3. This will make sure both cores runs jobs for the compiler

make -j3 bzImage

if you want to know how long it took to compile the kernel you can use the time command like so to see what -j option works best for you in the future

time make -j3 bzImage

before copying the kernel make sure /boot is mounted. If not mount it like so
df -Th
mount /boot

copy the kernel and rename it to kernel-version where version is replaced with the actual version for example kernel-3.12.6. If you run many kernels you can add -gentoo or -vanilla after the kernel number. This is just a recommendation not a must do
cp arch/x86_64/boot/bzImage /boot/kernel-3.12.6

emerge genkernel if you dont have it installed (in your case I assume you have since you mentioned it so you can skip this)
emerge genkernel

for grub2 to write a proper config file for you new kernel or kernel images you need an initrd image for it. To create one for you kernel or kernel images you need to run the fallowing command. This should generate initramfs images and you should find them in /boot starting with initramfs-genkernel-* fallowed by the name you gave your kernel image
genkernel --install initramfs

Finally we need to create a new grub.conf so we can boot our new kernel images. Grub2 should tell you that it found the initramfs-genkernel-* and kernel images in /boot that you compiled and generated in the previous steps. If so you should have them in grub2 when booting as boot options
grub2-mkconfig -o /boot/grub/grub.cfg


If you want to remove an old kernel just delete the initramfs-genkernel-* and the kernel image associated with it and re run "grub2-mkconfig -o /boot/grub/grub.cfg" to generate a new grub.conf with out them.

I hop this helps.
_________________
WS: i7 3930K@4Ghz, 32Gb ram, 256Gb NVME & 128Gb sata SSD, GTX780 3Gb & RX 460 2Gb
NAS: i3 4360 3.7Ghz, 20Gb ram, 256Gb SSD, 42Tb HDD, NIC: Intel 2x1Gbit
ROUTER: J1900 2Ghz, 8Gb ram, 128Gb SSD, NIC: 2x1Gbit, WIFI: Atheros AR9462 and AR5005G
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