ืืื ืืืืื ืืื ืืืืื! ืคืืกื ืื ืืืื ืฉืืืืฉื ืขืืืจ ืืื ืืืฉืชืืฉืื ืืืฆืคื ืช ื ืชืื ืื LUKS ืืจืืฆืื ืืคืขื ื ืืืกืงืื ืชืืช ืืื ืืงืก (Debian, Ubuntu) ื- ืฉืืื ืคืขื ืื ืืืืฆืช ืืฉืืจืฉ. ืืื ืืฆืืืชื ืืืฆืื ืืืืข ืืื ืืืื ืืจื ื.
ืืืืจืื ื, ืขื ืืืืืื ืืืกืคืจ ืืืืกืงืื ืืืืคืื, ื ืชืงืืชื ืืืขืื ืฉื ืคืขื ืื ืืืกืงืื ืืฉืืื ืืืืชืจ ืืืืจืช ืืจื /etc/crypttab. ืืืืคื ืืืฉื, ืื ื ืืืืืฉ ืืื ืืขืืืช ืืฉืืืืฉ ืืฉืืื ืื, ืืืืืจ ืฉืืงืืืฅ ื ืงืจื ืจืง ืืืืจ ืืขืื ืช (ืืจ) ืืช ืืืืฆืช ืืฉืืจืฉ, ืื ืฉืืฉืคืืข ืืจืขื ืขื ืืืืื โโZFS, ืืืืืื ืื ืื ื ืื ื ืืืืืฆืืช ืืืืฉืืจ *_crypt, ืื ืคืฉืืืืช mdadm ืฉื ืื ื ืื ืืืืืฆืืช. ืืืื ื ืืืืขืื ืฉืืชื ืืืื ืืืฉืชืืฉ ืืืืืงื ืขื ืืืืื LUKS, ื ืืื? ืืื ืืืขืื ืฉื ืืชืืื ืืืงืืืช ืฉื ืฉืืจืืชืื ืืืจืื, ืืฉืืื ืขืืืื ืืขืจืืื, ืืื ืฉืืืืฉ ืื ื ืืืจ ืฆืจืื ืืฉืื (ืื ื ืขืืื ืขื clustered Proxmox VE 5.x ื-ZFS ืืขื iSCSI).
ืงืฆืช ืขื ZFSoverISCSIiSCSI ืขืืื ืืฉืืืื ืืจื LIO, ืืืืขืฉื, ืืืฉืจ ืืขื ื-iscsi ืืชืืื ืืื ืจืืื ืืชืงื ื ZVOL, ืืื ืคืฉืื ืืกืืจ ืืืชื ืืืงืื ืคืืืืจืฆืื, ืื ืฉืืื ืข ืืืขืจืืืช ืืืจืืืช ืืืชืื. ืืคืืื, ืื ืฉืืืืจ ืืืืื ืฉื ืงืืืฅ json, ืื ืืืกืคืช ืืืฉืืจืื ืขื ืืืืื ืืื ืืช ืขืืืจ ืื VM, ืืื ืคืฉืื ื ืืจื ืืืฉืจ ืืฉ ืขืฉืจืืช ืืืื ืืช ืืืื ืืืื ืชืฆืืจื ืืฉ ืืืชืจ ืืืืกืง ืืื.
ืืืฉืืื ืืฉื ืืื ืฉืืฉืงืื ืืื ืืืฆื ืืคืขื ื (ืื ื ืงืืืช ืืืคืชื ืฉื ืืืืืจ). ืืขื ืื ื ืืืจ ืืืื, ืืื ืืชืืช ืืกืฃ!
ืืจืื, ืืืื ืืจื ื, ื ืขืฉื ืฉืืืืฉ ืืงืืืฅ ืืคืชื (ืืืกืคื ืขืฆืืืช ืืืจืืฅ ืืคื ื ืื ืขื ืืื ืืคืงืืื - cryptsetup luksAddKey), ืื ืืืจืืืื ื ืืืจืื (ืืืื ืืจื ื ืืฉืคื ืืจืืกืืช ืืฉ ืืขื ืืืื ืืืืข) - ืืกืงืจืืคื decrypt_derived ืืืืงื ื-/lib/cryptsetup/script/ (ืืืืื, ืืฉ ืืจืืื ืืืจืืช, ืืื ืืฉืชืืฉืชื ืืฉืชื ืืื, ืฉืืืื ืืช ืืืกืืก ืืืืืจ). ืืฉืชืืืชื ืื ืืืืืื ืืืืื ืืืืช ืืืื ืืืืจ ืืชืืืืื, ืืื ืคืงืืืืช ื ืืกืคืืช ืืงืื ืกืืื, ืื ืฉืืื "ืืขืฃ" ืื ืืืช ืืืช. ืืื, ืืื ืืืืืช? โ
ืืื ื ืชืืื!
ื ื ืื ืฉืืขืจืืช, ืืื ืืืืื, ืืืชืงื ืช ืขื ืืืืฆืช ืงืจืืคืื sda3_crypt ืืชืจืืกืจ ืืืกืงืื ืืืื ืื ืืืฆืคื ื ืืืืฆืืจ ืืืืืช ื ืคืฉื. ืืฉ ืื ื ืืืืื ืกืืกืื (ืกืืกืื) ืืคืชืืืช ืื ืขืืื ืฉื sda3_crypt, ืืืืืืฆื ืื ื ืกืืจ ืืช ื-"hash" ืืืกืืกืื ืืืขืจืืช ืืคืืขืืช (ืืคืืขื ืืช) ืื ืืกืืฃ ืืืชื ืืฉืืจ ืืืืกืงืื. ืืื ืืืื ืืจื, ืืงืื ืกืืื ืื ื ืืืฆืขืื:
/lib/cryptsetup/scripts/decrypt_derived sda3_crypt | cryptsetup luksFormat /dev/sdX
ืืืฉืจ X ืืื ืืืืกืงืื, ืืืืืฆืืช ืืื' ืฉืื ื.
ืืืืจ ืืฆืคื ืช ืืืืกืงืื ื"hash" ืืืืืื ืืกืืกืื ืฉืื ื, ืฆืจืื ืืืจืจ ืืช ื-UUID ืื ืืืืื - ืชืืื ืื ืจืืื ืืื ืืืื. ืื ื ืืืงืืื ื ืชืื ืื ื-/dev/disk/by-uuid ื-by-id ืืืชืืื.
ืืฉืื ืืื ืืื ืืื ืช ืงืืฆืื ืืืื ื ืกืงืจืืคืืื ืขืืืจ ืืคืื ืงืฆืืืช ืฉืื ื ืฆืจืืืื, ืืืื ื ืืฉืื:
cp -p /usr/share/initramfs-tools/hooks/cryptroot /etc/initramfs-tools/hooks/
cp -p /usr/share/initramfs-tools/scripts/local-top/cryptroot /etc/initramfs-tools/scripts/local-top/
ืขืื
touch /etc/initramfs-tools/hooks/decrypt && chmod +x /etc/initramfs-tools/hooks/decrypt
ืืชืืื ืฉื ../decrypt
#!/bin/sh
cp -p /lib/cryptsetup/scripts/decrypt_derived "$DESTDIR/bin/decrypt_derived"
ืขืื
touch /etc/initramfs-tools/hooks/partcopy && chmod +x /etc/initramfs-tools/hooks/partcopy
ืืชืืื ืฉื ../partcopy
#!/bin/sh
cp -p /sbin/partprobe "$DESTDIR/bin/partprobe"
cp -p /lib/x86_64-linux-gnu/libparted.so.2 "$DESTDIR/lib/x86_64-linux-gnu/libparted.so.2"
cp -p /lib/x86_64-linux-gnu/libreadline.so.7 "$DESTDIR/lib/x86_64-linux-gnu/libreadline.so.7"
ืขืื ืืื
touch /etc/initramfs-tools/scripts/local-bottom/partprobe && chmod +x /etc/initramfs-tools/scripts/local-bottom/partprobe
ืชืืื ../partprobe
#!/bin/sh
$DESTDIR/bin/partprobe
ืืืืกืืฃ, ืืคื ื update-initramfs, ืขืืื ืืขืจืื ืืช ืงืืืฅ /etc/initramfs-tools/scripts/local-top/cryptroot, ืืื ืืฉืืจื ~360, ืงืืข ืงืื ืืืื
ืืงืืจื
# decrease $count by 1, apparently last try was successful.
count=$(( $count - 1 ))
message "cryptsetup ($crypttarget): set up successfully"
break
ืืืืืื ืืืชื ืืืืคืก ืืื
ืขึธืจืึผื
# decrease $count by 1, apparently last try was successful.
count=$(( $count - 1 ))
/bin/decrypt_derived $crypttarget | cryptsetup luksOpen /dev/disk/by-uuid/ *CRYPT_MAP*
/bin/decrypt_derived $crypttarget | cryptsetup luksOpen /dev/disk/by-id/ *CRYPT_MAP*
message "cryptsetup ($crypttarget): set up successfully"
break
ืฉืืื ืื ืฉื ืืชื ืืืฉืชืืฉ ื-UUID ืื ID ืืื. ืืขืืงืจ ืืื ืฉืื ืืื ืืืชืงื ืืืจืืฉืื ืขืืืจ ืืชืงื ื HDD / SSD ืืชืืืกืคืื ื-/etc/initramfs-tools/modules. ืืชื ืืืื ืืืืืช ืืืืื ืื ืื ืืชืงื ื ืขืฉื ืฉืืืืฉ ืขื ืืคืงืืื udevadm info -a -n /dev/sdX | egrep 'ืืกืชืื|ืืจืืืจ'.
ืขืืฉืื ืืฉืกืืืื ื ืืื ืืงืืฆืื ืืืงืื, ืืคืขื update-initramfs -u -k all -v, ืืจืืฉืื ืืืื ืื ืืืืืช ืฉืืืืืช ืืืฆืืข ืฉื ืืกืงืจืืคืืื ืฉืื ื. ืื ื ืืืชืืืื, ืืื ืืกืื ืืช ืืฉืคื ืืกืืกืื ืืืืชืื ืื ืืขื, ืืืชืื ืืืกืคืจ ืืืืกืงืื. ืืืืจ ืืื, ืืืขืจืืช ืชืชืืื ืืืฉืื ืืกืืคื ืฉื ืืืฉืงื, ืืืืืจ ืืืืจ "ืืจืืื" ืฉื ืืืืฆืช ืืฉืืจืฉ, ืชืืืฆืข ืืคืงืืื partprobe - ืืื ืชืืฆื ืืชืงืื ืืช ืื ืืืืืฆืืช ืฉื ืืฆืจื ืืืืฉืืจื LUKS ืืื ืืขืจืืื, ืืื ืื ืื ZFS ืื mdadm, ืืืจืื ืืื ืืขืืืช! ืืื ืื ืืคื ื ืืืขืื ื ืฉืืจืืชื ืืืื ืืฉืืจืืชืื ืืืงืืงืื ืืืืกืงืื/ืืขืจืืื ืืื.
ืขืืืื 1: ืืื
ืืงืืจ: www.habr.com