From bed90c1c45ab9956756813a8596410d18143de78 Mon Sep 17 00:00:00 2001 From: torben Date: Thu, 28 Jan 2016 17:22:46 +0100 Subject: CentOS now supported! --- .../dnbd3-rootfs/hooks/prepare-root-partition.sh | 109 +++++++++++---------- 1 file changed, 57 insertions(+), 52 deletions(-) (limited to 'builder') diff --git a/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh b/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh index c527062a..be327555 100755 --- a/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh +++ b/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh @@ -14,6 +14,46 @@ logging.set_log_level debug SLX_SERVER_BASE="$(getargs slxbase=)" source /etc/openslx +# region find writable partition +if ! persistent_device=$(utils.find_block_device \ + "$SLX_WRITABLE_DEVICE_IDENTIFIER"); then + logging.warn "Failed to find unique device with identifier" \ + "'${SLX_WRITABLE_DEVICE_IDENTIFIER}'; matched devices:" \ + "'${persistent_device}'" +fi + +# TODO move somewhere else +#tmp_device="$(utils.find_block_device \ + #'$SLX_TMP_PARTITION_IDENTIFIER')" + +#if [ -n $tmp_device ]; then + #mount --type auto "$tmp_device" "$NEWROOT/tmp" +#fi + +persistent='N' # 'P' for persistent storage, 'N' for not persistent +if [ -n "$persistent_device" ]; then + writable_device="$persistent_device" + if [ "$SLX_WRITABLE_DEVICE_PERSISTENT" = "yes" ]; then + persistent='P' + fi +else + ramdisk_size="$SLX_RAMDISK_SIZE" + if [ "$ramdisk_size" = "" ]; then + ramdisk_size="$(cat /proc/meminfo | awk '/MemTotal/ {print $2}')" + fi + modprobe brd max_part=1 rd_size="$ramdisk_size" + writable_device='/dev/ram0' + persistent='N' +fi + +# persistent storage on a filesystem (e.g. usb stick) +# writable_device="$(losetup -f)" +#dd if=/dev/zero of=persistent_storage.img bs=1k count=1000 +#losetup "$writable_device" persistent_storage.img +#persistent='P' + +# endregion + # region connect dnbd3 IFS_backup="$IFS" IFS="," @@ -50,7 +90,7 @@ else loop_device="$(losetup --find)" losetup "$loop_device" "$SLX_DNBD3_DEVICE" --partscan read_only_device="$loop_device" - touch $read_only_device + touch "$read_only_device" udevadm settle fi # Fail fast if no device could be determined. @@ -58,64 +98,29 @@ fi # endregion # region find 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 - break - else - logging.warn "Failed to find unique device with identifier" \ - "'${SLX_SYSTEM_PARTITION_IDENTIFIER}'; matched devices:" \ - "'${read_only_partition}'" - sleep $i - fi -done -# endregion - -# region find writable partition -if ! persistent_device=$(utils.find_block_device \ - "$SLX_WRITABLE_DEVICE_IDENTIFIER"); then - logging.warn "Failed to find unique device with identifier" \ - "'${SLX_WRITABLE_DEVICE_IDENTIFIER}'; matched devices:" \ - "'${persistent_device}'" -fi - -# TODO move somewhere else -#tmp_device="$(utils.find_block_device \ - #'$SLX_TMP_PARTITION_IDENTIFIER')" - -#if [ -n $tmp_device ]; then - #mount --type auto "$tmp_device" "$NEWROOT/tmp" -#fi - -persistent='N' # 'P' for persistent storage, 'N' for not persistent -if [ -n "$persistent_device" ]; then - writable_device="$persistent_device" - if [ "$SLX_WRITABLE_DEVICE_PERSISTENT" = "yes" ]; then - persistent='P' - fi +if [ -z "$SLX_SYSTEM_PARTITION_PREPARATION_SCRIPT" ]; then + read_only_partition="$(utils.find_block_device \ + "$SLX_SYSTEM_PARTITION_IDENTIFIER" "$read_only_device")" else - ramdisk_size="$SLX_RAMDISK_SIZE" - if [ "$ramdisk_size" = "" ]; then - ramdisk_size="$(cat /proc/meminfo | awk '/MemTotal/ {print $2}')" - fi - modprobe brd max_part=1 rd_size="$ramdisk_size" - writable_device='/dev/ram0' - persistent='N' + logging.plain + logging.plain "$SLX_SYSTEM_PARTITION_PREPARATION_SCRIPT" + logging.plain + eval "$SLX_SYSTEM_PARTITION_PREPARATION_SCRIPT" +fi +if [[ ! $? || -z "$read_only_partition" ]]; then + logging.error "Failed to find unique device with identifier" \ + "\"${SLX_SYSTEM_PARTITION_IDENTIFIER}\"; matched devices:" \ + "\"${read_only_partition}\"" + exit 1 fi - -# persistent storage on a filesystem (e.g. usb stick) -# writable_device="$(losetup -f)" -#dd if=/dev/zero of=persistent_storage.img bs=1k count=1000 -#losetup "$writable_device" persistent_storage.img -#persistent='P' - # endregion -logging.info "Using read-only device: $read_only_partition" +logging.info "Using read-only partition: $read_only_partition" logging.info "Using writable device $writable_device, persistency: $persistent" # combine devices with device mapper -device-add-write-layer "root" "$read_only_partition" "$writable_device" "$persistent" +device-add-write-layer "root" "$read_only_partition" "$writable_device" \ + "$persistent" ) || exit $? exceptions.deactivate -- cgit v1.2.3-55-g7522 From 560aebc2efc10a81ae23ac262a64633accbd085e Mon Sep 17 00:00:00 2001 From: torben Date: Thu, 28 Jan 2016 17:23:27 +0100 Subject: Fix. --- builder/dnbd3-rootfs/hooks/prepare-root-partition.sh | 3 --- builder/dnbd3-rootfs/scripts/rebash | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) (limited to 'builder') diff --git a/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh b/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh index be327555..71d64b3a 100755 --- a/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh +++ b/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh @@ -102,9 +102,6 @@ if [ -z "$SLX_SYSTEM_PARTITION_PREPARATION_SCRIPT" ]; then read_only_partition="$(utils.find_block_device \ "$SLX_SYSTEM_PARTITION_IDENTIFIER" "$read_only_device")" else - logging.plain - logging.plain "$SLX_SYSTEM_PARTITION_PREPARATION_SCRIPT" - logging.plain eval "$SLX_SYSTEM_PARTITION_PREPARATION_SCRIPT" fi if [[ ! $? || -z "$read_only_partition" ]]; then diff --git a/builder/dnbd3-rootfs/scripts/rebash b/builder/dnbd3-rootfs/scripts/rebash index 96e6914c..46681d9d 160000 --- a/builder/dnbd3-rootfs/scripts/rebash +++ b/builder/dnbd3-rootfs/scripts/rebash @@ -1 +1 @@ -Subproject commit 96e6914cb1ab15d243efe065f51306bae866a99d +Subproject commit 46681d9d6caef2c14b10f4512f12176a7b0c1f47 -- cgit v1.2.3-55-g7522