View previous topic :: View next topic |
Author |
Message |
PCNet3000 n00b
Joined: 29 Jan 2024 Posts: 4 Location: East Asia
|
Posted: Mon Jan 29, 2024 12:13 pm Post subject: No kernel and initrd in /boot after installing gentoo-kernel |
|
|
Hi,
I'm a gentoo newbie and am currently following the Handbook to finish my first gentoo installation.
For the kernel section, I chose to install the distribution kernel:
Code: | emerge --ask sys-kernel/gentoo-kernel |
During the installation there was a minor hiccup with emerge asking me to add the USE flag 'dracut' to the package 'installkernel', and I did that manually in /etc/portage/package.use/use.
However, after I installed GRUB2 and used `grub-mkconfig -o /boot/grub/grub.cfg`, it didn't detect any linux kernel. As a result the new intallation cannot be booted.
I checked and there are no kernel and initrd in /boot.
Code: |
(chroot) # ls /boot
efi gentoo grub loader
|
However there seems to be something in /boot/gentoo/.6.13-gentoo-dist/:
Code: |
(chroot) # ls -lah /boot/gentoo/6.6.13-gentoo-dist/
29M initrd
12M linux
|
What am I doing wrong? Thanks!
Some information
Hardware: Intel Atom D2550 (EMT64 disabled in firmware, amd64 is not supported)
Stage3: stage3-i686-systemd-mergedusr-*.tar.xz
Please tell me if more information is needed. |
|
Back to top |
|
|
GDH-gentoo Veteran
Joined: 20 Jul 2019 Posts: 1569 Location: South America
|
Posted: Mon Jan 29, 2024 12:40 pm Post subject: |
|
|
PCNet3000 wrote: | During the installation there was a minor hiccup with emerge asking me to add the USE flag 'dracut' to the package 'installkernel', and I did that manually in /etc/portage/package.use/use. |
Also set the grub USE flag for sys-kernel/installkernel. _________________
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 |
|
|
AndrewAmmerlaan Developer
Joined: 25 Jun 2014 Posts: 292 Location: Nijmegen
|
Posted: Mon Jan 29, 2024 1:02 pm Post subject: |
|
|
GDH-gentoo wrote: |
Also set the grub USE flag for sys-kernel/installkernel. |
And then reinstall the kernel with emerge --config gentoo-kernel
This is documented in the handbook, but maybe it is unclear and/or in the wrong spot. The installkernel changes are still a bit fresh, so it would be very helpful to get feedback from you (as a new user) on how I can improve the documentation here to prevent other new users from running into the same issue. _________________ OS: Gentoo 6.8.10-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 |
|
|
PCNet3000 n00b
Joined: 29 Jan 2024 Posts: 4 Location: East Asia
|
Posted: Mon Jan 29, 2024 3:35 pm Post subject: |
|
|
Thanks for the information! I added the use flag and `reconfigured` the kernel package and it triggerd the configuration steps, and this time the two images are installed into /boot and are found by grub-mkconfig.
And somehow I found that if the EFI partition is mounted at /boot/efi during the configuration of kernel package, linux and initrd will be installed into /boot/efi instead of /boot, and grub-mkconfig would find them there. However the resulting grub.cfg won't have the corresponding menuentry, resulting in an unbootable system. This is kind of weird and I think I'll try some more times to verify the results.
Regarding the documentation, I understand that firstly gentoo itself is a moving target, and secondly it offers so many options such as different init systems and various boot loaders, so it can be at times difficult to make the documentation 100% resistance-free for newcomers. I think I'll install gentoo for a couple more times to familiarize myself with various new concepts!
Regards! |
|
Back to top |
|
|
AndrewAmmerlaan Developer
Joined: 25 Jun 2014 Posts: 292 Location: Nijmegen
|
Posted: Mon Jan 29, 2024 4:07 pm Post subject: |
|
|
PCNet3000 wrote: | Thanks for the information! I added the use flag and `reconfigured` the kernel package and it triggerd the configuration steps, and this time the two images are installed into /boot and are found by grub-mkconfig.
And somehow I found that if the EFI partition is mounted at /boot/efi during the configuration of kernel package, linux and initrd will be installed into /boot/efi instead of /boot, and grub-mkconfig would find them there. However the resulting grub.cfg won't have the corresponding menuentry, resulting in an unbootable system. This is kind of weird and I think I'll try some more times to verify the results. |
That sounds like there is some bug here. Can I see the output of 'tree /boot' (tree is part of app-text/tree), the contents of the generated grub.cfg and the output of the 'emerge --config gentoo-kernel' command?
Quote: |
Regarding the documentation, I understand that firstly gentoo itself is a moving target, and secondly it offers so many options such as different init systems and various boot loaders, so it can be at times difficult to make the documentation 100% resistance-free for newcomers. I think I'll install gentoo for a couple more times to familiarize myself with various new concepts!
|
Yes you are right, the perfect documentation is unobtainable, that won't stop me from trying to make it better anyway _________________ OS: Gentoo 6.8.10-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 |
|
|
sMueggli Guru
Joined: 03 Sep 2022 Posts: 377
|
Posted: Mon Jan 29, 2024 5:34 pm Post subject: |
|
|
AndrewAmmerlaan wrote: | PCNet3000 wrote: | Thanks for the information! I added the use flag and `reconfigured` the kernel package and it triggerd the configuration steps, and this time the two images are installed into /boot and are found by grub-mkconfig.
And somehow I found that if the EFI partition is mounted at /boot/efi during the configuration of kernel package, linux and initrd will be installed into /boot/efi instead of /boot, and grub-mkconfig would find them there. However the resulting grub.cfg won't have the corresponding menuentry, resulting in an unbootable system. This is kind of weird and I think I'll try some more times to verify the results. |
That sounds like there is some bug here. Can I see the output of 'tree /boot' (tree is part of app-text/tree), the contents of the generated grub.cfg and the output of the 'emerge --config gentoo-kernel' command?
|
I think there is a feature/bug in "kernel-install". Executing
Code: | kernel-install inspect |
shows (among others)
. But the expected and correct value should be "$BOOT: /boot".
The man page (LANG=C man 8 kernel-install) contains:
Code: | THE $BOOT PARTITION
The partition where the kernels and Boot Loader Specification[2] snippets are located
is called $BOOT. kernel-install determines the location of this partition by
checking /efi/, /boot/, and /boot/efi/ in turn. The first location where
$BOOT/loader/entries/ or $BOOT/ENTRY-TOKEN/ exists is used. |
But creating the directories /boot/loader/entries/ (and also the second possibility) did also not help in getting the correct "$BOOT partition".
@PCNet3000 can you please also share the output of
Code: | kernel-install inspect | ? Attention: The output contains your /etc/machine-id (if you have privacy concerns). |
|
Back to top |
|
|
AndrewAmmerlaan Developer
Joined: 25 Jun 2014 Posts: 292 Location: Nijmegen
|
Posted: Mon Jan 29, 2024 5:59 pm Post subject: |
|
|
sMueggli wrote: |
I think there is a feature/bug in "kernel-install". Executing
Code: | kernel-install inspect |
shows (among others)
. But the expected and correct value should be "$BOOT: /boot". |
No this is correct. Note that the manual says it looks for a partition at these locations. If your ESP is mounted at /boot/efi it is correctly identifying that as the KERNEL_INSTALL_BOOT_ROOT. You may override the auto-detection by specifying BOOT_ROOT=/somewhere/else in the environment.
What has got me confused is that you say grub-mkconfig finds your installed kernel+initrd, but then fails to boot and that there is no correct entry in the grub.cfg.
[EDIT]
Could you try setting GRUB_CFG=/boot/grub/grub.cfg and then repeating the kernel installation? _________________ OS: Gentoo 6.8.10-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 |
|
|
sMueggli Guru
Joined: 03 Sep 2022 Posts: 377
|
Posted: Mon Jan 29, 2024 7:13 pm Post subject: |
|
|
AndrewAmmerlaan wrote: | No this is correct. Note that the manual says it looks for a partition at these locations. If your ESP is mounted at /boot/efi it is correctly identifying that as the KERNEL_INSTALL_BOOT_ROOT. You may override the auto-detection by specifying BOOT_ROOT=/somewhere/else in the environment. |
Ok, if kernel-install wants to find the mount point for the ESP, it is correct. Nevertheless I have some doubts, that kernel-install is working correctly. I think, kernel-install has to handle two cases: the files need to be copied to the ESP for technical reasons and all other cases.
The first case is for EFI stub kernels. I guess the USE flags "uki" and "ukify" are situations where kernel-install should move the kernel to the ESP.
In all other cases the firmware is loading an EFI binary that is not moved by kernel-install, for example the firmware is loading a bootloader like grubx64.efi. In this case, it does not matter, where the ESP is mounted. In this case kernel-install should move the files to /boot, regardless whether /boot is the ESP or not.
There are several reasons to enforce the second case. One is that the ESP might be too small to contain the kernel and initramfs.
But the stronger case which is not handled correctly by kernel-install is if you are using a FDE (with encrypted /boot) and Grub as a bootloader. Some people do not want to enter the LUKS passphrase twice at boot and therefore include a LUKS key into the initramfs (which is encrypted on /boot). With the current behaviour of install-kernel the initramfs with the LUKS key is installed on the unencrypted ESP (and FAT does not even have file permissions). And that is a big security problem, at least in my point of view. |
|
Back to top |
|
|
AndrewAmmerlaan Developer
Joined: 25 Jun 2014 Posts: 292 Location: Nijmegen
|
Posted: Mon Jan 29, 2024 9:01 pm Post subject: |
|
|
sMueggli wrote: | [There are several reasons to enforce the second case. One is that the ESP might be too small to contain the kernel and initramfs.
But the stronger case which is not handled correctly by kernel-install is if you are using a FDE (with encrypted /boot) and Grub as a bootloader. Some people do not want to enter the LUKS passphrase twice at boot and therefore include a LUKS key into the initramfs (which is encrypted on /boot). With the current behaviour of install-kernel the initramfs with the LUKS key is installed on the unencrypted ESP (and FAT does not even have file permissions). And that is a big security problem, at least in my point of view. |
I see your point.
I can adjust the plugin to always install to /boot instead of KERNEL_INSTALL_BOOT_ROOT. It seems that kernel-install defaults to installing things to the $BOOT partition because systemd-boot can only boot kernels from the ESP, this is not the case for GRUB since it understand more partition types and thus this whole "find the $BOOT partition" logic is irrelevant for GRUB users.
Before I start changing things though, it would be great to know if the OP's issue is solved by BOOT_ROOT="/boot" emerge --config gentoo-kernel. If not then there may be a second problem that I have to solve. _________________ OS: Gentoo 6.8.10-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 |
|
|
PCNet3000 n00b
Joined: 29 Jan 2024 Posts: 4 Location: East Asia
|
Posted: Tue Jan 30, 2024 1:53 am Post subject: |
|
|
Thanks for taking time to look into this!
Since my current installation has already been "fixed", and I didn't save the output when the installation was "bad", I believe now I need to repeat this issue on a modern fast machine(VM), and report back with all the information everyone have asked for. I think I'll be back in several hours. |
|
Back to top |
|
|
PCNet3000 n00b
Joined: 29 Jan 2024 Posts: 4 Location: East Asia
|
Posted: Tue Jan 30, 2024 6:54 am Post subject: |
|
|
I've experimented with another brand new installation for some time, and I tried to replicate my previous exact steps during the second attempt, and collected some information during different stages.
Just after emerging sys-kernel/gentoo-kernel, with only 'dracut' applied to sys-kernel/installkernel as required by emerge:
(GRUB2 is not installed, ESP not mounted)
tree /boot: https://paste.debian.net/plain/1305704
kernel-install inspect https://paste.debian.net/plain/1305705
And after these steps: (I mounted ESP because grub-install involved writing to it.)
Code: | # echo 'GRUB_PLATFORMS="efi-64"' >> /etc/portage/make.conf
# emerge --ask sys-boot/grub
# mkdir /boot/efi
# mount /dev/sda1 /boot/efi
|
tree /boot: https://paste.debian.net/plain/1305708
kernel-install inspect: https://paste.debian.net/plain/1305710
($BOOT becomes /boot/efi)
And after grub-install --efi-directory=/boot/efi:
tree boot: https://paste.debian.net/plain/1305715
It was at this time I thought I could just 'grub-mkconfig' and reboot into the new system.
However this is what happened: https://paste.debian.net/plain/1305716
As shown in the paste, grub-mkconfig detects no kernel and initrd, and there is no menuentry in grub.cfg.
After receiving help from the forum, I added USE flag 'grub' to installkernel and did
(emerge --newuse installkernel after adding USE flag 'grub' seems to be an important step)
Code: | emerge --ask --newuse sys-kernel/installkernel
emerge --config sys-kernel/gentoo-kernel
|
The outputs are:
https://paste.debian.net/plain/1305719
https://paste.debian.net/plain/1305720
https://paste.debian.net/plain/1305722
I trimmed the very long dracut outputs to fit within the pastebin length limit. As can be seen near the end it automatically generated "new GRUB config as /boot/efi/grub/grub.cfg" instead of /boot/grub/grub.cfg, and detected linux and initrd at /boot/efi/.
The content of this new grub.cfg is: https://paste.debian.net/plain/1305721
There are menuentries, but after a reboot the menu is not shown and instead I'm thrown directly at the grub command prompt. I think GRUB is actually using /boot/grub/grub.cfg which does not contain any menuentry.
Manually running grub-mkconfig again does not detect those images at /boot/efi, probably because of the difference in $BOOT_ROOT.
And finally, with 'BOOT_ROOT="/boot" emerge --config sys-kernel/gentoo-kernel', it still insists to work with /boot/efi, as can be seen in the paste:
https://paste.debian.net/plain/1305723
The only way I've found to work at the moment is to umount /boot/efi, so that kernel config falls back to "KERNEL_INSTALL_BOOT_ROOT autodetection yielded no candidates, using "/boot".": https://paste.debian.net/plain/1305724 |
|
Back to top |
|
|
AndrewAmmerlaan Developer
Joined: 25 Jun 2014 Posts: 292 Location: Nijmegen
|
Posted: Tue Jan 30, 2024 8:32 am Post subject: |
|
|
PCNet3000 wrote: |
I trimmed the very long dracut outputs to fit within the pastebin length limit. As can be seen near the end it automatically generated "new GRUB config as /boot/efi/grub/grub.cfg" instead of /boot/grub/grub.cfg, and detected linux and initrd at /boot/efi/.
The content of this new grub.cfg is: https://paste.debian.net/plain/1305721
There are menuentries, but after a reboot the menu is not shown and instead I'm thrown directly at the grub command prompt. I think GRUB is actually using /boot/grub/grub.cfg which does not contain any menuentry.
Manually running grub-mkconfig again does not detect those images at /boot/efi, probably because of the difference in $BOOT_ROOT.
And finally, with 'BOOT_ROOT="/boot" emerge --config sys-kernel/gentoo-kernel', it still insists to work with /boot/efi, as can be seen in the paste:
https://paste.debian.net/plain/1305723
The only way I've found to work at the moment is to umount /boot/efi, so that kernel config falls back to "KERNEL_INSTALL_BOOT_ROOT autodetection yielded no candidates, using "/boot".": https://paste.debian.net/plain/1305724 |
Thanks for the detailed debugging. I now understand the problem. grub-mkinstall will (by default) install a grub efi executable that always loads /boot/grub/grub.cfg (not /boot/efi/grub/grub.cfg), which means the grub.cfg we put on the KERNEL_INSTALL_BOOT_ROOT is ignored when this variable is not detected as /boot.
I will have a fix soon (the fix will involve simply ignoring the KERNEL_INSTALL_BOOT_ROOT, and using /boot always) _________________ OS: Gentoo 6.8.10-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 |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 4333 Location: Bavaria
|
|
Back to top |
|
|
jnack95 n00b
Joined: 28 Jun 2008 Posts: 21
|
Posted: Thu Feb 01, 2024 5:26 am Post subject: |
|
|
I'm also having problems because I have a fresh install on a new machine with /efi and not /boot/efi. I installed gentoo-kernel and everything was fine until i updated today. I'm also trying to use a dist-kernel for the first time after manually configuring the kernel for many years so I'm not super confident with what I am doing. When I emerge gentoo-kernel it puts the initrd and kernel image in /efi and grub is confused and does not update... It seemed the first install i did put an intrd and a vmlinuz image in /boot and grub was happy. Thanks |
|
Back to top |
|
|
AndrewAmmerlaan Developer
Joined: 25 Jun 2014 Posts: 292 Location: Nijmegen
|
Posted: Thu Feb 01, 2024 7:24 am Post subject: |
|
|
jnack95 wrote: | I'm also having problems because I have a fresh install on a new machine with /efi and not /boot/efi. I installed gentoo-kernel and everything was fine until i updated today. I'm also trying to use a dist-kernel for the first time after manually configuring the kernel for many years so I'm not super confident with what I am doing. When I emerge gentoo-kernel it puts the initrd and kernel image in /efi and grub is confused and does not update... It seemed the first install i did put an intrd and a vmlinuz image in /boot and grub was happy. Thanks |
It's a bug in installkernel, it will be fixed in the next version.
kernel-install insists on using the ESP as BOOT_ROOT, grub insists on the grub.cfg being at /boot/grub/grub.cfg. I have already solved this in upstream installkernel by simply ignoring the BOOT_ROOT that installkernel tells us about and using /boot always. A new version with the fix will be available soon once we have ironed out some other issues.
As a short term workaround, disable the systemd flag on installkernel to fallback to the traditional behaviour. _________________ OS: Gentoo 6.8.10-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 |
|
|
AndrewAmmerlaan Developer
Joined: 25 Jun 2014 Posts: 292 Location: Nijmegen
|
Posted: Fri Feb 02, 2024 7:32 am Post subject: |
|
|
Version 23 of installkernel should work better for you. Please let me know if there still is some problem. _________________ OS: Gentoo 6.8.10-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 |
|
|
|