Title: Booting Gentoo on a BTRFS from multiple LUKS devices | |
Author: Solène | |
Date: 02 January 2023 | |
Tags: linux gentoo btrfs | |
Description: In this article, I share my discoveries in booting Gentoo | |
installed on a BTRFS filesystem using multiple-devices stored on LUKS | |
partitions. | |
# Introduction | |
This is mostly a reminder for myself. I installed Gentoo on a machine, | |
but I reused the same BTRFS filesystem where NixOS is already | |
installed, the trick is the BTRFS filesystem is composed of two | |
partitions (a bit like raid 0) but they are from two different LUKS | |
partitions. | |
It wasn't straightforward to unlock that thing at boot. | |
# Fix grub error | |
Grub was trying to autodetect the root partition to add | |
`root=/dev/something`, but as my root filesystem requires | |
`/dev/mapper/ssd1` and `/dev/mapper/ssd2`, it was simply adding | |
`root=/dev/mapper/ssd1 /dev/mapper/ssd2`, which is wrong. | |
This required a change in the file `/etc/grub.d/10_linux` where I | |
entirely deleted the `root=` parameter. | |
# Compile systemd with cryptsetup | |
A mistake I made was to try to boot without systemd compiled with | |
cryptsetup support, this was just failing because in the initramfs, | |
some systemd services were used to unlock the partitions, but without | |
proper support for cryptsetup it didn't work. | |
# Linux command line parameters | |
In `/etc/default/grub`, I added this line, it contains the UUID of both | |
LUKS partitions needed, and a `root=/dev/dm-0` which is unexpectedly | |
the first unlocked device path, and `rd.luks=1` to enble LUKS support. | |
``` | |
GRUB_CMDLINE_LINUX="rd.luks.uuid=24682f88-9115-4a8d-81fb-a03ec61d870b rd.luks.u… | |
``` | |
# Run Dracut and grub | |
After the changes, I did run `dracut --force --kver | |
5.15.85-gentoo-dist` and `grub-mkconfig -o /boot/grub/grub.cfg` | |
# Conclusion | |
It's working fine now, I thought it would require me to write a custom | |
initrd script, but dracut is providing all I needed, but there were | |
many quirks on the path with no really helpful message to understand | |
what's failing. | |
Now, I can enjoy my dual boot Gentoo / NixOS (they are quite | |
antagonists :D), but they share the same filesystem and I really enjoy | |
this weird setup. |