From 18ea96f370dc2e12c379c3b4f7d88e804ef4e6d6 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 27 Aug 2019 13:10:00 +0200 Subject: [slx-dmsetup] fix small ID44 / large filesystem read the comments for the why :) --- builder/modules.d/slx-dmsetup/scripts/dmsetup-slx-device | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/builder/modules.d/slx-dmsetup/scripts/dmsetup-slx-device b/builder/modules.d/slx-dmsetup/scripts/dmsetup-slx-device index 29796d84..c0f6a274 100755 --- a/builder/modules.d/slx-dmsetup/scripts/dmsetup-slx-device +++ b/builder/modules.d/slx-dmsetup/scripts/dmsetup-slx-device @@ -410,11 +410,22 @@ if [ -n "$thin_snapshot" ] || [ -n "$thin_volume" ]; then # create thin-snapshot, use first one read -r name crypt min max ignore <<< "$thin_snapshot" # min/max was used for the pool data device, ignore it here! - if ! create_volume "$name 1 $writable_device_size $read_only_device"; then + # NOTE: the filesystem will most likely malfunction if the size of the + # thin-snapshot is smaller than what it was upon creation. + # As such, the size of the thin-snapshot can only be $writable_device_size + # if it is larger than $read_only_device_size, otherwise we should only + # use $read_only_device_size. While live-shrinking the filesystem might be + # an option, it is not supported throughout all fileystems (xfs can't). + if (( writable_device_size >= read_only_device_size )); then + thin_snapshot_size="$writable_device_size" + else + thin_snapshot_size="$read_only_device_size" + fi + if ! create_volume "$name 1 $thin_snapshot_size $read_only_device"; then echo "Failed to create external snapshot for '$read_only_device'." ramdisk_fallback fi - finish_setup "$name" "1" "$writable_device_size" + finish_setup "$name" "1" "$thin_snapshot_size" fi fi -- cgit v1.2.3-55-g7522