View previous topic :: View next topic |
Author |
Message |
velladecin n00b
Joined: 02 Nov 2008 Posts: 17
|
Posted: Wed Feb 05, 2025 11:34 am Post subject: Kernel install (make install) + grub config |
|
|
I've setup /efi and many months I was happily compiling kernels and used 'make install' to install them into that directory and update grub.cfg (also under /efi). One day I made an update and 'make install' started installing into /boot instead.
I found out the hard way when after reboot I could not boot, grub menu was offering old entries which did not have corresponding kernel and ramdisk in /boot.
Since then I'm manually entering details via grub shell to be able to boot. AFAIK my grub menu is loaded from /efi containing the old entries but looks for kernels in /boot - I'm bit confused as to how this happens.. Mind you, I'm rather enjoying the use of grub shell these days
But there must be a parameter that decides where grub menu is loaded from and where grub looks for kernels. I tried /etc/conf.d /etc/default but nothing obvious there. Any suggestions? |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10733 Location: Somewhere over Atlanta, Georgia
|
Posted: Wed Feb 05, 2025 12:29 pm Post subject: |
|
|
Grub looks for the kernels & initramfs images where it was told to by the command line options used with grub-install, but this defaults to /boot. Is it possible you reinstalled grub to your boot disk at some point? To help figure this out, could you post your /etc/fstab file and also the output of Code: | fdisk --list /dev/sda | (substituting in the actual device of your boot disk), please?
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
|
velladecin n00b
Joined: 02 Nov 2008 Posts: 17
|
Posted: Wed Feb 05, 2025 12:41 pm Post subject: |
|
|
Thanks to using grub shell/cli I've now worked out how the grub menu works and see the paths definitions when passing linux and initrd options. I've hacked the menu and can boot directly via grub menu - well, until I re-run grub-install and the modified menu gets overwritten
So my question is how to force 'make install' to deposit kernels to /efi instead of /boot and when it runs grub-install to work with grub under /efi instead of /boot and to specify the right paths in grub.cfg
Also, I was thinking about removing /boot altogether to see if that forces 'make install' to use alternate location, specifically /efi..? But nicer would be to actually have control that's for sure. |
|
Back to top |
|
|
velladecin n00b
Joined: 02 Nov 2008 Posts: 17
|
Posted: Wed Feb 05, 2025 12:49 pm Post subject: |
|
|
Hi John,
I'm sure that grub did get re-installed as part of the update but I would have done the same number of times before. I can't remember what I did during the install and how/if I installed grub specifically into /efi. But will have a look at how to install grub to certain location.
## /etc/fstab
Code: | PARTUUID="36147838-95af-49dc-b5f4-a302f8c7dd9b" /efi vfat umask=0077 0 2
PARTUUID="028bc0f7-3efc-43e3-9935-17b53d3a418f" / xfs defaults,noatime 0 1
PARTUUID="0bd580d6-f684-47a2-9195-6a9b73760d33" /var xfs defaults,noatime 0 2
PARTUUID="f49bc823-e0a1-45c0-a739-74b7ca07098c" /home xfs defaults,noatime 0 2
|
## fdisk
Code: | Disk /dev/nvme0n1: 476.94 GiB, 512110190592 bytes, 1000215216 sectors
Disk model: Micron_2450_MTFDKBK512TFK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 320431C7-067B-5048-8A27-672EEC7300B1
Device Start End Sectors Size Type
/dev/nvme0n1p1 2048 2099199 2097152 1G EFI System
/dev/nvme0n1p2 2099200 106956799 104857600 50G Linux root (x86-64)
/dev/nvme0n1p3 106956800 190842879 83886080 40G Linux filesystem
/dev/nvme0n1p4 190842880 1000214527 809371648 385.9G Linux filesystem |
[Administrator edit: added [code] tags to preserve output layout. -Hu] |
|
Back to top |
|
|
velladecin n00b
Joined: 02 Nov 2008 Posts: 17
|
Posted: Wed Feb 05, 2025 9:41 pm Post subject: |
|
|
adding fdisk -l of /efi which has some additional output, nothing special for /root which also contains /boot
Code: |
Disk /dev/nvme0n1p1: 1 GiB, 1073741824 bytes, 2097152 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000
|
|
|
Back to top |
|
|
sublogic Guru
Joined: 21 Mar 2022 Posts: 310 Location: Pennsylvania, USA
|
Posted: Wed Feb 05, 2025 11:47 pm Post subject: |
|
|
@velladecin, I had a similar situation on a fresh install. I ended up splitting my /efi partition into an /efi and a /boot, as recommended in the Gentoo handbook.
Here's the forum thread. |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10733 Location: Somewhere over Atlanta, Georgia
|
Posted: Thu Feb 06, 2025 5:07 am Post subject: |
|
|
velladecin wrote: | ## /etc/fstab
Code: | PARTUUID="36147838-95af-49dc-b5f4-a302f8c7dd9b" /efi vfat umask=0077 0 2
PARTUUID="028bc0f7-3efc-43e3-9935-17b53d3a418f" / xfs defaults,noatime 0 1
PARTUUID="0bd580d6-f684-47a2-9195-6a9b73760d33" /var xfs defaults,noatime 0 2
PARTUUID="f49bc823-e0a1-45c0-a739-74b7ca07098c" /home xfs defaults,noatime 0 2
|
| So the situation is a little more nuanced—and I missed it because that's not the way I do it. (I'll explain that below.) Anyway, here's what's going on. Gentoo is moving towards (actually they're already there) recommending the "distribution kernel" approach, which is aware that kernel images need to be installed in the /efi partition (if it exists) or the /boot partition (if that exists). However, "make install" in the kernel source tree is not aware of this dichotomy, by default installing kernel images in /boot. There's an environment variable that works, though: INSTALL_PATH. You can either use this on the "make install" command, like this: Code: | INSTALL_PATH=/efi make install | or else set this in your .bashrc file.
I never did like using the EFI partition to store kernel & initramfs images because I use symlinks there, which FAT does not support. So from the very beginning of the UEFI evolution, I created an EFI partition (mounted on /efi) and a boot partition (usually ext2, mounted on /boot). I seldom mount /efi.
But if you don't want two partitions, and don't like the INSTALL_PATH solution described above, you can just mount your EFI partition on /boot. In this case, your /etc/fstab entry would be: Code: | PARTUUID="36147838-95af-49dc-b5f4-a302f8c7dd9b" /boot vfat umask=0077 0 2 | Your UEFI bootloader doesn't care about (in fact is unaware of) the name of the Linux mount point and neither does grub (at boot time, at least).
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters.
Last edited by John R. Graham on Thu Feb 06, 2025 12:13 pm; edited 4 times in total |
|
Back to top |
|
|
Nowa Developer
Joined: 25 Jun 2014 Posts: 478 Location: Nijmegen
|
Posted: Thu Feb 06, 2025 9:14 am Post subject: Re: Kernel install (make install) + grub config |
|
|
velladecin wrote: | But there must be a parameter that decides where grub menu is loaded from and where grub looks for kernels. I tried /etc/conf.d /etc/default but nothing obvious there. Any suggestions? |
The --boot-directory option for grub-install controls where the grub.cfg is loaded from. The GRUB_CFG environment variable controls where sys-kernel/installkernel puts the grub.cfg. _________________ OS: Gentoo 6.10.12-gentoo-dist, ~amd64, 23.0/desktop/plasma/systemd
MB: MSI Z370-A PRO
CPU: Intel Core i9-9900KS
GPU: Intel Arc A770 16GB & Intel UHD Graphics 630
SSD: Samsung 970 EVO Plus 2 TB
RAM: Crucial Ballistix 32GB DDR4-2400 |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10733 Location: Somewhere over Atlanta, Georgia
|
Posted: Thu Feb 06, 2025 12:18 pm Post subject: |
|
|
sublogic wrote: | ... I ended up splitting my /efi partition into an /efi and a /boot, as recommended in the Gentoo handbook. ... | (Italics mine.) Alas, no more. Personally, I don't like that simplification.
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
|
GDH-gentoo Veteran
Joined: 20 Jul 2019 Posts: 1806 Location: South America
|
Posted: Thu Feb 06, 2025 3:01 pm Post subject: |
|
|
You can convince make install to install the kernel in the EFI System Partition (ESP) by appropiately setting USE flags for sys-kernel/installkernel. But I don't think that you can convince grub-mkconfig to look for kernels in places other that /boot. If you managed to do that in the past, I don't know how you did it.
That said, I don't see the point of installing kernels in the ESP unless they are EFI stubs that will be booted directly by the UEFI firmware (which you are not doing if you use GRUB), or you are using a bootloader that can't deal with filesystems other than FAT (again, not GRUB's case). And I don't see the point of installing a UKI either, unless you are using secure boot. _________________
NeddySeagoon wrote: | I'm not a witch, I'm a retired electronics engineer |
Ionen wrote: | As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though |
|
|
Back to top |
|
|
sublogic Guru
Joined: 21 Mar 2022 Posts: 310 Location: Pennsylvania, USA
|
Posted: Fri Feb 07, 2025 2:27 am Post subject: |
|
|
GDH-gentoo wrote: | You can convince make install to install the kernel in the EFI System Partition (ESP) by appropiately setting USE flags for sys-kernel/installkernel. But I don't think that you can convince grub-mkconfig to look for kernels in places other that /boot. If you managed to do that in the past, I don't know how you did it. | That was my reaction to the initial post.
John R. Graham wrote: | sublogic wrote: | ... I ended up splitting my /efi partition into an /efi and a /boot, as recommended in the Gentoo handbook. ... | (Italics mine.) Alas, no more. Personally, I don't like that simplification. | Yeah, me neither but it's done. Indeed the handbook has changed here, but how is that going to work with grub ? The grub entry in the bootloader section only says to emerge installkernel with USE=grub . Later the fstab has no /boot entry. grub-mkconfig will break, no ?
Is the handbook broken with respect to GPT + UEFI + grub ? |
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 5386 Location: Bavaria
|
Posted: Fri Feb 07, 2025 3:24 am Post subject: |
|
|
sublogic wrote: | Is the handbook broken with respect to GPT + UEFI + grub ? |
No.
First of all: There is no recommendation in the Handbook for an extra boot partition when UEFI is used (only old MBR boot needs this). Today /boot is just a directory of the root directory (= in the root partition).
Yes, the 2nd part of grub is - and was always - in /boot/grub. Therefore the grub.cfg is in that directory. The first part of grub is in \EFI\gentoo\grubx64.efi of the ESP ... if you mount this partition (fs) to your efi-directory you will see it as: /efi/EFI/gentoo/grubx64.efi (or /efi/efi/gentoo/grubx64.efi ... UEFI dont care if it is uppercase or lowercase).
Please read this (old) post to understand what has changed in September 2023:
https://forums.gentoo.org/viewtopic-t-1165115-highlight-.html
A normal installation with our AMD64 Handbook gives you:
- one ESP (with 1 GB)
- one partition for swap and one for root
- "installkernel" will install every kernel in /boot/. (if you do a "make install" for a manually configured kernel there are hooks from installkernel) + renames the kernel to a name which is recognized later by grub-mkconfig
- "grub-install" will create the grubx64.efi in the ESP + creates /boot/grub/* with the 2nd part of grub
- "grub-mkconfig" searches for kernels (and initramfs-files) in /boot/ which have a given naming scheme (so it will not recognize a "naked" "bzImage") + creates the grub.cfg in /boot/grub
As soon as you deviate from this standard you have to expect problems ... or know what to do ... e.g. I have a manually configured kernel that does not need/have an initramfs, which I boot directly via UEFI (without a boot manager). Here I had to globally eliminate the USE-flag “initramfs”. Of course I don't have an “installkernel” emerged ... I copy my kernel to \efi\ myself ... (-> https://wiki.gentoo.org/wiki/User:Pietinger/Tutorials/Boot_kernel_via_UEFI ) _________________ https://wiki.gentoo.org/wiki/User:Pietinger |
|
Back to top |
|
|
sublogic Guru
Joined: 21 Mar 2022 Posts: 310 Location: Pennsylvania, USA
|
Posted: Sat Feb 08, 2025 2:46 am Post subject: |
|
|
Ok, so the handbook is fine. Good.
pietinger wrote: | As soon as you deviate from this standard you have to expect problems ... or know what to do | ... such as placing root in LVM over LUKS with pbkdf=argon2id, beyond the reach of grub, like I did ? Yep.
Thanks for the clarification.
Back to the OP, I think GDH-gentoo's post is the final word: you can get your kernels to install in the ESP, but grub-mkconfig won't play.
Okay, maybe not. Mount your ESP on /boot , per Zucca's post in the other thread ? Beware, Zucca doesn't use grub, you will be a pioneer. |
|
Back to top |
|
|
|