3 # $1=$device [$2=keyfile|none [$3=size]]
6 [ -d /sys/module/dm_crypt ] || modprobe dm_crypt
8 [ -f /tmp/reencrypted ] && exit 0
12 # if device name is /dev/dm-X, convert to /dev/mapper/name
13 if [ "${1##/dev/dm-}" != "$1" ]; then
14 device="/dev/mapper/$(dmsetup info -c --noheadings -o name "$1")"
19 PARAMS="$device -T 1 --use-fsync -B 32"
21 PARAMS="$PARAMS --device-size $3"
25 local keypath="${1#*:}"
26 local keydev="${1%%:*}"
28 local mntp="/tmp/reencrypted-mount-tmp"
30 mount -r "$keydev" "$mntp" && cat "$mntp/$keypath"
38 if [ "$1" = "none" ] ; then
39 /bin/plymouth ask-for-password \
40 --prompt "LUKS password for REENCRYPTING $device" \
41 --command="/sbin/cryptsetup-reencrypt $PARAMS"
43 info "REENCRYPT using key $1"
44 reenc_readkey "$1" | /sbin/cryptsetup-reencrypt -d - $PARAMS
49 info "REENCRYPT $device requested"
50 # flock against other interactive activities