7-add-legacy-bios-support #8
36
setup.sh
36
setup.sh
@ -34,7 +34,7 @@ partition_types[mbr_boot]='0x83'
|
|||||||
set -E
|
set -E
|
||||||
trap '[ "$?" -ne 77 ] || exit 77' ERR
|
trap '[ "$?" -ne 77 ] || exit 77' ERR
|
||||||
|
|
||||||
declare zpool_drive efi_drive part_schema
|
declare zpool_drive efi_drive boot_drive part_schema
|
||||||
|
|
||||||
function we_are_changerooted () {
|
function we_are_changerooted () {
|
||||||
if [ "$(stat -c '%d:%i' '/')" != "$(stat -c '%d:%i' '/proc/1/root/.')" ]; then
|
if [ "$(stat -c '%d:%i' '/')" != "$(stat -c '%d:%i' '/proc/1/root/.')" ]; then
|
||||||
@ -138,6 +138,9 @@ function get_parts () {
|
|||||||
fi
|
fi
|
||||||
parts="$(get_partitions | jq --raw-output '.[][] | select(.children | length > 0) | .children[] | select(.parttype=="'"${part_type_code}"'") | .path')" || exit 1
|
parts="$(get_partitions | jq --raw-output '.[][] | select(.children | length > 0) | .children[] | select(.parttype=="'"${part_type_code}"'") | .path')" || exit 1
|
||||||
;;
|
;;
|
||||||
|
boot)
|
||||||
|
parts="$(get_partitions | jq --raw-output '.[][] | select(.children | length > 0) | select(.path=="'"${zfs_install_drive:?}"'") | .children[] | select(.parttype=="'"${partition_types[mbr_boot]}"'") | .path')" || exit 1
|
||||||
|
;;
|
||||||
efi)
|
efi)
|
||||||
parts="$(get_partitions | jq --raw-output '.[][] | select(.children | length > 0) | select(.path=="'"${zfs_install_drive:?}"'") | .children[] | select(.parttype=="'"${partition_types[gpt_efi]}"'") | .path')" || exit 1
|
parts="$(get_partitions | jq --raw-output '.[][] | select(.children | length > 0) | select(.path=="'"${zfs_install_drive:?}"'") | .children[] | select(.parttype=="'"${partition_types[gpt_efi]}"'") | .path')" || exit 1
|
||||||
;;
|
;;
|
||||||
@ -186,15 +189,22 @@ function get_drive_id () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function select_part () {
|
function select_part () {
|
||||||
local parts enriched_parts enriched_parts_count part_number part_type zfs_install_drive part_type_code
|
local parts enriched_parts enriched_parts_count part_number part_type zfs_install_drive part_type_code specific_part_type
|
||||||
declare part
|
declare part
|
||||||
part_type="${1:?}" # 'efi' or 'zfs'
|
part_type="${1:?}" # 'boot' or 'zfs'
|
||||||
zfs_install_drive="${2:-}"
|
zfs_install_drive="${2:-}"
|
||||||
if [[ "${zfs_install_drive}" ]]; then
|
|
||||||
# This is intended to find correct EFI partition
|
if [[ "${part_schema}" = 'mbr' ]]; then
|
||||||
parts="$(get_parts "${part_type}" "${zfs_install_drive}")"
|
specific_part_type='boot'
|
||||||
else
|
else
|
||||||
parts="$(get_parts "${part_type}")"
|
specific_part_type='efi'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${zfs_install_drive}" ]]; then
|
||||||
|
# This is intended to find correct boot/EFI partition
|
||||||
|
parts="$(get_parts "${specific_part_type}" "${zfs_install_drive}")"
|
||||||
|
else
|
||||||
|
parts="$(get_parts "${specific_part_type}")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! "${parts}" ]]; then
|
if [[ ! "${parts}" ]]; then
|
||||||
@ -324,12 +334,20 @@ function mount_system () {
|
|||||||
zfs mount "${zpool_name}"'/root/'"${zfs_arch_dataset_name}"
|
zfs mount "${zpool_name}"'/root/'"${zfs_arch_dataset_name}"
|
||||||
zfs mount -a
|
zfs mount -a
|
||||||
|
|
||||||
local zfs_parent efi_part
|
local zfs_parent efi_part boot_part
|
||||||
zfs_parent="$(get_part_parent "${zpool_drive:?}")"
|
zfs_parent="$(get_part_parent "${zpool_drive:?}")"
|
||||||
|
|
||||||
|
if [[ "${part_schema}" = 'mbr' ]]; then
|
||||||
|
boot_drive="${zfs_parent}"
|
||||||
|
boot_part="$(select_part 'boot' "${zfs_parent:?}")"
|
||||||
|
mkdir -p '/mnt/boot/syslinux'
|
||||||
|
mount "${boot_part}" '/mnt/boot/syslinux'
|
||||||
|
else
|
||||||
efi_drive="${zfs_parent}"
|
efi_drive="${zfs_parent}"
|
||||||
efi_part="$(select_part 'efi' "${zfs_parent:?}")"
|
efi_part="$(select_part 'boot' "${zfs_parent:?}")"
|
||||||
mkdir -p '/mnt/efi'
|
mkdir -p '/mnt/efi'
|
||||||
mount "${efi_part}" '/mnt/efi'
|
mount "${efi_part}" '/mnt/efi'
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function copy_zpool_cache () {
|
function copy_zpool_cache () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user