summaryrefslogtreecommitdiffstats
path: root/modules.d/slx-dmsetup/hooks/dmsetup-slx-device
diff options
context:
space:
mode:
Diffstat (limited to 'modules.d/slx-dmsetup/hooks/dmsetup-slx-device')
-rwxr-xr-xmodules.d/slx-dmsetup/hooks/dmsetup-slx-device9
1 files changed, 5 insertions, 4 deletions
diff --git a/modules.d/slx-dmsetup/hooks/dmsetup-slx-device b/modules.d/slx-dmsetup/hooks/dmsetup-slx-device
index 0888e97c..4c41af4b 100755
--- a/modules.d/slx-dmsetup/hooks/dmsetup-slx-device
+++ b/modules.d/slx-dmsetup/hooks/dmsetup-slx-device
@@ -241,15 +241,16 @@ ramdisk_fallback() {
mkdir -p "$cow_tmpfs"
fi
if ! mount -t tmpfs cow-tmpfs -o size="$(( read_only_device_sz / 2 + 100 ))k" "$cow_tmpfs"; then
- echo "$0: Failed to mount tmpfs in '$cow_tmpfs' of size '$(( read_only_device_sz / 2 + 100 ))KiB'."
+ echo "$0: Failed to mount tmpfs in '$cow_tmpfs' of size '$(( read_only_device_sz / 2 + 100 ))KiB', trying to use regular /run tmpfs."
fi
# create sparse file there
- local file="$(mktemp -u -p "$cow_tmpfs" dnbd_cow.XXX)"
- if ! dd if=/dev/null of="$file" seek="$(( read_only_device_sz ))" bs=512 2> /dev/null; then
+ local file="$cow_tmpfs/thinpool.meta"
+ if ! truncate -s "$(( read_only_device_sz * 512 ))" "$file" \
+ && ! dd if=/dev/null of="$file" seek="$read_only_device_sz" bs=512 2> /dev/null; then
emergency_shell "Failed to allocate CoW file $file."
fi
- declare -rg writable_device="$(losetup --show --find "$file")"
+ declare -rg writable_device="$( losetup --show --find "$file" )"
local cow_device_candidate="root"
while [ -b "/dev/mapper/$cow_device_candidate" ]; do
cow_device_candidate="root.$RANDOM"