summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Bauer2019-11-19 11:40:45 +0100
committerJonathan Bauer2019-11-19 11:40:45 +0100
commitf6ecfba9dc12daad0cd4dfba3cca8fa53a579a5f (patch)
treec18e7c9dcc3c8d54aa0b659204bfe1791d4425d1
parent[slx-dmsetup] back to sparse files (diff)
downloadsystemd-init-f6ecfba9dc12daad0cd4dfba3cca8fa53a579a5f.tar.gz
systemd-init-f6ecfba9dc12daad0cd4dfba3cca8fa53a579a5f.tar.xz
systemd-init-f6ecfba9dc12daad0cd4dfba3cca8fa53a579a5f.zip
try to grow qcow
-rwxr-xr-xbuilder/modules.d/slx-dmsetup/scripts/dmsetup-slx-device12
1 files changed, 10 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 64b12047..7dd1bab3 100755
--- a/builder/modules.d/slx-dmsetup/scripts/dmsetup-slx-device
+++ b/builder/modules.d/slx-dmsetup/scripts/dmsetup-slx-device
@@ -24,8 +24,8 @@ exec &> /run/openslx/dmsetup.log
# read-only device to prepare for CoW
[ -z "$1" ] && emergency_shell "Read-only device was not given!"
-declare -rg read_only_device="$1"
-declare -rg read_only_device_size="$(blockdev --getsz $1)"
+declare -g read_only_device="$1"
+declare -g read_only_device_size="$(blockdev --getsz $1)"
# global array variables storing the configuration of the partitions
declare -ag linear snapshot thin_snapshot thin_volume
@@ -146,6 +146,12 @@ ramdisk_fallback() {
local qcow_size_in_kb="$(( read_only_device_size / 2 ))"
local ram_size_in_kb="$(awk '/MemTotal/ {printf("%d\n", $2 )}' /proc/meminfo)"
+ # fill the qcow2 device with a zero device to make it larger than it is
+ dmsetup_create_noudevsync filler "0 $(( ram_size_in_kb / 2 )) zero"
+ echo "0 $(( read_only_device_size / 2 )) linear $read_only_device 0
+ 0 $(( ram_size_in_kb / 2 )) linear /dev/mapper/filler 0" | dmsetup create bigger --noudevsync
+ dmsetup mknodes --noudevsync bigger
+
# Use the qcow size + half the RAM as tmpfs size.
local cow_size="$(( qcow_size_in_kb + ( ram_size_in_kb / 2 ) ))"
if ! mount -t tmpfs tmpfs -o size="${cow_size}k" "$cow_tmpfs"; then
@@ -157,6 +163,8 @@ ramdisk_fallback() {
emergency_shell "Failed to allocate CoW file $file."
fi
writable_device="$(losetup --show --find "$file")"
+ read_only_device=/dev/mapper/bigger
+ read_only_device_size="$cow_size"
cow_device_candidate="root"
while [ -b "/dev/mapper/$cow_device_candidate" ]; do
cow_device_candidate="root.$RANDOM"