You are not logged in.

#1 2024-04-26 13:45:03

availmon
Member
Registered: 2024-04-26
Posts: 8

[SOLVED] Setting up autom systemd-boot and dracut for LVM/LUKS install

Hello!

I am currently trying to switch from endeavourOS (used it two years) to my own arch linux install and I am currently encountering some problems with setting up the bootloader and generating initramfs/initrd's.
I have decided for the following configuration, but I am open to change it when another route is easier:
- systemd-boot as the bootloader
- dracut as the initramfs infrastructure (I would be fine with mkinitcpio, too, I just thought it might be better for a lvm/luks install)
- default "linux" kernel as my kernel
- encryped LUKS partition with a LVM environment inside (two logical volumes, one for the root partition, one for the /home partition)

From my time with endeavourOS, I am used to automated entries in systemd-boot, where hooks detect a new kernel and they rebuild the initramfs with dracut and update the systemd-boot boot entries.

Following the Installation guide and the information provided on https://wiki.archlinux.org/title/Dm-cry … VM_on_LUKS, they ask me to figure out the uuid of the root partition by myself (which is not that hard, but copying it to the boot entry is). But I still don't know if I have to update my entries for every kernel update myself (are there pacman hooks for that?).

Using the "kernel-install" script and using

# kernel-install add-all

I was able to get a semi-working boot entry (it generated a initrd and initramfs and added it to the entry), but it ends up searching for a root partion forever (stuck on "A start job is running for /dev/gpt-auto-root")
So I think it just doesn't know that it should be decrypting the LUKS partition and open the lvm.

So, my questions are:
How can you configure dracut/my systemd boot entry to look for the LUKS partition, decrypt it and open the LVM volumes?
Are there hooks that automate A. the generation of initrd/initramfs for dracut and B. Add all installed kernels as entries in the boot menu?

or should I just install mkinitcpio and follow the guide on the dm-crypt wiki page and make a manual entry? (-> how would I automate this for new kernels?)

SOLUTION:
I just didn't configure kernel-install correctly. In order for this setup to work, you have to add the following kernel parameters to /etc/kernel/cmdline (kernel-install copies the parameters there to the options-section of a boot entry):

rd.luks.uuid=<UUID of LUKS Device> root=/dev/<Volume Group Name>/<logical root volume name>

This is because dracut uses systemd early-userspace by default. Any additional kernel parameters for a LVM/LUKS install are not neccessary with dracut. You also don't need to set any hooks similar to mkinitcpio, since dracut adds them automatically looking at the kernel parameters.

Last edited by availmon (2024-04-27 09:51:20)

Offline

#2 2024-04-26 18:05:05

bschnei
Member
Registered: 2024-03-05
Posts: 15

Re: [SOLVED] Setting up autom systemd-boot and dracut for LVM/LUKS install

Yes, there are packaged hooks for kernel-install. See: https://wiki.archlinux.org/title/Kernel … omatically

That start job is this service trying to work: https://wiki.archlinux.org/title/System … tomounting

You'll note it has several conditions that have to be satisfied in order for it to work correctly. If those won't work for you or you just don't want to use the GPT automount feature, then you have to use the command line parameters as noted here https://wiki.archlinux.org/title/Dm-cry … t_loader_2

If you do want to use the GPT automount service, pay particular attention to the requirement of setting the correct partition type. https://wiki.archlinux.org/title/GPT_fd … ition_type I missed that the first time around and hit the same issue you have. I can't find where I read it, but you'll want to use the Linux root type and *not* the LUKS type or dm-crypt type.

Edit: it's not immediately clear to me that you can use GPT automounting with LVM on LUKS. You may want to start with the command line parameters unless someone else chimes in here confirming it can work or you can find documentation.

Last edited by bschnei (2024-04-26 18:14:33)

Offline

#3 2024-04-26 18:16:12

availmon
Member
Registered: 2024-04-26
Posts: 8

Re: [SOLVED] Setting up autom systemd-boot and dracut for LVM/LUKS install

bschnei wrote:

That start job is this service trying to work: https://wiki.archlinux.org/title/System … tomounting

You'll note it has several conditions that have to be satisfied in order for it to work correctly. If those won't work for you or you just don't want to use the GPT automount feature, then you have to use the command line parameters as noted here https://wiki.archlinux.org/title/Dm-cry … t_loader_2

on the command line parameters: I'm not sure if they are right, the mentioned parameters for a dracut intird seem very convoluted and I don't remember my eOS boot entries to be that complicated (even with device encryption + lvm)

bschnei wrote:

If you do want to use the GPT automount service, pay particular attention to the requirement of setting the correct partition type. https://wiki.archlinux.org/title/GPT_fd … ition_type I missed that the first time around and hit the same issue you have. I can't find where I read it, but you'll want to use the Linux root type and *not* the LUKS type or dm-crypt type.

Interesting, I specifically set the partition type of my lvm environment to Linux LVM (type 44 in fdisk)

I will let you know how it turned out!

Offline

#4 2024-04-26 18:21:25

bschnei
Member
Registered: 2024-03-05
Posts: 15

Re: [SOLVED] Setting up autom systemd-boot and dracut for LVM/LUKS install

Sorry I'm not familiar with dracut. Are you using a systemd-based initramfs or busybox? The kernel parameters will vary depending on which one you use. I also got that one wrong when I was screwing around.

Offline

#5 2024-04-26 18:29:41

availmon
Member
Registered: 2024-04-26
Posts: 8

Re: [SOLVED] Setting up autom systemd-boot and dracut for LVM/LUKS install

Wow, @bschnei now (I've set the partition type to fdisk 23 (Linux root (x86_64))) it actually detects the root partition, it even decrypts it, but it fails in the sysroot.mount service: mount: /sysroot: unkown filesystem type 'LVM2_member'

Going to recheck my kernel parameters and boot entry (I tested a few things out).

By the way, during initrd generation (with kernel-install add-all), it kept thinking I was using a different kernel because it somehow got the information of the kernel from the archiso and I think it added some trash because of that under the options portion in the boot entry:
is archisobasedir=arch archisodevice=UUID=(blahblah) normal?

Offline

#6 2024-04-26 18:30:59

availmon
Member
Registered: 2024-04-26
Posts: 8

Re: [SOLVED] Setting up autom systemd-boot and dracut for LVM/LUKS install

I think my last reply answers the question wink I am using systemd (it's dracuts default)

Offline

#7 2024-04-26 18:32:50

bschnei
Member
Registered: 2024-03-05
Posts: 15

Re: [SOLVED] Setting up autom systemd-boot and dracut for LVM/LUKS install

Duh. I'm an idiot. You are obviously using systemd-based initramfs. See my ninja edit from before: I'm not actually sure if you can use GPT automount feature with LVM on LUKS. The wiki isn't clear on that and I haven't gone digging through the docs in detail.

I made exactly the same mess you did when I tried to recover from a bad initramfs once. You definitely want to set your command line parameters in /etc/dracut.conf.d/cmdline.conf because if you don't, the default behavior is to use the command line parameters from the currently loaded kernel!

https://wiki.archlinux.org/title/Dracut … ne_options

Last edited by bschnei (2024-04-26 18:34:21)

Offline

#8 2024-04-26 18:36:46

availmon
Member
Registered: 2024-04-26
Posts: 8

Re: [SOLVED] Setting up autom systemd-boot and dracut for LVM/LUKS install

Lol, I just threw out everything in the options on the boot entry and it still works (up until the sysroot thing). Going to regenerate the initramfs again now. But by the way, kernel-install's "documentation" is kinda misleading. The options are sort-of fine but at no point in time it tells you that it basically assumes you run it on the kernel you are currently on

Offline

#9 2024-04-26 18:42:22

bschnei
Member
Registered: 2024-03-05
Posts: 15

Re: [SOLVED] Setting up autom systemd-boot and dracut for LVM/LUKS install

Oh right, you are using kernel-install which then calls dracut. I think you'll need to set the parameters here then: /etc/kernel/cmdline per https://wiki.archlinux.org/title/Kernel … mmand_line. I can't remember where I read that it uses the current running kernel's parameters...I thought I had, but maybe I just figured it out from trial and error...

Offline

#10 2024-04-26 18:44:51

bschnei
Member
Registered: 2024-03-05
Posts: 15

Re: [SOLVED] Setting up autom systemd-boot and dracut for LVM/LUKS install

Ha. It's in the docs, it's just not intuitive. See the FILES section here: https://man.archlinux.org/man/kernel-install.8

/etc/kernel/cmdline, /usr/lib/kernel/cmdline, /proc/cmdline
Specifies the kernel command line to use. The first of the files that is found will be used. $KERNEL_INSTALL_CONF_ROOT may be used to override the search path; see below for details.

/proc/cmdline is the current running kernel's command line...if the other files don't exist..that's the fallback...

Offline

#11 2024-04-26 18:46:15

availmon
Member
Registered: 2024-04-26
Posts: 8

Re: [SOLVED] Setting up autom systemd-boot and dracut for LVM/LUKS install

bschnei wrote:

Oh right, you are using kernel-install which then calls dracut. I think you'll need to set the parameters here then: /etc/kernel/cmdline per https://wiki.archlinux.org/title/Kernel … mmand_line. I can't remember where I read that it uses the current running kernel's parameters...I thought I had, but maybe I just figured it out from trial and error...

Yeah yeah I know (I am reading these docs/wikis for hours, the one on LVM, dm_crypt, kernel parameters, dracut, systemd-boot, everything sad(). The problem is, that dracut supposedly figures everything out itself (encrypted root partitions and Logical volumes) but something is going wrong. I'm currently in the emergency shell of systemd on the installation. Decryption works fine, but I think it doesn't know what lv's are.

Last edited by availmon (2024-04-26 18:48:57)

Offline

#12 2024-04-26 18:54:39

bschnei
Member
Registered: 2024-03-05
Posts: 15

Re: [SOLVED] Setting up autom systemd-boot and dracut for LVM/LUKS install

Gotcha. Not familiar with dracut or LVM unfortunately. I'm guessing you already found this tip buried at the bottom too: https://wiki.archlinux.org/title/Dracut … AID_/_LUKS.

Offline

#13 2024-04-26 19:59:52

availmon
Member
Registered: 2024-04-26
Posts: 8

Re: [SOLVED] Setting up autom systemd-boot and dracut for LVM/LUKS install

Finally, it worked! I am going to edit the wiki next, because the dracut section on dm-crypt#Encrypting_an_entire_system is not accurate you only need:

rd.luks.uuid=<UUID of LUKS Device> root=/dev/<Volume Group Name>/<logical root volume name>

. I think there is no way of using gpt automount because then it thinks this partition really is directly the root partition, not a physical volume for the LVM. Thanks for the help bschnei!

Last edited by availmon (2024-04-26 20:08:02)

Offline

#14 2024-04-26 20:37:20

bschnei
Member
Registered: 2024-03-05
Posts: 15

Re: [SOLVED] Setting up autom systemd-boot and dracut for LVM/LUKS install

No problem. Happy you got it worked out!

Offline

Board footer

Powered by FluxBB