cam*_*rod 5 fedora encryption btrfs disk-encryption
有许多现有的在线指南已经介绍了如何重新加密磁盘,例如此处maxschhelpzig的响应以及Arch wiki中的文档。然而,Arch wiki 更多地关注使用而不是 的系统,并且现有的 StackExchange 答案假设使用 ext4 文件系统。mkinitcpiodracut
cam*_*rod 10
This assumes a default Fedora installation, with the following Btrfs-based partitions:
/] and "home" [mounted at /home])/boot)/boot/efi)Requirements
dnf install cryptsetup)/etc/vconsole.conf (set with localectl). The layout cannot be changed at boot time.Instructions
lsblk -f. Store the UUID (format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX) for later use.uname -r, and save this value for later.blkid --uuid <UUID>, and run a check on the filesystem with btrfs check <device>mount /dev/<device> /mntbtrfs filesystem resize -32M /mntumount /mntcryptsetup reencrypt --encrypt --reduce-device-size 32M /dev/<device>, providing a passphrase when prompted.lsblk -f (note that the UUID has changed). Save this LUKS partition UUID for later use.cryptsetup open /dev/<device> systemmount /dev/mapper/system /mntbtrfs filesystem resize max /mnt, then unmount the filesystem with umount /mntmount -t btrfs -o "noatime,subvol=root,compress=zstd:1" /dev/mapper/system /mntlsblk. Mount the boot filesystem (mount /dev/<boot device> /mnt/boot), followed by the EFI filesystem for UEFI systems (mount /dev/<EFI device> /mnt/boot/efi)./dev, /dev/pts, /proc, /run, and /sys, in the format of mount --bind /sys /mnt/syschroot /mnt /bin/bash/etc/default/grub with a text editor, and modify the kernel parameters to identify the LUKS partition, and temporarily disable SELinux enforcing. Add these parameters, then save the changes and close the file:GRUB_CMDLINE_LINUX="[other params] rd.luks.uuid=<LUKS partition UUID> enforcing=0"
Run Code Online (Sandbox Code Playgroud)
touch /.autorelabelgrub2-mkconfig -o /boot/grub2/grub.cfg (also generate for /etc/grub2.cfg, and on UEFI systems /etc/grub2-efi.cfg)dracut --kver <kernel version> --force--bind, the option -l can be used.) Close the LUKS partition with cryptsetup close system/etc/default/grub in a text editor, and reenable SELinux enforcing by removing enforcing=0 from GRUB_CMDLINE_LINUX. Save and exit.touch /.autorelabel.这个答案很大程度上源自maxschhelpzig的答案和Arch wiki。它也来自ceremcem的 答案。2023 年 3 月 16 日,更正了错误--reduce-device-size包含空格的拼写错误。