In-place LUKS2 encryption of an installed Fedora Asahi Remix root, done by hand,
then AsahiLocker's boot guards on top. This is what luks-deploy.sh automates.
- Run it from a live USB, never from the system being encrypted.
- Have a verified backup. Every block of the root partition is rewritten.
- Plug in the charger.
- Partition numbers below are examples. Check yours with
lsblk -ffirst.
Commands
Encrypt (as root, on the live USB):
ROOT=/dev/nvme0n1p6 BOOT=/dev/nvme0n1p5 EFI=/dev/nvme0n1p4 # your btrfs root, ext4 /boot, vfat EFI
btrfs check --readonly $ROOT # stop here if it finds errors
mount $ROOT /mnt && btrfs filesystem resize -32M /mnt && umount /mnt # room for the LUKS2 header
cryptsetup reencrypt --encrypt --type luks2 --cipher aes-xts-plain64 --key-size 512 --hash sha512 \
--pbkdf argon2id --pbkdf-memory 4194304 --pbkdf-force-iterations 10 --sector-size 4096 --reduce-device-size 32M $ROOT
cryptsetup open $ROOT fedora_crypt # the passphrase you just set
LUKS=$(blkid -s UUID -o value $ROOT); BTRFS=$(blkid -s UUID -o value /dev/mapper/fedora_crypt)
mount -o subvol=root /dev/mapper/fedora_crypt /mnt && btrfs filesystem resize max /mnt
mount -o subvol=home /dev/mapper/fedora_crypt /mnt/home && mount $BOOT /mnt/boot && mount $EFI /mnt/boot/efi
for d in dev dev/pts proc sys run; do mount --bind /$d /mnt/$d; done # not --rbind: it won't unmountConfigure the encrypted system to boot:
echo "fedora_crypt UUID=$LUKS none luks,discard" >> /mnt/etc/crypttab
sed -i "s|UUID=$BTRFS|/dev/mapper/fedora_crypt|" /mnt/etc/fstab
sed -i "1s|\$| rd.luks.uuid=$LUKS rd.luks.name=$LUKS=fedora_crypt|" /mnt/etc/kernel/cmdline
sed -i "s|^GRUB_CMDLINE_LINUX_DEFAULT=\"|&rd.luks.uuid=$LUKS rd.luks.name=$LUKS=fedora_crypt |" /mnt/etc/default/grub
chroot /mnt grubby --update-kernel=ALL --args="rd.luks.uuid=$LUKS rd.luks.name=$LUKS=fedora_crypt"
echo 'add_dracutmodules+=" crypt dm "' > /mnt/etc/dracut.conf.d/99-luks.conf
chroot /mnt dracut --regenerate-all --force # every initramfs, now able to unlock
chroot /mnt grub2-mkconfig -o /boot/grub2/grub.cfg # /boot/grub2, NEVER /boot/efi/...
touch /mnt/.autorelabel # SELinux relabels at first boot
cryptsetup luksHeaderBackup $ROOT --header-backup-file /root/luks-header.img # copy it off the Mac
umount -R /mnt && cryptsetup close fedora_crypt && rebootAdd the boot guards (on the encrypted system, after the first boot):
git clone https://github.com/doug445/AsahiLocker.git
sudo ./AsahiLocker/boot-guards/install.sh # stub guard + stale EFI entry cleaner
systemctl status esp-grub-stub-guard.path # "active (waiting)"
sudo ./AsahiLocker/extras/boot-tripwire/install.sh # optional: report /boot changed while offConclusion
The root and /home are now LUKS2 with argon2id at 4 GiB x 10, the strongest
cryptsetup allows; you type the passphrase at every boot. /boot and the EFI
partition stay unencrypted, as on every standard LUKS install, and the boot
guards undo a stray grub2-mkconfig over the EFI partition's GRUB stub within
milliseconds.
-
Interrupted? Boot the live USB again:
cryptsetup reencrypt --resume-only $ROOT(aftercryptsetup repair $ROOTif it asks), then redo the configure step. - Won't boot? Every change above is undone from the live USB; see RECOVERY.md.
-
What doing it by hand skips: the 12-point check before reboot, the
partition cross-checks, a recovery key, the swap check, and resuming on its
own.
luks-deploy.shdoes all of this, in one command: INSTALL.md.
← Back to the full guide: encrypt Fedora Asahi Remix with LUKS2, in place