summaryrefslogtreecommitdiffstats
path: root/modules.d/slx-dmsetup/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'modules.d/slx-dmsetup/hooks')
-rwxr-xr-xmodules.d/slx-dmsetup/hooks/dmsetup-slx-device30
1 files changed, 14 insertions, 16 deletions
diff --git a/modules.d/slx-dmsetup/hooks/dmsetup-slx-device b/modules.d/slx-dmsetup/hooks/dmsetup-slx-device
index 8e3b50ca..9da7ea44 100755
--- a/modules.d/slx-dmsetup/hooks/dmsetup-slx-device
+++ b/modules.d/slx-dmsetup/hooks/dmsetup-slx-device
@@ -655,6 +655,7 @@ fi
# start allocating spaces to the configured devices
declare -g writable_device_used_sz=0
+declare -g pool_crypted=
# first, reserve the space for the rootfs cow snapshot (of either type)...
# (this is the first line of our custom partition table)
@@ -690,10 +691,13 @@ else
scratch_device_sz="$(( (scratch_device_sz / 8) * 8 ))"
# encrypt the scratch device, if configured
- if [ -z "$id44_crypted" ] && (( crypt != 0 )) \
- && ! encrypt_device "$writable_device" "${scratch_device##*/}" 0 "$scratch_device_sz"; then
- echo "$0: Continuing with unencrypted scratch"
- crypt=0 # So we do the linear thing below
+ if [ -z "$id44_crypted" ] && (( crypt != 0 )); then
+ if encrypt_device "$writable_device" "${scratch_device##*/}" 0 "$scratch_device_sz"; then
+ pool_crypted=1
+ else
+ echo "$0: Continuing with unencrypted scratch"
+ crypt=0 # So we do the linear thing below
+ fi
fi
if (( crypt == 0 )) && ! dmsetup_create_noudevsync "${scratch_device##*/}" \
"0 $scratch_device_sz linear $writable_device $writable_device_used_sz"; then
@@ -762,7 +766,9 @@ if [ -n "$thin_snapshot" ] || [ -n "$thin_volume" ]; then
for line in "${thin_volume[@]}"; do
[ -z "$line" ] && continue
read -r name crypt min max ignore <<< "$line"
- [ -n "$id44_crypted" ] && crypt=0
+ if [ -n "$id44_crypted" ] || [ -n "$pool_crypted" ]; then
+ crypt=0
+ fi
# thin-volume can be created with max size,
# since they are overprovisioned anyway.
suffix=
@@ -780,9 +786,8 @@ if [ -n "$thin_snapshot" ] || [ -n "$thin_volume" ]; then
if [ -n "$thin_snapshot" ]; then
# create thin-snapshot, use first one
- read -r name crypt min max ignore <<< "$thin_snapshot"
- [ -n "$id44_crypted" ] && crypt=0
- # min/max was used for the pool data device, ignore it here!
+ read -r name _ <<< "$thin_snapshot"
+ # min/max and crypt was used for the pool data device, ignore it here!
# Calculate how much of the CoW space we reserve for changes in the base
# system. Usually all the files in the base system should be static, but
# if someone decided to run apt dist-upgrade, this would change a lot of
@@ -802,17 +807,10 @@ if [ -n "$thin_snapshot" ] || [ -n "$thin_volume" ]; then
if (( root_ntfs_extra > 0 )); then
thin_snapshot_sz="$(( thin_snapshot_sz + root_ntfs_extra ))"
fi
- suffix=
- (( crypt != 0 )) && suffix="-k"
- if ! create_volume "$name$suffix" 1 "$thin_snapshot_sz" "$read_only_device"; then
+ if ! create_volume "$name" 1 "$thin_snapshot_sz" "$read_only_device"; then
echo "Failed to create external snapshot for '$read_only_device'."
ramdisk_fallback
fi
- if (( crypt != 0 )) && ! encrypt_device \
- "/dev/mapper/$name$suffix" "$name" 0 "$thin_snapshot_sz"; then
- echo "Failed to encrypt thin volume '$name', continuing without encryption."
- name="$name$suffix"
- fi
finish_setup "$name" "1" "$thin_snapshot_sz"
fi
echo "$0: Thin volumes defined, but no snapshot. Using tmpfs."