diff --git a/setup.sh b/setup.sh index 836c7f6..970fd30 100644 --- a/setup.sh +++ b/setup.sh @@ -11,7 +11,7 @@ zfs_arch_dataset_name='archlinux' set -E trap '[ "$?" -ne 77 ] || exit 77' ERR -declare zpool_drive +declare zpool_drive efi_drive function set_ntp () { timedatectl set-ntp true @@ -51,6 +51,14 @@ function get_partitions () { return 0 } +function get_part_parent () { + local child_partition parent_partition + child_partition="${1:?}" + parent_partition="$(get_partitions | jq --raw-output '.[][] | select(.children | length > 0) | select(.children[].path=="'"${child_partition:?}"'") | .path')" + printf -- '%s' "${parent_partition}" + return 0 +} + function get_parts () { local zfs_install_drive declare parttype parts @@ -61,7 +69,7 @@ function get_parts () { parts="$(get_partitions | jq --raw-output '.[][] | select(.children | length > 0) | .children[] | select(.parttype=="6a85cf4d-1dd2-11b2-99a6-080020736631") | .path')" || exit 1 ;; efi) - parts="$(get_partitions | jq --raw-output '.[][] | select(.children | length > 0) | select(.children[].path=="'"${zfs_install_drive:?}"'") | .children[] | select(.parttype=="c12a7328-f81f-11d2-ba4b-00a0c93ec93b") | .path')" || exit 1 + parts="$(get_partitions | jq --raw-output '.[][] | select(.children | length > 0) | select(.path=="'"${zfs_install_drive:?}"'") | .children[] | select(.parttype=="c12a7328-f81f-11d2-ba4b-00a0c93ec93b") | .path')" || exit 1 ;; *) >2 printf -- '%s\n' 'Unknown partition type '"'"'"${parttype}"'"'"', exiting ...' @@ -212,7 +220,10 @@ function mount_system () { zfs mount "${zpool_name}"'/root/'"${zfs_arch_dataset_name}" zfs mount -a - local efi_part="$(select_part 'efi' "${zpool_drive:?}")" + local zfs_parent efi_part + zfs_parent="$(get_part_parent "${zpool_drive:?}")" + efi_drive="${zfs_parent}" + efi_part="$(select_part 'efi' "${zfs_parent:?}")" mkdir -p '/mnt/efi' mount "${efi_part}" '/mnt/efi' } @@ -523,7 +534,6 @@ function configure_zfs_mount_gen () { } function configure_zfsbootmenu () { - mkdir -p '/mnt/efi/EFI/ZBM' curl -s 'https://raw.githubusercontent.com/zbm-dev/zfsbootmenu/master/etc/zfsbootmenu/mkinitcpio.conf' | sed -r -e '/^#/d' -e '/^$/d' > '/mnt/etc/zfsbootmenu/mkinitcpio.conf' cat > '/mnt/etc/zfsbootmenu/config.yaml' <