summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Bauer2022-03-02 18:57:37 +0100
committerJonathan Bauer2022-03-02 18:57:37 +0100
commitb3442c9b9bd31769465a0b8ebc320fc180e69469 (patch)
treef4e075555da3798e487f66310521909aee5bae2e
parentupdates to new dnbd3 (diff)
downloadsystemd-init-b3442c9b9bd31769465a0b8ebc320fc180e69469.tar.gz
systemd-init-b3442c9b9bd31769465a0b8ebc320fc180e69469.tar.xz
systemd-init-b3442c9b9bd31769465a0b8ebc320fc180e69469.zip
add RAW support
-rwxr-xr-xmodules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh23
1 files changed, 21 insertions, 2 deletions
diff --git a/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh b/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh
index 35b4204f..fac961bd 100755
--- a/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh
+++ b/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh
@@ -44,6 +44,22 @@ container_unpack_xloop() {
udevadm settle
echo "$out_device"
}
+
+container_unpack_raw() {
+ if [ -z "$1" ]; then
+ warn "No target device given to setup as loop device."
+ return 1
+ fi
+ local in_device="$1"
+ local out_device="$(losetup -f)"
+ if ! losetup "$out_device" "$in_device" --partscan; then
+ emergency_shell "Failed to attach '$in_device' to '$out_device'."
+ return 1
+ fi
+ udevadm settle
+ echo "$out_device"
+}
+
# endregion
# region connect dnbd3 image
@@ -92,7 +108,7 @@ done
# endregion
# region unpack dnbd3 image
-if ! [[ $SLX_QCOW_HANDLER =~ ^(kernel|xmount)?$ ]]; then
+if ! [[ $SLX_QCOW_HANDLER =~ ^(kernel|xmount|raw)?$ ]]; then
emergency_shell "Unsupported QCOW handler: $SLX_QCOW_HANDLER" \
"Use either 'xmount' or 'kernel'."
fi
@@ -100,6 +116,9 @@ if [ -z "$SLX_QCOW_HANDLER" ]; then
SLX_QCOW_HANDLER="xmount"
echo "SLX_QCOW_HANDLER='$SLX_QCOW_HANDLER'" >> /etc/openslx
fi
+if [ "$SLX_QCOW_HANDLER" = "raw" ]; then
+ read_only_device="$(container_unpack_raw "$_dnbd3_dev")"
+fi
if [ "$SLX_QCOW_HANDLER" = "kernel" ]; then
read_only_device="$(container_unpack_xloop "$_dnbd3_dev")"
fi
@@ -109,7 +128,7 @@ fi
# Fail fast if unpacking dnbd3 image failed.
if [ -z "$read_only_device" ]; then
- emergency_shell "Failed to unpack the qcow2 image!"
+ emergency_shell "Failed to unpack the dnbd3 image!"
fi
# endregion