diff options
Diffstat (limited to 'builder/modules.d/slx-dmsetup')
3 files changed, 0 insertions, 164 deletions
diff --git a/builder/modules.d/slx-dmsetup/scripts/gen-fstab-persistent b/builder/modules.d/slx-dmsetup/scripts/gen-fstab-persistent deleted file mode 100644 index ed00b5de..00000000 --- a/builder/modules.d/slx-dmsetup/scripts/gen-fstab-persistent +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env bash -# -# Hook to generate stage4's fstab entries for persistent partitions -# -# Persistent identifiers (MBR types, GPT partition labels) -# are expected to be specified in the OpenSLX config -# as 'SLX_PERSISTENT_DEVICE_IDENTIFIER' and their filesystem -# as 'SLX_PERSISTENT_DEVICE_FILESYSTEM', e.g ext4 or xfs. -# If not specified, will default to 'auto' but will not -# active systemd's features 'x-systemd.makefs' and 'x-systemd.growfs' - -. /etc/openslx - -type -p emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh - -# NOTE: systemd makes the mount point path automatically. -# if multiple exists, take the biggest one (first in the list) -if [ -n "$SLX_PERSISTENT_DEVICE_IDENTIFIER" ]; then - declare -a persistent_dev_list - for persistent_dev in \ - $(get_partitions_by_id ${SLX_PERSISTENT_DEVICE_IDENTIFIER//,/ /}); do - [ -z "$persistent_dev" ] && continue - persistent_dev_list+=("$persistent_dev") - done - if [ "${#persistent_dev[@]}" -gt 0 ]; then - if [ "${#persistent_dev[@]}" -gt 1 ]; then - warn "$0: More than one persistent device found." - warn "$0: Will use the biggest one: ${persistent_dev[0]}" - fi - persistent_dev_systemd_name="$( tr '/' '-' <<< ${persistent_dev[0]:1})" - persistent_mount_opts="nofail" - if [ -n "$SLX_PERSISTENT_DEVICE_FILESYSTEM" ]; then - #persistent_mount_opts+=",x-systemd.requires=ensure-fs@${persistent_dev_systemd_name}" - persistent_mount_opts+=",x-systemd.after=ensure-fs@${persistent_dev_systemd_name}" - fi - ( - echo -ne "${persistent_dev[0]}\t" - echo -ne "${SLX_PERSISTENT_DEVICE_MOUNT_POINT:-/opt/openslx/persistent}\t" - echo -ne "${SLX_PERSISTENT_DEVICE_FILESYSTEM:-auto}\t" - echo -ne "${persistent_mount_opts}\t0\t2" - ) >> "$NEWROOT/etc/fstab" - - # drop-in to create filesystem if needed and - #persistent_dev_systemd_name="$( tr '/' '-' <<< ${persistent_dev[0]:1})" - #mkdir -p "$NEWROOT/etc/systemd/system/${persistent_dev_systemd_name}" - #cat <<- EOF > "$NEWROOT" - #EOF - else - warn "$0: No device with ID '$SLX_PERSISTENT_DEVICE_IDENTIFIER' found." - fi -fi -true diff --git a/builder/modules.d/slx-dmsetup/scripts/generate-fstab-persistent.sh b/builder/modules.d/slx-dmsetup/scripts/generate-fstab-persistent.sh deleted file mode 100644 index 5c6f2b82..00000000 --- a/builder/modules.d/slx-dmsetup/scripts/generate-fstab-persistent.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env bash -# -# Hook to generate stage4's fstab entries for persistent partitions -# -# Persistent identifiers (MBR types, GPT partition labels) -# are expected to be specified in the OpenSLX config -# as 'SLX_PERSISTENT_DEVICE_IDENTIFIER' and their filesystem -# as 'SLX_PERSISTENT_DEVICE_FILESYSTEM', e.g ext4 or xfs. -# If not specified, will default to 'auto' but will not -# active systemd's features 'x-systemd.makefs' and 'x-systemd.growfs' - -. /etc/openslx - -type -p emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh - -# NOTE: systemd makes the mount point path automatically. -# if multiple exists, take the biggest one (first in the list) -if [ -n "$SLX_PERSISTENT_DEVICE_IDENTIFIER" ]; then - declare -a persistent_dev_list - for persistent_dev in \ - $(get-partitions-by-id ${SLX_PERSISTENT_DEVICE_IDENTIFIER//,/ /}); do - [ -z "$persistent_dev" ] && continue - persistent_dev_list+=("$persistent_dev") - done - if [ "${#persistent_dev[@]}" -gt 0 ]; then - if [ "${#persistent_dev[@]}" -gt 1 ]; then - warn "$0: More than one persistent device found." - warn "$0: Will use the biggest one: ${persistent_dev[0]}" - fi - persistent_dev_systemd_name="$( tr '/' '-' <<< ${persistent_dev[0]:1})" - persistent_mount_opts="nofail" - if [ -n "$SLX_PERSISTENT_DEVICE_FILESYSTEM" ]; then - #persistent_mount_opts+=",x-systemd.requires=ensure-fs@${persistent_dev_systemd_name}" - persistent_mount_opts+=",x-systemd.after=ensure-fs@${persistent_dev_systemd_name}" - fi - ( - echo -ne "${persistent_dev[0]}\t" - echo -ne "${SLX_PERSISTENT_DEVICE_MOUNT_POINT:-/opt/openslx/persistent}\t" - echo -ne "${SLX_PERSISTENT_DEVICE_FILESYSTEM:-auto}\t" - echo -ne "${persistent_mount_opts}\t0\t2" - ) >> "$NEWROOT/etc/fstab" - - # drop-in to create filesystem if needed and - #persistent_dev_systemd_name="$( tr '/' '-' <<< ${persistent_dev[0]:1})" - #mkdir -p "$NEWROOT/etc/systemd/system/${persistent_dev_systemd_name}" - #cat <<- EOF > "$NEWROOT" - #EOF - else - warn "$0: No device with ID '$SLX_PERSISTENT_DEVICE_IDENTIFIER' found." - fi -fi -true diff --git a/builder/modules.d/slx-dmsetup/scripts/get-partitions-by-id b/builder/modules.d/slx-dmsetup/scripts/get-partitions-by-id deleted file mode 100755 index 2fe5ce7a..00000000 --- a/builder/modules.d/slx-dmsetup/scripts/get-partitions-by-id +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env bash -# -# Get all partitions with given ids (list of /dev/sdXX) -# Examples of supported ID types: -# * MBR's type: 44 -# * GPT's UUID: 0657fd6d-a4ab-43c4-84e5-0933c84b4f4f (swap) -# * GPT's Name: OpenSLX-ID44 -# -# First argument can be a block device to limit the search to -# partitions thereof, e.g. for /dev/loop0 to look for /dev/loop0pX -# -# NOTE: for compatibility reasons, MBR's type will also -# be matched against part name 'OpenSLX-ID<id>'. -# The output will be a list of matching devices, -# sorted from largest to smallest. -get_partitions_by_id () { - local ID dev exp target - exp= - # target for the scan, defaults to /dev to check everything - target=/dev - if [ -b "$1" ]; then - target="$1"'*' - shift - fi - # support commas and pipes to separate identifiers - local args=$@ - set -- ${args//[,|]/ } - while [ $# -gt 0 ]; do - ID=$1 - shift - [ -z "$ID" ] && continue - # if single digit, e.g. 7, look for 0x7 and 0x07 - [[ $ID =~ ^[0-9]$ ]] && ID="0?$ID" - if [[ $ID =~ ^[0-9]{2}$ ]]; then - # if double digit look for MBR types and OpenSLX-ID$ID GPT labels - exp="$exp|ID_PART_ENTRY_(NAME=OpenSLX-ID|TYPE=0x)$ID" - elif [[ $ID =~ ^(0x[0-9]{2}|[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})$ ]]; then - # if full MBR type (e.g. 0x44) or UUID look for TYPE - exp="$exp|ID_PART_ENTRY_TYPE=$ID" - else - # something else, look for names of partitions / filesystems - exp="$exp|ID_(PART_ENTRY_NAME|FS_LABEL)=$ID" - fi - done - exp=${exp:1} - #echo "Partition find is '$exp'" >&2 - for dev in $(find $target -type b); do - udevadm info --name="$dev" | grep -iqE "($exp)\$" \ - && echo "$(blockdev --getsize64 "$dev") $dev" - done | sort -n -k1 -r | cut -d' ' -f2 -} - -## MAIN -if [ $# -eq 0 ]; then - echo "$0 needs at least one argument." - exit 1 -fi - -get_partitions_by_id $@ - |