Made mdadm uuids discoverable
This commit is contained in:
parent
cfcefae1ec
commit
d203dfc6c3
|
@ -132,9 +132,10 @@ resolve_id_to_device() {
|
||||||
local arg="${disk_id_to_resolvable[$id]#*:}"
|
local arg="${disk_id_to_resolvable[$id]#*:}"
|
||||||
|
|
||||||
case "$type" in
|
case "$type" in
|
||||||
'partuuid') get_device_by_partuuid "$arg" ;;
|
'partuuid') get_device_by_partuuid "$arg" ;;
|
||||||
'ptuuid') get_device_by_ptuuid "$arg" ;;
|
'ptuuid') get_device_by_ptuuid "$arg" ;;
|
||||||
'uuid') get_device_by_uuid "$arg" ;;
|
'uuid') get_device_by_uuid "$arg" ;;
|
||||||
|
'mdadm') get_device_by_mdadm_uuid "$arg" ;;
|
||||||
*) die "Cannot resolve '$type:$arg' to device (unkown type)"
|
*) die "Cannot resolve '$type:$arg' to device (unkown type)"
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
@ -237,12 +238,14 @@ disk_create_raid() {
|
||||||
done
|
done
|
||||||
devices_desc="${devices_desc:0:-2}"
|
devices_desc="${devices_desc:0:-2}"
|
||||||
|
|
||||||
|
local mddevice="/dev/md/$name"
|
||||||
local uuid="${DISK_ID_TO_UUID[$new_id]}"
|
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"
|
einfo "Creating raid$level ($new_id) on $devices_desc"
|
||||||
mdadm \
|
mdadm \
|
||||||
--create "/dev/md/$name" \
|
--create "$mddevice" \
|
||||||
--verbose \
|
--verbose \
|
||||||
--homehost="$HOSTNAME" \
|
--homehost="$HOSTNAME" \
|
||||||
--metadata=1.2 \
|
--metadata=1.2 \
|
||||||
|
|
|
@ -29,6 +29,8 @@ declare -A DISK_ID_TO_UUID
|
||||||
declare -A DISK_GPT_HAD_SIZE_REMAINING
|
declare -A DISK_GPT_HAD_SIZE_REMAINING
|
||||||
# An associative from PTUUID to device
|
# An associative from PTUUID to device
|
||||||
declare -A DISK_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() {
|
only_one_of() {
|
||||||
local previous=""
|
local previous=""
|
||||||
|
@ -229,8 +231,8 @@ create_default_disk_layout() {
|
||||||
else
|
else
|
||||||
DISK_ID_BIOS="part_$type"
|
DISK_ID_BIOS="part_$type"
|
||||||
fi
|
fi
|
||||||
DISK_ID_SWAP=part_raid
|
DISK_ID_SWAP=part_swap
|
||||||
DISK_ID_ROOT=part_luks
|
DISK_ID_ROOT=part_root
|
||||||
}
|
}
|
||||||
|
|
||||||
# Example 2: Multiple disks, with raid 0 and luks
|
# Example 2: Multiple disks, with raid 0 and luks
|
||||||
|
|
|
@ -134,12 +134,16 @@ get_device_by_partuuid() {
|
||||||
get_device_by_blkid_field 'PARTUUID' "$1"
|
get_device_by_blkid_field 'PARTUUID' "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_device_by_uuid() {
|
||||||
|
get_device_by_blkid_field 'UUID' "$1"
|
||||||
|
}
|
||||||
|
|
||||||
get_device_by_ptuuid() {
|
get_device_by_ptuuid() {
|
||||||
echo -n "${DISK_PTUUID_TO_DEVICE[${1,,}]}"
|
echo -n "${DISK_PTUUID_TO_DEVICE[${1,,}]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_device_by_uuid() {
|
get_device_by_mdadm_uuid() {
|
||||||
get_device_by_blkid_field 'UUID' "$1"
|
echo -n "${DISK_MDADM_UUID_TO_DEVICE[${1,,}]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
load_or_generate_uuid() {
|
load_or_generate_uuid() {
|
||||||
|
|
Loading…
Reference in New Issue