summaryrefslogtreecommitdiffstats
path: root/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh
diff options
context:
space:
mode:
authorjandob2016-01-21 15:29:05 +0100
committerjandob2016-01-21 15:29:05 +0100
commitad9d66426c3a00c81da5ab76ba6269948d6609d0 (patch)
treec22fe002d7f590fe957f6d3f12096733a8df0d90 /builder/dnbd3-rootfs/hooks/prepare-root-partition.sh
parentdebugging (diff)
downloadsystemd-init-ad9d66426c3a00c81da5ab76ba6269948d6609d0.tar.gz
systemd-init-ad9d66426c3a00c81da5ab76ba6269948d6609d0.tar.xz
systemd-init-ad9d66426c3a00c81da5ab76ba6269948d6609d0.zip
add xmount; refactor
Diffstat (limited to 'builder/dnbd3-rootfs/hooks/prepare-root-partition.sh')
-rwxr-xr-xbuilder/dnbd3-rootfs/hooks/prepare-root-partition.sh47
1 files changed, 8 insertions, 39 deletions
diff --git a/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh b/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh
index e5881ca0..3af24960 100755
--- a/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh
+++ b/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh
@@ -37,33 +37,10 @@ if [[ $return_code != 0 ]]; then
fi
# endregion
-# region detect read-only partition
-read_only_device="$SLX_DNBD3_DEVICE"
-if ! qemu-img info --output json "$read_only_device" | grep '"format": "raw"'
+read_only_device=""
+if ! qemu-img info --output json "$SLX_DNBD3_DEVICE" | grep '"format": "raw"'
then
- read_only_device='/dev/nbd0'
- systemd-preserve-process-marker qemu-nbd --connect="$read_only_device" \
- "$SLX_DNBD3_DEVICE" --read-only --persistent --nocache
-
- # XXX better way to wait for the device to be made?
- i=0
- while [ ! -b "$read_only_device" ]; do
- [ $i -ge 20 ] && exit 1
- if [ $UDEVVERSION -ge 143 ]; then
- udevadm settle --exit-if-exists="$read_only_device"
- else
- sleep 0.1
- fi
- i=$(($i + 1))
- done
-
- # NBD doesn't emit uevents when it gets connected, so kick it
- echo change > /sys/block/nbd0/uevent
- udevadm settle
-
- # wait for partitions TODO make nicer
- #touch $read_only_device
- #udevadm settle
+ read_only_device="$(container-unpack-xmount $SLX_DNBD3_DEVICE)"
else
# workaround to detect partitions on raw disks
# can be omited when the dnbd3 kernel module supports it (like the nbd
@@ -74,7 +51,7 @@ else
udevadm settle
read_only_device="$loop_device"
fi
-
+# region detect read-only partition
for i in 0.5 1 2; do
if read_only_partition=$(utils.find_block_device \
"$SLX_SYSTEM_PARTITION_IDENTIFIER" "$read_only_device"); then
@@ -128,20 +105,12 @@ fi
# endregion
-# region combine devices with device mapper
-partition_size="$(blockdev --getsz "$read_only_partition")"
-writable_partition_name='root'
logging.info "Using read-only device: $read_only_partition"
logging.info "Using writable device $writable_device, persistency: $persistent"
-chunksize='1'
-modprobe dm_snapshot
-dmsetup create "$writable_partition_name" --noudevsync --table \
- "0 $partition_size snapshot $read_only_partition $writable_device $persistent $chunksize"
-dmsetup mknodes --noudevsync "$writable_partition_name"
-# TODO remove
-echo 'IgnoreOnIsolate=true' >> /usr/lib/systemd/system/sockets.target
-# end TODO
-# endregion
+
+# combine devices with device mapper
+device-add-write-layer "root" "$read_only_partition" "$writable_device" "$persistent"
+
) || exit $?
exceptions.deactivate
# region vim modline