Added blkid device resolve by PTUUID

This commit is contained in:
oddlama 2020-04-21 20:58:21 +02:00
parent bab787cbb7
commit 29a7b8a183
No known key found for this signature in database
GPG Key ID: 88EA325D51D53908
3 changed files with 20 additions and 18 deletions

View File

@ -133,8 +133,8 @@ resolve_id_to_device() {
case "$type" in
'partuuid') get_device_by_partuuid "$arg" ;;
'ptuuid') get_device_by_ptuuid "$arg" ;;
'uuid') get_device_by_uuid "$arg" ;;
'raw') echo -n "$arg" ;;
*) die "Cannot resolve '$type:$arg' to device (unkown type)"
esac
}
@ -160,11 +160,11 @@ disk_create_gpt() {
device_desc="$device"
fi
local uuid="${DISK_ID_TO_UUID[$new_id]}"
disk_id_to_resolvable[$new_id]="uuid:$uuid"
local ptuuid="${DISK_ID_TO_UUID[$new_id]}"
disk_id_to_resolvable[$new_id]="ptuuid:$ptuuid"
einfo "Creating new gpt partition table ($new_id) on $device_desc"
sgdisk -Z -U "$uuid" "$device" >/dev/null \
sgdisk -Z -U "$ptuuid" "$device" >/dev/null \
|| die "Could not create new gpt partition table ($new_id) on '$device'"
partprobe "$device"
}

View File

@ -116,7 +116,7 @@ install_kernel_efi() {
local efipartnum="${efipartdev: -1}"
local gptuuid="${DISK_PARTUUID_TO_GPT_UUID[$PARTITION_UUID_EFI]}"
local gptdev
gptdev="$(get_device_by_uuid "$gptuuid")" \
gptdev="$(get_device_by_ptuuid "$gptuuid")" \
|| die "Could not resolve GPT UUID '$gptuuid'"
try efibootmgr --verbose --create --disk "$gptdev" --part "$efipartnum" --label "gentoo" --loader '\EFI\vmlinuz.efi' --unicode "root=$linuxdev initrd=\\EFI\\initramfs.img"
}
@ -131,7 +131,7 @@ install_kernel_bios() {
|| die "Could not resolve partition UUID '$PARTITION_UUID_BOOT'"
local gptuuid="${DISK_PARTUUID_TO_GPT_UUID[$PARTITION_UUID_BOOT]}"
local gptdev
gptdev="$(get_device_by_uuid "$gptuuid")" \
gptdev="$(get_device_by_ptuuid "$gptuuid")" \
|| die "Could not resolve GPT UUID '$gptuuid'"
try dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/gptmbr.bin of="$gptdev"

View File

@ -116,28 +116,30 @@ download() {
wget --quiet --https-only --secure-protocol=PFS --show-progress -O "$2" -- "$1"
}
get_device_by_partuuid() {
get_device_by_blkid_field() {
local blkid_field="$1"
local field_value="$2"
blkid -g \
|| die "Error while executing blkid"
local dev
dev="$(blkid -o export -t PARTUUID="$1")" \
|| die "Error while executing blkid to find PARTUUID=$1"
dev="$(blkid -o export -t "$blkid_field=$field_value")" \
|| die "Error while executing blkid to find $blkid_field=$field_value"
dev="$(grep DEVNAME <<< "$dev")" \
|| die "Could not find DEVNAME=... in blkid output"
dev="${dev:8}"
echo -n "$dev"
}
get_device_by_partuuid() {
get_device_by_blkid_field 'PARTUUID' "$1"
}
get_device_by_ptuuid() {
get_device_by_blkid_field 'PTUUID' "$1"
}
get_device_by_uuid() {
blkid -g \
|| die "Error while executing blkid"
local dev
dev="$(blkid -o export -t UUID="$1")" \
|| die "Error while executing blkid to find UUID=$1"
dev="$(grep DEVNAME <<< "$dev")" \
|| die "Could not find DEVNAME=... in blkid output"
dev="${dev:8}"
echo -n "$dev"
get_device_by_blkid_field 'UUID' "$1"
}
load_or_generate_uuid() {