Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Systemd-boot error even when using GRUB, cannot boot
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
neoissad
n00b
n00b


Joined: 27 Mar 2024
Posts: 9

PostPosted: Wed Mar 27, 2024 7:43 pm    Post subject: Systemd-boot error even when using GRUB, cannot boot Reply with quote

I am trying to use UKI with GRUB and gentoo-kernel-bin. systemd-boot is not installed to my efi directory. However, after updating systemd-utils with boot and kernel-install, I can no longer boot, and get the error

Code:
systemd-boot: Assertion 'device' failed at ../systemd-stable-254.8/src/boot/efi/part-discovery.c:251@partition\_open, halting

Here is my relevant package.use:

Code:
sys-kernel/installkernel grub dracut uki
sys-apps/systemd-utils boot kernel-install


I am using OpenRC and UEFI. I'm pretty new to Gentoo, any help would be appreciated!
Back to top
View user's profile Send private message
kimchi_sg
Advocate
Advocate


Joined: 26 Nov 2004
Posts: 3038

PostPosted: Thu Mar 28, 2024 12:55 am    Post subject: Re: Systemd-boot error even when using GRUB, cannot boot Reply with quote

neoissad wrote:
I am trying to use UKI with GRUB and gentoo-kernel-bin. systemd-boot is not installed to my efi directory. However, after updating systemd-utils with boot and kernel-install, I can no longer boot, and get the error

Which do you want to use, GRUB or systemd-boot?

They are mutually exclusive.

If you want to use GRUB, remove USE=boot from systemd-utils and remove USE=systemd from installkernel.
Back to top
View user's profile Send private message
neoissad
n00b
n00b


Joined: 27 Mar 2024
Posts: 9

PostPosted: Thu Mar 28, 2024 3:08 am    Post subject: Reply with quote

I'm trying to use GRUB. I removed the USE=boot from systemd-utils. My current use flags for installkernel and systemd-utils are
Code:
sys-kernel/installkernel dracut grub
sys-apps/systemd-utils acl kmod python_single_target_python3_11 tmpfiles udev abi_x86_32

After rerunning `emerge --config gentoo-kernel-bin`, unmounting drives, and rebooting, I still get the same error.
Back to top
View user's profile Send private message
Nowa
Developer
Developer


Joined: 25 Jun 2014
Posts: 431
Location: Nijmegen

PostPosted: Thu Mar 28, 2024 2:26 pm    Post subject: Reply with quote

Quote:
I am trying to use UKI with GRUB and gentoo-kernel-bin


Quote:
If you want to use GRUB, remove USE=boot from systemd-utils and remove USE=systemd from installkernel.


This advice is wrong. An UKI requires systemd-stub loader (an alternative EFI stub loader), it is installed with the "boot" flag that also controls the installation of systemd-boot. So OP should have the boot flag enabled. Additionally, the systemd flag makes no difference here, both systemd kernel-install and the legacy installkernel are compatible with GRUB.

The issue you are seeing likely originates in systemd-stub and it looks to be related to systemd's automatic partition discovery. Are you sure you are passing the correct "root=" on the kernel command line? Note that UKIs have a built in command line (which is set by /etc/kernel/cmdline if using ukify and by /etc/dracut.conf if using dracut), that grub may and will override if secureboot is disabled.

[EDIT] You may want to try and upgrade to systemd 255, there are many essential fixes and improvements for UKIs in that release. For the same reason you should use the latest version of GRUB.
_________________
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
View user's profile Send private message
neoissad
n00b
n00b


Joined: 27 Mar 2024
Posts: 9

PostPosted: Thu Mar 28, 2024 2:57 pm    Post subject: Reply with quote

Thanks for the reply. The only kernel command line parameter I'm using is loglevel=6, what is the "root=" parameter for? I also forgot to mention that I'm not sure if my UKI even is building correctly, it doesn't show up in ESP/EFI/Linux, so that also may be the issue. How should I go about enabling systemd-utils 255? It doesn't appear to be even in testing on package.gentoo.org.
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 5138
Location: Bavaria

PostPosted: Thu Mar 28, 2024 3:13 pm    Post subject: Reply with quote

neoissad wrote:
[...] what is the "root=" parameter for?[...]

This is one of the most important kernel command line parameters and informs the kernel/initramfs which is the root partition to mount. You probably never had contact with the parameter "root=" because ... the grub-mkconfig automatically finds out which is your root partition and adds it to the grub.cfg ... so that later - when the grub boots - this parameter is passed to the kernel/initramfs.

(See more here: https://wiki.gentoo.org/wiki/User:Pietinger/Tutorials/Kernel_Commandline_Parameter )

neoissad wrote:
[...] I also forgot to mention that I'm not sure if my UKI even is building correctly, it doesn't show up in ESP/EFI/Linux, so that also may be the issue.[...]

To better understand UEFI you could read this, where I describe how to boot a (manually configured) kernel directly via UEFI:
https://wiki.gentoo.org/wiki/User:Pietinger/Tutorials/Boot_kernel_via_UEFI
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
Nowa
Developer
Developer


Joined: 25 Jun 2014
Posts: 431
Location: Nijmegen

PostPosted: Thu Mar 28, 2024 3:20 pm    Post subject: Reply with quote

neoissad wrote:
Thanks for the reply. The only kernel command line parameter I'm using is loglevel=6, what is the "root=" parameter for? I also forgot to mention that I'm not sure if my UKI even is building correctly, it doesn't show up in ESP/EFI/Linux, so that also may be the issue. How should I go about enabling systemd-utils 255? It doesn't appear to be even in testing on package.gentoo.org.


root= specifies the location of the root partition e.g. 'root=PARTUUID=<output of blkid here>'. Grub does this automatically for you, but I'm not sure how this automation interacts with UKIs so I recommend to set the correct root= both as the grub cmdline and as the built-in cmdline.

You do not have the "uki" flag enabled on installkernel, which is why no UKI will be built (by dracut).

systemd-utils 255 indeed has no keywords yet. I suspect the reason is because systemd-255 dropped support for split-usr upstream, I recommend migrating to the merged-usr profiles soon. But lets first try the other steps (enabling the uki flag on installkernel and setting kernel_cmdline=... in /etc/dracut.conf).
_________________
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
View user's profile Send private message
neoissad
n00b
n00b


Joined: 27 Mar 2024
Posts: 9

PostPosted: Thu Mar 28, 2024 6:01 pm    Post subject: Reply with quote

AndrewAmmerlaan wrote:
You do not have the "uki" flag enabled on installkernel, which is why no UKI will be built (by dracut).


I set the root= parameter, USE=uki for installkernel is already enabled, and I've rerun emerge --config gentoo-kernel-bin to no avail. There still does not exist a directory containing the UKI in /efi/EFI very strangely. Even just trying to boot without all the UKI and systemd-boot stuff, I still get the same error

[edit] It might be notable that when changing profiles, I updated using emerge -uDN @world instead of emerge --emptytree @world
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 5138
Location: Bavaria

PostPosted: Thu Mar 28, 2024 6:16 pm    Post subject: Reply with quote

Please show us the (complete) output of:
Code:
emerge -pvD installkernel systemd-utils grub
ls -lR /efi
more /etc/dracut.conf
# here you can cut all the grub modules:
ls -lR /boot

_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
neoissad
n00b
n00b


Joined: 27 Mar 2024
Posts: 9

PostPosted: Thu Mar 28, 2024 6:24 pm    Post subject: Reply with quote

pietinger wrote:
Please show us the (complete) output of:
Code:
emerge -pvD installkernel systemd-utils grub
ls -lR /efi
more /etc/dracut.conf
# here you can cut all the grub modules:
ls -lR /boot


Here it is https://bpa.st/DDQA
Back to top
View user's profile Send private message
Nowa
Developer
Developer


Joined: 25 Jun 2014
Posts: 431
Location: Nijmegen

PostPosted: Thu Mar 28, 2024 6:33 pm    Post subject: Reply with quote

neoissad wrote:
AndrewAmmerlaan wrote:
You do not have the "uki" flag enabled on installkernel, which is why no UKI will be built (by dracut).


I set the root= parameter, USE=uki for installkernel is already enabled, and I've rerun emerge --config gentoo-kernel-bin to no avail. There still does not exist a directory containing the UKI in /efi/EFI very strangely. Even just trying to boot without all the UKI and systemd-boot stuff, I still get the same error

[edit] It might be notable that when changing profiles, I updated using emerge -uDN @world instead of emerge --emptytree @world


If the systemd flag on installkernel is disabled you have to create the ESP/EFI/Linux directory manually because the traditional installkernel lacks the ability to find the ESP and create the directory. After creating the directory installkernel will find it and install the UKI there.
_________________
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
View user's profile Send private message
neoissad
n00b
n00b


Joined: 27 Mar 2024
Posts: 9

PostPosted: Thu Mar 28, 2024 6:48 pm    Post subject: Reply with quote

AndrewAmmerlaan wrote:
neoissad wrote:
AndrewAmmerlaan wrote:
You do not have the "uki" flag enabled on installkernel, which is why no UKI will be built (by dracut).


I set the root= parameter, USE=uki for installkernel is already enabled, and I've rerun emerge --config gentoo-kernel-bin to no avail. There still does not exist a directory containing the UKI in /efi/EFI very strangely. Even just trying to boot without all the UKI and systemd-boot stuff, I still get the same error

[edit] It might be notable that when changing profiles, I updated using emerge -uDN @world instead of emerge --emptytree @world


If the systemd flag on installkernel is disabled you have to create the ESP/EFI/Linux directory manually because the traditional installkernel lacks the ability to find the ESP and create the directory. After creating the directory installkernel will find it and install the UKI there.


Oh geez, I missed such a simple thing. Now the error I get is something with the automatic grub-config loading /EFI/Linux/gentoo-6.6.21-gentoo-dist.efi root=<root-uuid-here> ro instead of that path in /efi
Back to top
View user's profile Send private message
Nowa
Developer
Developer


Joined: 25 Jun 2014
Posts: 431
Location: Nijmegen

PostPosted: Thu Mar 28, 2024 7:53 pm    Post subject: Reply with quote

It should be root=PARTUUID=<your PARTUUID here>. The PARTUUID= part is required to tell the kernel that what follows is a PARTUUID and not a path.
_________________
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
View user's profile Send private message
neoissad
n00b
n00b


Joined: 27 Mar 2024
Posts: 9

PostPosted: Thu Mar 28, 2024 8:14 pm    Post subject: Reply with quote

AndrewAmmerlaan wrote:
It should be root=PARTUUID=<your PARTUUID here>. The PARTUUID= part is required to tell the kernel that what follows is a PARTUUID and not a path.


I edited dracut.conf with your change, and I still get the file 'EFI/Linux/gentoo-6.6.21-gentoo-dist.efi' not found error. I suspect it's something to do with my grub.cfg where it defines the boot entries. Here's my automatically generated grub.cfg: https://bpa.st/GSPA

[edit] see line 94
Back to top
View user's profile Send private message
Nowa
Developer
Developer


Joined: 25 Jun 2014
Posts: 431
Location: Nijmegen

PostPosted: Thu Mar 28, 2024 8:40 pm    Post subject: Reply with quote

It is looking for the UKI on the wrong partition, the path is set relative to the EFI System Partition (as it should), but the UUID of the partition it is searching on is the same as for your entries in /boot. This must be wrong since these are in fact different partitions in your setup.

I suspect this is a bug in 'grub-mkconfig', the UKI support there is not something official in GRUB. It is something I "hacked" in via an environment variable in the installkernel plugin. Four workarounds I can think off:
1) adjusting grub.cfg manually (will have to be redone every time)
2) Mount the ESP at /boot, in this configuration plain kernel images are on the same partition as UKIs
3) Remove the ESP/EFI/Linux directory so installkernel falls back to installing UKIs in /boot
4) Use systemd-boot or refind instead of GRUB, or if the firmware supports it boot the UKI directly via EFI Stub.
_________________
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
View user's profile Send private message
neoissad
n00b
n00b


Joined: 27 Mar 2024
Posts: 9

PostPosted: Thu Mar 28, 2024 9:11 pm    Post subject: Reply with quote

AndrewAmmerlaan wrote:
It is looking for the UKI on the wrong partition, the path is set relative to the EFI System Partition (as it should), but the UUID of the partition it is searching on is the same as for your entries in /boot. This must be wrong since these are in fact different partitions in your setup.

I suspect this is a bug in 'grub-mkconfig', the UKI support there is not something official in GRUB. It is something I "hacked" in via an environment variable in the installkernel plugin. Four workarounds I can think off:
1) adjusting grub.cfg manually (will have to be redone every time)
2) Mount the ESP at /boot, in this configuration plain kernel images are on the same partition as UKIs
3) Remove the ESP/EFI/Linux directory so installkernel falls back to installing UKIs in /boot
4) Use systemd-boot or refind instead of GRUB, or if the firmware supports it boot the UKI directly via EFI Stub.


Option 1 works, but I don't really like the idea of that. Option 3 seems the most ideal, but I'm back to the original error message, albeit with a lot better understanding courtesy of you two. I'm guessing I have to tell systemd-boot to look for the efi-stub in the boot directory, but not sure how to do it. Either that or I can just give up on making a UKI.
Back to top
View user's profile Send private message
Nowa
Developer
Developer


Joined: 25 Jun 2014
Posts: 431
Location: Nijmegen

PostPosted: Fri Mar 29, 2024 12:13 am    Post subject: Reply with quote

neoissad wrote:
Option 1 works, but I don't really like the idea of that. Option 3 seems the most ideal, but I'm back to the original error message, albeit with a lot better understanding courtesy of you two. I'm guessing I have to tell systemd-boot to look for the efi-stub in the boot directory, but not sure how to do it. Either that or I can just give up on making a UKI.


The efi stub is part of the UKI, so apart from root= there should be no need to specify anything.

Something to try is to generate the UKI with ukify instead of dracut, there are slight differences in the generated UKI which may be causing this problem.
_________________
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
View user's profile Send private message
neoissad
n00b
n00b


Joined: 27 Mar 2024
Posts: 9

PostPosted: Fri Mar 29, 2024 10:03 pm    Post subject: Reply with quote

AndrewAmmerlaan wrote:
neoissad wrote:
Option 1 works, but I don't really like the idea of that. Option 3 seems the most ideal, but I'm back to the original error message, albeit with a lot better understanding courtesy of you two. I'm guessing I have to tell systemd-boot to look for the efi-stub in the boot directory, but not sure how to do it. Either that or I can just give up on making a UKI.


The efi stub is part of the UKI, so apart from root= there should be no need to specify anything.

Something to try is to generate the UKI with ukify instead of dracut, there are slight differences in the generated UKI which may be causing this problem.


I just ended up booting normally without a UKI, thanks for all of your help though!
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