diff --git a/installer/preinstall.d/08-crypttab.sh b/installer/preinstall.d/08-crypttab.sh index 31fd1e6..920d3b4 100755 --- a/installer/preinstall.d/08-crypttab.sh +++ b/installer/preinstall.d/08-crypttab.sh @@ -4,20 +4,19 @@ [ -f /tmp/fstab ] || exit 0 -for device in $(find /dev/ -name 'dm-*' -type b); +for device in $(findmnt -neo SOURCE -F /tmp/fstab); do - uuid=$(blkid -o value -s UUID "$device") - fgrep "$uuid" "/tmp/fstab" &> /dev/null || continue + # filter out non-luks devices + MAJMIN="$(findmnt $device -rno MAJ:MIN)" + device_luks="/dev/"$(ls -1 "/sys/dev/block/$MAJMIN/slaves/") + [ "$(blkid -o value -s TYPE "$device_luks")" = "crypto_LUKS" ] || continue + # we should add luks feature to initrd if / is placed on luks # or create /etc/crypttab otherwise - if grep -qe ".*$uuid.*[^[:alnum:]]/[^[:alnum:]]" "/tmp/fstab"; then + if [ "$(findmnt $device -no TARGET -F /tmp/fstab)" = "/" ]; then echo 'FEATURES += luks' >> $destdir/etc/initrd.mk - exit 0 fi - device_luks="/dev/"$(ls "/sys/block/$(basename "$device")/slaves/") - [ "$(blkid -o value -s TYPE "$device_luks")" = "crypto_LUKS" ] || continue - luks_uuid=$(blkid -o value -s UUID "$device_luks") [ -r "$destdir/etc/crypttab" ] && fgrep "$luks_uuid" "$destdir/etc/crypttab" &> /dev/null && continue