Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] grub2 bios fails to find kernel
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
Yak
Tux's lil' helper
Tux's lil' helper


Joined: 01 Sep 2002
Posts: 107

PostPosted: Fri Aug 25, 2017 1:43 pm    Post subject: [SOLVED] grub2 bios fails to find kernel Reply with quote

Need a little help with grub2. Doing an install but grub2 can't find the kernel.

Pretty simple setup, root partition is /dev/sda2, boot partition is /dev/sda1, these are the only two partitions.
Just one drive partitioned with fdisk and there are 2048 sectors before the first partition. No gpt or uefi or anything like that.
Mounted /boot after chrooting.
Kernel is at /boot/bzImage
Emerged grub and did grub-install which seems ok.
Run grub-mkconfig -o /boot/grub/grub.cfg but it doesn't say anything about finding a kernel.
So it just boots to a grub> prompt.

I have read the amd64 handbook section on installing grub2, the grub2 page on the wiki and the grub2 troubleshooting. These all seem to be written with the assumption that the user is booting with efi and/or that grub2 is going to magically run all of its scripts and boot. It really doesn't say much about the rest.

I haven't mucked around with the scripts in /etc/grub.d or installed os-prober or anything like that. This isn't dual boot or anything.


Last edited by Yak on Fri Aug 25, 2017 4:54 pm; edited 1 time in total
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 6375
Location: almost Mile High in the USA

PostPosted: Fri Aug 25, 2017 2:45 pm    Post subject: Reply with quote

grub2-mkconfig has some weird rules for naming the kernel. In /boot, the kernel needs to be named something like

kernel-4.12.5
vmlinuz-4.12.5

The associated initramfs

initrd-4.12.5
initramfs-4.12.5
initrd.img-4.12.5

There are other possibilities but it's still a fixed set of naming rules.

I think this is one of the crazy things that grub-mkconfig needs, which makes it a bit confusing. However grub2-mkconfig uses these file versions to match up the kernel with initramfs. If you don't have the initramfs, that's fine too, it will ignore it.
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
gen2saurus
n00b
n00b


Joined: 20 Aug 2017
Posts: 10

PostPosted: Fri Aug 25, 2017 2:53 pm    Post subject: Reply with quote

It would be no problems if you'll follow the standard kernel procedure:
Code:
make;make modules;make modules_install;make install;grub-mkconfig -o /boot/grub/grub.cfg
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 5968
Location: Saint Amant, Acadiana

PostPosted: Fri Aug 25, 2017 3:30 pm    Post subject: Reply with quote

There is no standard procedure in Gentoo, everybody does what they like and suits them best. I myself (if I used Grub2) would write grub.cfg by hand and never run that script.
_________________
Please learn how to denote units correctly!

Political Correctness is all about replacing imaginary injustice with real injustice.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 6375
Location: almost Mile High in the USA

PostPosted: Fri Aug 25, 2017 3:40 pm    Post subject: Reply with quote

I believe the reason for the crazy grub-mkconfig script is so that it can set up the "clean" menus and submenus where writing it by hand can be cumbersome. However for a simple menu, it's not that hard to write by hand - syntax is different than grub legacy, but it's no harder than before.
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 5968
Location: Saint Amant, Acadiana

PostPosted: Fri Aug 25, 2017 3:44 pm    Post subject: Reply with quote

The most important reason probably is mayor binary distros use it for automated kernel upgrade.
_________________
Please learn how to denote units correctly!

Political Correctness is all about replacing imaginary injustice with real injustice.
Back to top
View user's profile Send private message
charles17
Advocate
Advocate


Joined: 02 Mar 2008
Posts: 2446

PostPosted: Fri Aug 25, 2017 3:47 pm    Post subject: Reply with quote

eccerr0r wrote:
grub2-mkconfig has some weird rules for naming the kernel. In /boot, the kernel needs to be named something like

Good to know. I already considered starting a topic »why rename bzImage -> vmlinuz?«.
I prefer bzImage, but never tried that with grub.
Back to top
View user's profile Send private message
Yak
Tux's lil' helper
Tux's lil' helper


Joined: 01 Sep 2002
Posts: 107

PostPosted: Fri Aug 25, 2017 4:16 pm    Post subject: Reply with quote

Weird rules indeed. Thanks for the information on that naming.

Don't use initramfs or anything, have always done a kernel like so:
Code:
cd /usr/src/linux
make -j9 && make modules_install
mount /boot
mv /boot/bzImage /boot/bzImage.1
cp arch/x86_64/boot/bzImage /boot/


I have worked on this then and fixed it like so:
Code:
rm /boot/grub/grub.cfg
vim /boot/grub/grub.cfg

set default=0
set timeout=0

menuentry "default" {
   linux /boot/bzImage root=/dev/sda2
}


:wq and all that and it works for me. Yeah I removed the original grub.cfg file with the big warning about not editing it. I don't think gentoo does anything crazy like running grub-mkconfig automatically and I've got no plans to run it either. The name of the kernel doesn't change so I won't have to edit grub.cfg anymore. If grub-mkconfig doesn't know what a bzImage is, then it's got issues afaic.

Thanks for the help, it's much appreciated. I think the last time I did a gentoo install never did figure out the grub2 with all its scripts just gave up after days and used lilo instead.
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 5968
Location: Saint Amant, Acadiana

PostPosted: Fri Aug 25, 2017 4:26 pm    Post subject: Reply with quote

Well done! This would be worth to be sticky ... but nobody reads stickies anyway ...
_________________
Please learn how to denote units correctly!

Political Correctness is all about replacing imaginary injustice with real injustice.
Back to top
View user's profile Send private message
Yak
Tux's lil' helper
Tux's lil' helper


Joined: 01 Sep 2002
Posts: 107

PostPosted: Fri Aug 25, 2017 4:51 pm    Post subject: Reply with quote

Thanks, I did some poking around in https://www.gnu.org/software/grub/manual/grub.html grub2 2.02 manual which helped me out. That thing is huge though, it support so much stuff anymore. LFS has a nice example of a simple grub.cfg for grub2 too.

Maybe somewhere in the gentoo doc it says to rename bzImage to vmlinuz and I missed it/forgot/never done it that way.. I don't do install very often really.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 6375
Location: almost Mile High in the USA

PostPosted: Fri Aug 25, 2017 5:03 pm    Post subject: Reply with quote

What I do wonder is why doesn't grub2-mkconfig take bzimage-4.12.5 as a proper name by default... seems like an easy enough hack (I think just need to patch one file), after all it accepts the other names ("vmlinuz-", and the gawdawful "kernel-"). It now becomes a matter of maintaining it.

Though it may be convenient to just stick your kernel as /boot/bzImage I'd still put a version number on each. It's a bit more annoying that you have to keep changing the bootloader config, but it keeps kernel versions straight especially if you suddenly come up with a kernel that doesn't boot. It also helps know what kernels you have and know what modules to blow away in /lib/modules/* when you delete kernels.

Anyway, at least for grub and having multiple kernels, you only need to change grub.cfg to update the bootloader, and not also have to reinstall the boot sector like you do for lilo.
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Yak
Tux's lil' helper
Tux's lil' helper


Joined: 01 Sep 2002
Posts: 107

PostPosted: Fri Aug 25, 2017 6:33 pm    Post subject: Reply with quote

I have no idea why grub2-mkconfig does not like ones named bzImage, but I for some reason thought it would be okay so I really couldn't think at first why it wasn't working.

When I compile a new kernel I usually just rename the previous one so those old ones are still there in /boot
For instance, one of my /boot look like this:
Code:
# ls -lh /boot
total 76M
-rw-r--r-- 1 root root 5.6M Sep 30  2016 bzImage
-rw-r--r-- 1 root root 5.6M Jan 24  2015 bzImage.1
-rw-r--r-- 1 root root 5.6M Dec 29  2015 bzImage.10
-rw-r--r-- 1 root root 5.6M Dec 29  2015 bzImage.11
-rw-r--r-- 1 root root 5.5M Sep 30  2016 bzImage.12
-rw-r--r-- 1 root root 6.0M Feb  3  2015 bzImage.2
-rw-r--r-- 1 root root 6.0M Mar 11  2015 bzImage.3
-rw-r--r-- 1 root root 6.0M Mar 12  2015 bzImage.4
-rw-r--r-- 1 root root 6.1M Apr 29  2015 bzImage.5
-rw-r--r-- 1 root root 6.1M May  2  2015 bzImage.6
-rw-r--r-- 1 root root 6.1M May 10  2015 bzImage.7
-rw-r--r-- 1 root root 5.5M May 11  2015 bzImage.8
-rw-r--r-- 1 root root 5.5M May 19  2015 bzImage.9
drwxr-xr-x 6 root root 1.0K May 19  2015 grub
drwx------ 2 root root  12K Jan 23  2015 lost+found

The older kernels have the lower numbers. Yeah it could probably use some cleaning up doesn't really need to be a dozen of them.

If I want to know the version i can use file:
Code:
# file /usr/src/linux
/usr/src/linux: symbolic link to linux-4.7.5-gentoo/
# file /boot/bzImage
/boot/bzImage: Linux kernel x86 boot executable bzImage, version 4.7.5-gentoo (root@nyx) #1 SMP Fri Sep 30 09:11:25 EDT 2016, RO-rootFS, swap_dev 0x5, Normal VGA


Now if I do get one that doesn't boot, can usually do some stuff with grub, like edit the grub boot menu or at the grub> prompt. Like the first time I got the grub2 to boot manually on this new install I finally found I had to do:
Code:
grub> linux /boot/bzImage root=/dev/sda2
grub> boot

And just use for example bzImage.12 or whichever was the latest working one. I don't remember if you can really list them from grub and I have a hard time remembering something like for example vmlinuz-3.19.27-r1 or some such. Of course there could be extra entries for other kernels in a boot menu, named whatever. Except for grub-mkconfig doesn't understand all that I guess, has to be a certain proper name so it knows it actually has a kernel or something?

So I've always been happy just leaving the current kernel named bzImage, never would have thought it was that uncommon, but who knows..
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 5968
Location: Saint Amant, Acadiana

PostPosted: Fri Aug 25, 2017 6:58 pm    Post subject: Reply with quote

All my kernels are bzImage, so there is at least two of us. :P
_________________
Please learn how to denote units correctly!

Political Correctness is all about replacing imaginary injustice with real injustice.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 6375
Location: almost Mile High in the USA

PostPosted: Fri Aug 25, 2017 7:27 pm    Post subject: Reply with quote

I leave mine named bzImage as well, at least for the machines that are still using grub-legacy! The grub2 machines I ended up just going with the flow.

However I do name all of my kernels with the version plus any special feature flags, like adding -gentoo if it's a gentoo-sources kernel. Makes it a lot easier in the bootloader if I don't have access to tools to tell what kernel each are when trying to boot a dead machine. BTW, grub-legacy and grub2 you can actually tab-complete files so you get a list of all files in that directory. How's that for convenient - another reason why I love grub (though EFI's efishell is better...).

Oddly enough, Gentoo is already applying a patch to the glob patterns. Perhaps we can get^H^H^H^H bribe :( a Gentoo dev to add bzImage to the list of kernel names. In
Code:
portage/sys-boot/grub/files/grub-2.02_beta2-KERNEL_GLOBS.patch

we just need to add /boot/bzImage-* and /bzImage-* to the list of globs - note that one still needs to name them bzImage-4.9.34 with a hyphen between bzImage and the version number.
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
gen2saurus
n00b
n00b


Joined: 20 Aug 2017
Posts: 10

PostPosted: Sat Aug 26, 2017 8:46 am    Post subject: Reply with quote

Jaglover wrote:
There is no standard procedure in Gentoo, everybody does what they like and suits them best. I myself (if I used Grub2) would write grub.cfg by hand and never run that script.
It is not Gentoo but the kernel compilation procedure.

P.S. *NIX world is very flexible, so you can do all things different ways...
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 6375
Location: almost Mile High in the USA

PostPosted: Mon Aug 28, 2017 8:07 am    Post subject: Reply with quote

Hooray... I found a good use...
I think I finally got my RAID5 system's grub to grub-mkconfig a grub.cfg file that does not need hacking before I can dump and use. Whew. I think the last hack was making my custom initramfs accept the output of grub-mkconfig (grr...)

But one last issue: I stick the virtual machines' kernels in this host machine's boot directory which grub-mkconfig happily picks up. Why I don't use another directory? Creature of habit and I use direct kernel boot instead of in-image kernel boot.

Now if I name these VM kernels bzImage-blahblah and the host machines' kernels kernel-blahblah ... Problem solved :D
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo 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