summaryrefslogtreecommitdiffstats
path: root/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh
diff options
context:
space:
mode:
Diffstat (limited to 'builder/dnbd3-rootfs/hooks/prepare-root-partition.sh')
-rwxr-xr-xbuilder/dnbd3-rootfs/hooks/prepare-root-partition.sh7
1 files changed, 5 insertions, 2 deletions
diff --git a/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh b/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh
index cdd8c2f4..c527062a 100755
--- a/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh
+++ b/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh
@@ -39,19 +39,22 @@ fi
# region scan partitions
read_only_device=""
-if ! qemu-img info --output json "$SLX_DNBD3_DEVICE" | grep '"format": "raw"'
+if utils.dependency_check qemu-img && ! qemu-img qemu-img info --output json \
+ "$SLX_DNBD3_DEVICE" | grep '"format": "raw"'
then
read_only_device="$(container-unpack-xmount $SLX_DNBD3_DEVICE)"
else
# Workaround to detect partitions on raw disks can be omitted when the
# dnbd3 kernel module supports it (like the nbd kernel module with
# parameter "max_part").
- loop_device="$(losetup -f)"
+ loop_device="$(losetup --find)"
losetup "$loop_device" "$SLX_DNBD3_DEVICE" --partscan
read_only_device="$loop_device"
touch $read_only_device
udevadm settle
fi
+# Fail fast if no device could be determined.
+[ -z "$read_only_device" ] && exit 1
# endregion
# region find read-only partition