找到以下方法
https://forums.centos.org/viewtopic.php?t=50535
这是唯一靠谱的答案,仍然不行,不过提示信息变了,之前提示
Please enter passphrase for disk STxxxxxx-xxxxxx (luks)! *
后来提示成
Password /dev/sda3
lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
├─sda1 vfat 1D62-EBDE /boot/efi
├─sda2 xfs f0418bd5-5e31-4623-95a1-eb01cb0eed45 /boot
└─sda3 crypto_LUKS 61af80c4-4d0a-4312-aae1-b66abd729eb5
└─luks-61af80c4-4d0a-4312-aae1-b66abd729eb5 LVM2_member tSCNNP-dh40-wP5I-aGsm-Jfrw-aVc2-R0pmBw
├─centos-root xfs 9b6bef41-1545-4cae-8b64-5f7ddd793ed4 /
├─centos-swap swap ef1918bb-90d9-4851-8aa5-3c0fdf96a807 [SWAP]
└─centos-home xfs 88da7564-ccd2-4839-83f9-0250a13e2a7a /home
sdf
└─sdf1 ext4 KEYS 1785c13d-9726-4547-a7cd-1cc2816e6c64
设置流程:
dd if=/dev/urandom of=keyfile bs=512 count=4
cryptsetup -v luksAddKey /dev/sda3 keyfile
mkfs -t ext4 /dev/sdf1
e2label /dev/sdf1 KEYS
mkdir KEYS
mount /dev/sdb1 KEYS
cp keyfile KEYS
chown root KEYS/keyfile
chmod 400 KEYS/keyfile
vi /etc/crypttab
luks-61af80c4-4d0a-4312-aae1-b66abd729eb5 UUID=61af80c4-4d0a-4312-aae1-b66abd729eb5 /keyfile
Modify /etc/default/grub, adding:
rd.luks.key=/keyfile:LABEL=KEYS
To the GRUB_CMDLINE_LINUX variable.
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.luks.uuid=luks-61af80c4-4d0a-4312-aae1-b66abd729eb5 rd.luks.key=/keyfile:LABEL=KEYS rd.lvm.lv=centos/swap rhgb quiet"
Modify /etc/dracut.conf, modifying omit_dracutmodules and add_dracutmodules:
# dracut modules to omit
omit_dracutmodules+="systemd"
# dracut modules to add to the default
add_dracutmodules+="crypt lvm"
Build updated initramfs and grub.cfg:
grub2-mkconfig -o /boot/grub2/grub.cfg
dracut --force
按以上流程设置并无效,其它教程全都不行,还不如这个。
1
Hardrain 2021-06-24 15:33:45 +08:00
参考 https://wiki.archlinux.org/title/Dm-crypt/Encrypting_an_entire_system#Configuring_the_boot_loader_4
至于 /dev/sdX 会变, 可以用 /dev/disk/by-uuid/来解决 |
3
Hardrain 2021-06-25 22:54:39 +08:00
@sbmzhcn Command line 移除
rd.lvm.lv=centos/root rd.luks.uuid=luks-61af80c4-4d0a-4312-aae1-b66abd729eb5 rd.luks.key=/keyfile:LABEL=KEYS rd.lvm.lv=centos/swap 其他不变, 添加如下三个参数 root=UUID=9b6bef41-1545-4cae-8b64-5f7ddd793ed4 cryptdevice=UUID=61af80c4-4d0a-4312-aae1-b66abd729eb5:luks-61af80c4-4d0a-4312-aae1-b66abd729eb5 cryptkey=UUID=1785c13d-9726-4547-a7cd-1cc2816e6c64:auto:/keyfile 试试? |