Hi all,
I’m in the process of setting up current Fedora with LUKS2 encrypted boot and root partition on my Framework 13 AMD.
But I always end up with the problem when entering the second passphrase (for the root partition) it doesn’t accept the (correct) passphrase anymore and I’m stuck on the GRUB emergency console (GRUB version 2.06).
Though, after the initial setup of the encrypted root partition (“/” and “/home”) with the official Anaconda installer everything works fine. But when I apply this unofficial guide to also encrypt the boot partition (see below) it doesn’t accept the passphrase of the root partition anymore.
Maybe one of you is familiar with GRUB and LUKS encryption and knows how to do this correctly. Your help would be really appreciated. If we get this working we would also have a working guide for everyone.
Here’s my approach based on the guide for Fedora 37 with FDE by Sysguides:
Initial installation of Fedora
First install Fedora as usual via live image on USB stick, enable drive encryption, so that root partition is LUKS2 encrypted.
The initial partition layout looks like this:
lsblk -pf
├─/dev/nvme0n1p1
│ vfat FAT32 D532-C407 581,4M 3% /boot/efi
├─/dev/nvme0n1p2
│ ext4 1.0 e029e25d-d9ae-4251-8942-bd1c8369f027 702,7M 21% /boot
└─/dev/nvme0n1p3
crypto 2 ddc0ea5f-c32a-4845-90b0-bfc96efb5e56
└─/dev/mapper/luks-ddc0ea5f-c32a-4845-90b0-bfc96efb5e56
btrfs fedora ccdc409e-b2b3-4264-a0aa-228849f64e9b 932G 0% /home
/
Now, when initial setup is done proceed to manually encrypting the boot partition.
Encrypt /boot partition with LUKS2
Unmount /boot partition
sudo umount -vR /boot
Examine the ext4 file system for any issues
sudo e2fsck -f /dev/nvme0n1p2
Shrink the ext4 file system to make some room for the LUKS header
The minimum size recommended by cryptsetup is twice the default LUKS2 header size, i.e. 32 MiB.
As the /dev/nvme0n1p2 partition is set to 1 GiB, I’m going to reduce the ext4 file system to 992 MiB (1024-32).
sudo resize2fs -p /dev/nvme0n1p2 992M
Encrypt the shrinked boot partition with LUKS
GRUB currently only supports LUKS with the pbkdf2 algorithm.
For pbkdf2, the minimum iteration count is 1000 and the maximum is 4294967295.
The lower the iterations, the faster the GRUB boots, but it also reduces the security.
I chose a different passphrase here. So there is one passphrase for the boot partition and one for the root partition.
sudo cryptsetup reencrypt \
--encrypt \
--verbose \
--type luks2 \
--pbkdf pbkdf2 \
--pbkdf-force-iterations 500000 \
--reduce-device-size 32m \
/dev/nvme0n1p2
Open encrypted boot partition
BOOTUUID="$(sudo cryptsetup luksUUID /dev/nvme0n1p2)"
sudo cryptsetup open /dev/nvme0n1p2 luks-"${BOOTUUID}"
Mount all back
sudo mount -va
Restore the SELinux labels to the /boot directory
sudo restorecon -RFv /boot
Create a permanent entry into the /etc/crypttab file for the newly created encrypted block device
echo "luks-${BOOTUUID} UUID=${BOOTUUID} none discard" \
| sudo tee -a /etc/crypttab
sudo cat /etc/crypttab
Enable the CRYPTODISK option in GRUB
When enabled, it will check the encrypted disks and generate the additional commands needed to access them during boot.
echo 'GRUB_ENABLE_CRYPTODISK=y' | sudo tee -a /etc/default/grub
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Set up access to the encrypted boot device by adding the cryptomount command
sudo sed -i "1i cryptomount -u ${BOOTUUID//-/}" /boot/efi/EFI/fedora/grub.cfg
Final partition layout now looks like this:
lsblk -pf
/dev/nvme0n1
├─/dev/nvme0n1p1
│ vfat FAT32 D532-C407
├─/dev/nvme0n1p2
│ crypto 2 e029e25d-d9ae-4251-8942-bd1c8369f027
└─/dev/nvme0n1p3
crypto 2 ddc0ea5f-c32a-4845-90b0-bfc96efb5e56
└─/dev/mapper/luks-ddc0ea5f-c32a-4845-90b0-bfc96efb5e56
btrfs fedora ccdc409e-b2b3-4264-a0aa-228849f64e9b 932G 0% /home
/
Reboot the computer now to ensure that everything is working correctly.
sudo reboot
When booting, you will be prompted for the passphrase twice.
The first time is before loading GRUB, and the second time is before mounting the root file system.
When you input your passphrase in the first LUKS prompt, no cursor indication appears, just enter the passphrase blindly.
Additional notes
- I’m aware that my approach is based on a guide for Fedora 37 but the available guides for Fedora 38/39 and 40 from Sysguides are not utilizing the Ananconda installer anymore. Instead all partitioning is done manually via command line, boot is located on the root partition and the whole root partition is only encrypted with LUKS2 pbkdf2, which is weaker than only encrypting boot as a separate partition with pbkdf2 and leave the root partition encrypted with stronger LUKS2 argon2id which is the case when using Ananconda installer.