diff --git a/scripts/functions.sh b/scripts/functions.sh index 77388c1..754180a 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -132,9 +132,10 @@ resolve_id_to_device() { local arg="${disk_id_to_resolvable[$id]#*:}" case "$type" in - 'partuuid') get_device_by_partuuid "$arg" ;; - 'ptuuid') get_device_by_ptuuid "$arg" ;; - 'uuid') get_device_by_uuid "$arg" ;; + 'partuuid') get_device_by_partuuid "$arg" ;; + 'ptuuid') get_device_by_ptuuid "$arg" ;; + 'uuid') get_device_by_uuid "$arg" ;; + 'mdadm') get_device_by_mdadm_uuid "$arg" ;; *) die "Cannot resolve '$type:$arg' to device (unkown type)" esac } @@ -237,12 +238,14 @@ disk_create_raid() { done devices_desc="${devices_desc:0:-2}" + local mddevice="/dev/md/$name" local uuid="${DISK_ID_TO_UUID[$new_id]}" - disk_id_to_resolvable[$new_id]="uuid:$uuid" + DISK_MDADM_UUID_TO_DEVICE[${uuid,,}]="$mddevice" + disk_id_to_resolvable[$new_id]="mdadm:$uuid" einfo "Creating raid$level ($new_id) on $devices_desc" mdadm \ - --create "/dev/md/$name" \ + --create "$mddevice" \ --verbose \ --homehost="$HOSTNAME" \ --metadata=1.2 \ diff --git a/scripts/internal_config.sh b/scripts/internal_config.sh index f66a7c5..dbcade0 100644 --- a/scripts/internal_config.sh +++ b/scripts/internal_config.sh @@ -29,6 +29,8 @@ declare -A DISK_ID_TO_UUID declare -A DISK_GPT_HAD_SIZE_REMAINING # An associative from PTUUID to device declare -A DISK_PTUUID_TO_DEVICE +# An associative from MDADM uuid to device +declare -A DISK_MDADM_UUID_TO_DEVICE only_one_of() { local previous="" @@ -229,8 +231,8 @@ create_default_disk_layout() { else DISK_ID_BIOS="part_$type" fi - DISK_ID_SWAP=part_raid - DISK_ID_ROOT=part_luks + DISK_ID_SWAP=part_swap + DISK_ID_ROOT=part_root } # Example 2: Multiple disks, with raid 0 and luks diff --git a/scripts/utils.sh b/scripts/utils.sh index 6d98b1d..d21b2b8 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -134,12 +134,16 @@ get_device_by_partuuid() { get_device_by_blkid_field 'PARTUUID' "$1" } +get_device_by_uuid() { + get_device_by_blkid_field 'UUID' "$1" +} + get_device_by_ptuuid() { echo -n "${DISK_PTUUID_TO_DEVICE[${1,,}]}" } -get_device_by_uuid() { - get_device_by_blkid_field 'UUID' "$1" +get_device_by_mdadm_uuid() { + echo -n "${DISK_MDADM_UUID_TO_DEVICE[${1,,}]}" } load_or_generate_uuid() {