diff options
| author | jandob | 2016-01-29 12:37:33 +0100 |
|---|---|---|
| committer | jandob | 2016-01-29 12:37:33 +0100 |
| commit | a7109b0591aefeb87aaf5eb744db620c524f53f8 (patch) | |
| tree | bc1f0e5bc4a53793eb58a0c54cee4514c6e8544a /builder | |
| parent | add container2raw script (diff) | |
| parent | Fix. (diff) | |
| download | systemd-init-a7109b0591aefeb87aaf5eb744db620c524f53f8.tar.gz systemd-init-a7109b0591aefeb87aaf5eb744db620c524f53f8.tar.xz systemd-init-a7109b0591aefeb87aaf5eb744db620c524f53f8.zip | |
Merge branch 'master' of git.openslx.org:openslx-ng/systemd-init
Diffstat (limited to 'builder')
| -rwxr-xr-x | builder/dnbd3-rootfs/hooks/prepare-root-partition.sh | 106 | ||||
| m--------- | builder/dnbd3-rootfs/scripts/rebash | 0 |
2 files changed, 54 insertions, 52 deletions
diff --git a/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh b/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh index c527062a..71d64b3a 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,26 @@ 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' + 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 diff --git a/builder/dnbd3-rootfs/scripts/rebash b/builder/dnbd3-rootfs/scripts/rebash -Subproject 96e6914cb1ab15d243efe065f51306bae866a99 +Subproject 46681d9d6caef2c14b10f4512f12176a7b0c1f4 |
