Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Suggestion for the handbook regarding systemd-boot.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
De-Javu
n00b
n00b


Joined: 30 Mar 2009
Posts: 24
Location: USA

PostPosted: Sat Oct 14, 2023 10:08 am    Post subject: Suggestion for the handbook regarding systemd-boot. Reply with quote

If you follow the Handbook's procedure to set up Gentoo with a distribution kernel, with the intention of installing systemd-boot, and then move over to the systemd-boot wiki page (linked at the end of the post), it doesn't work. Dracut doesn't run as it should and thus we can't boot. A few steps are missing.

If you were to follow the handbook, switch over to the systemd-boot wiki page, but didn't read beyond the section where it shows how to install the bootloader, "Linux Boot Manager" will show as an EFI boot option but it will not work because no configuration was generated and dracut probably failed to run. However, users who read the whole page before installing will notice there are additional steps needed for this to actually work.

Since I am following the Handbook, I am in the Gentoo official LiveCD, chroot'ed with arch-chroot /mnt/gentoo. Inside the chroot I can verify all mount points are correct and accurate.

The Handbook would have you build sys-kernel/gentoo-kernel(-bin) without the systemd and initramfs USE flags. I am not 100% sure but I think systemd should be built with appropriate boot flags and dracut should be present before the kernel installation. I think this should be mentioned, because there are already provisions in the Handbook for users intending to have systemd-boot, and it is not intuitive for certain needed commands or prerequisite USE flags to be omitted from the Handbook.

For example, the handbook will have you run the following command before installing the kernel:

Code:
# emerge --ask sys-kernel/installkernel-systemd-boot


But it does not tell you that it won't actually work or fully install without consulting other pages of the wiki. I think there should be a note here for systemd-boot users, even if it's simply suggesting to check the systemd-boot page for other needed steps. While it could be argued that a systemd user should know to put systemd in their USE flags, the also-needed initramfs flag is not so obvious.

To reproduce the issue:
1) Start a new Gentoo install from Gentoo media
2) Use any systemd stage3 and follow the guide as normal, using sys-kernel/installkernel-systemd-boot and then any kernel you want. Notice dracut does not run after installing the kernel as it should.
3) Follow the instructions at https://wiki.gentoo.org/wiki/Systemd/systemd-boot once you reach the "Installing the Bootloader" section of the handbook.
4) Reboot the PC ("Linux Boot Loader" will show as an EFI boot option but it will not work)

To fix the issue:
1) After installing installkernel-systemd-boot, but before installing the kernel, apply the following USE flags: systemd, initramfs, and either boot or gnuefi, depending on systemd version. [For explanation, please consult the systemd-boot wiki page below.]
2) Make sure sys-kernel/dracut is installed before the kernel is installed.
3) Tell /etc/kernel/cmdline where the root partition is, as described here, so the configuation is automatically generated: https://wiki.gentoo.org/wiki/Systemd/systemd-boot#Automatically_generate_menu_entries
3) Build your kernel; via gentoo-kernel, genkernel or manually. You should now see dracut output at the end of the kernel install (as shown at the end of the post as an example). Now, if you were to now run emerge --config sys-kernel/gentoo-kernel it should call up dracut as expected.
4) Run bootctl install (assuming ESP is mounted to a compliant location)
5) Make sure there is an automatically generated .conf file in the directory /efi/loader/entries.

At this point you can reboot and everything works.

It's also a good idea to install efibootmgr before rebooting, since that way you can check and see if "Linux Boot Manager" was actually added to the list of boot options.

Links, thoughts, and disclaimers:
I also think systemd-boot should be included with other bootloaders on the "Installing the Bootloader" page, as it's been gaining popularity faster due to use in several other distros, so I think users are more familiar with it than Syslinux as an alternative boot loader.

I think if you wanted a systemd + systemd-boot based system, you probably want the systemd flag set in make.conf, so I didn't test it any other way (for instance, via package.use). I'm also not using secure boot on my system and extra steps are needed to enable secure boot support. That is not covered here.

systemd-boot is not shown as a bootloader option on the Handbook page "Configuring the bootloader". I think it should be there for people who followed systemd-boot instructions up until that point. https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Bootloader

As it is, if someone is following the Handbook and systemd-boot wiki page, they will find dracut can not be invoked successfully by installkernel-systemd-boot:
Code:
# eselect kernel list
Available kernel symlink targets:
 [1]  linux-6.1.55-gentoo-dist *
# dracut
dracut: Cannot find module directory /lib/modules/6.1.46-gentoo-x86_64
# dracut --hostonly --kver 6.1.55-gentoo-dist
dracut: Executing: /usr/bin/dracut --hostonly --kver 6.1.55-gentoo-dist
dracut: Can't write to /efi/Default/6.1.55-gentoo-dist: Directory /efi/Default/6.1.55-gentoo-dist does not exist or is not accessible.


systemd-boot Wiki page - https://wiki.gentoo.org/wiki/Systemd/systemd-boot

This is an example of a correct dracut output, and it appears immediately before emerge's notification that gentoo-kernel (or whatever else) finished installing.

Code:
dracut: *** Including module: dracut-systemd ***
dracut: *** Including module: usrmount ***
dracut: *** Including module: base ***
dracut: *** Including module: fs-lib ***
dracut: *** Including module: shutdown ***
dracut: *** Including modules done ***
dracut: *** Installing kernel module dependencies ***
dracut: *** Installing kernel module dependencies done ***
dracut: *** Resolving executable dependencies ***
dracut: *** Resolving executable dependencies done ***
dracut: *** Hardlinking files ***
dracut: Mode:                     real
dracut: Method:                   sha256
dracut: Files:                    1668
dracut: Linked:                   4 files
dracut: Compared:                 0 xattrs
dracut: Compared:                 482 files
dracut: Saved:                    6.9 KiB
dracut: Duration:                 0.403861 seconds
dracut: *** Hardlinking files done ***
dracut: *** Generating early-microcode cpio image ***
dracut: *** Constructing AuthenticAMD.bin ***
dracut: *** Constructing GenuineIntel.bin ***
dracut: *** Store current command line parameters ***
dracut: *** Stripping files ***
dracut: *** Stripping files done ***
dracut: *** Creating image file '/usr/src/linux-6.1.55-gentoo-dist/arch/x86/boot/initrd' ***
dracut: Using auto-determined compression method 'gzip'


Happy Gentooing,
De-Javu
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 5240
Location: Bavaria

PostPosted: Sat Oct 14, 2023 10:35 am    Post subject: Reply with quote

De-Javu,

first of all: Thank you very much for your detailed report ! :D

... but ... we need these updates in our Wiki articles ... and you will have three choices:

1. Tell some of our wiki editors in IRC channel #gentoo-wiki about this forums post, or

2. Sign in our Wiki and:

2a) Edit a "talk" page of one of these wiki articles and link to this forums post, or


... BEST option ...


2b) Edit all these wiki articles ... and you will get many thanks of our wiki editors @maffblaster, @ris, @vaukai and others ;-)



(because not everybody is reading in our forum)
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54640
Location: 56N 3W

PostPosted: Sat Oct 14, 2023 10:52 am    Post subject: Reply with quote

De-Javu,

The handbook pages on the Wiki are protected. That stops both malicious edits and well intentioned incorrect material being posted on the first pages most new users use.

Your choices are:-
1. Post on the talk page with something like replace <this section> with <this new text>.
That makes the editors job easy.

2. File a bug doing much the same thing.

3. IRC may work too but its bottom of the list. It's good for interactive clarifications though, so it has its place.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 5240
Location: Bavaria

PostPosted: Sat Oct 14, 2023 11:01 am    Post subject: Reply with quote

NeddySeagoon wrote:
The handbook pages on the Wiki are protected.


Neddy, you are right (as always) ... but ONLY the Handbook pages are protected; NOT all others; like: https://wiki.gentoo.org/wiki/Systemd/systemd-boot

(I have meant, he might edit this Systemd-page)
Back to top
View user's profile Send private message
sam_
Developer
Developer


Joined: 14 Aug 2020
Posts: 2037

PostPosted: Sun Oct 15, 2023 1:14 pm    Post subject: Reply with quote

Thanks for the feedback. Please do what NeddySeagoon suggested, as it's the best way to discuss wiki changes.

That said, I've implemented part of what you've said in https://wiki.gentoo.org/index.php?title=Handbook:Parts/Installation/Kernel/Dist-Kernel&curid=270462&diff=1265596&oldid=1263879. But some of what you said e.g. USE=systemd shouldn't be necessary on systemd profiles, and I'm not sure about the need for USE=initramfs (it's on by default in the ebuilds and it's not strictly necessary, plus if USE=initramfs is on for the dist kernel ebuilds, it pulls in Dracut anyway).

We do still need to add systemd-boot as a proper option where we talk about grub, syslinux, etc.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks 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