Fixed PTUUID ambiguity leading to blkid not showing results

This commit is contained in:
oddlama 2020-04-21 23:15:29 +02:00
parent 265851cbc8
commit 9133dcb37c
No known key found for this signature in database
GPG Key ID: 88EA325D51D53908
3 changed files with 8 additions and 5 deletions

View File

@ -132,9 +132,9 @@ 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" ;;
*) die "Cannot resolve '$type:$arg' to device (unkown type)" *) die "Cannot resolve '$type:$arg' to device (unkown type)"
esac esac
} }
@ -161,6 +161,7 @@ disk_create_gpt() {
fi fi
local ptuuid="${DISK_ID_TO_UUID[$new_id]}" local ptuuid="${DISK_ID_TO_UUID[$new_id]}"
DISK_PTUUID_TO_DEVICE[${ptuuid,,}]="$device"
disk_id_to_resolvable[$new_id]="ptuuid:$ptuuid" disk_id_to_resolvable[$new_id]="ptuuid:$ptuuid"
einfo "Creating new gpt partition table ($new_id) on $device_desc" einfo "Creating new gpt partition table ($new_id) on $device_desc"
@ -202,7 +203,7 @@ disk_create_partition() {
einfo "Creating partition ($new_id) with type=$type, size=$size on $device" einfo "Creating partition ($new_id) with type=$type, size=$size on $device"
# shellcheck disable=SC2086 # shellcheck disable=SC2086
sgdisk -n "0:0:$arg_size" -t "0:$type" -u 0:"$partuuid" $extra_args "$device" >/dev/null \ sgdisk -n "0:0:$arg_size" -t "0:$type" -u "0:$partuuid" $extra_args "$device" >/dev/null \
|| die "Could not create new gpt partition ($new_id) on '$device' ($id)" || die "Could not create new gpt partition ($new_id) on '$device' ($id)"
partprobe "$device" partprobe "$device"
} }

View File

@ -27,6 +27,8 @@ declare -A DISK_PARTUUID_TO_GPT_UUID
declare -A DISK_ID_TO_UUID declare -A DISK_ID_TO_UUID
# An associative set to check for correct usage of size=remaining in gpt tables # An associative set to check for correct usage of size=remaining in gpt tables
declare -A DISK_GPT_HAD_SIZE_REMAINING declare -A DISK_GPT_HAD_SIZE_REMAINING
# An associative from PTUUID to device
declare -A DISK_PTUUID_TO_DEVICE
only_one_of() { only_one_of() {
local previous="" local previous=""

View File

@ -135,7 +135,7 @@ get_device_by_partuuid() {
} }
get_device_by_ptuuid() { get_device_by_ptuuid() {
get_device_by_blkid_field 'PTUUID' "$1" echo -n "${DISK_PTUUID_TO_DEVICE[${1,,}]}"
} }
get_device_by_uuid() { get_device_by_uuid() {