Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bsdinstall/scripts/zfsboot
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | |||||
# | # | ||||
# Default path to the geli(8) keyfile used in drive encryption | # Default path to the geli(8) keyfile used in drive encryption | ||||
# | # | ||||
: ${ZFSBOOT_GELI_KEY_FILE:=/boot/encryption.key} | : ${ZFSBOOT_GELI_KEY_FILE:=/boot/encryption.key} | ||||
# | # | ||||
# Create a separate boot pool? | # Create a separate boot pool? | ||||
# NB: Automatically set when using geli(8) or MBR | # NB: Automatically set when using geli(8) | ||||
# | # | ||||
: ${ZFSBOOT_BOOT_POOL=} | : ${ZFSBOOT_BOOT_POOL=} | ||||
# | # | ||||
# Options to use when creating separate boot pool (if any) | # Options to use when creating separate boot pool (if any) | ||||
# | # | ||||
: ${ZFSBOOT_BOOT_POOL_CREATE_OPTIONS:=} | : ${ZFSBOOT_BOOT_POOL_CREATE_OPTIONS:=} | ||||
# | # | ||||
# Default name for boot pool when enabled (e.g., geli(8) or MBR) | # Default name for boot pool when enabled (e.g., geli(8)) | ||||
# | # | ||||
: ${ZFSBOOT_BOOT_POOL_NAME:=bootpool} | : ${ZFSBOOT_BOOT_POOL_NAME:=bootpool} | ||||
# | # | ||||
# Default size for boot pool when enabled (e.g., geli(8) or MBR) | # Default size for boot pool when enabled (e.g., geli(8)) | ||||
# | # | ||||
: ${ZFSBOOT_BOOT_POOL_SIZE:=2g} | : ${ZFSBOOT_BOOT_POOL_SIZE:=2g} | ||||
# | # | ||||
# Default disks to use (always empty unless being scripted) | # Default disks to use (always empty unless being scripted) | ||||
# | # | ||||
: ${ZFSBOOT_DISKS:=} | : ${ZFSBOOT_DISKS:=} | ||||
▲ Show 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | |||||
msg_no_disks_present_to_configure="No disk(s) present to configure" | msg_no_disks_present_to_configure="No disk(s) present to configure" | ||||
msg_no_disks_selected="No disks selected." | msg_no_disks_selected="No disks selected." | ||||
msg_not_enough_disks_selected="Not enough disks selected. (%u < %u minimum)" | msg_not_enough_disks_selected="Not enough disks selected. (%u < %u minimum)" | ||||
msg_null_disk_argument="NULL disk argument" | msg_null_disk_argument="NULL disk argument" | ||||
msg_null_index_argument="NULL index argument" | msg_null_index_argument="NULL index argument" | ||||
msg_null_poolname="NULL poolname" | msg_null_poolname="NULL poolname" | ||||
msg_ok="OK" | msg_ok="OK" | ||||
msg_partition_scheme="Partition Scheme" | msg_partition_scheme="Partition Scheme" | ||||
msg_partition_scheme_help="Toggle between GPT and MBR partitioning schemes" | msg_partition_scheme_help="Toggle between GPT, MBR, and BSD partitioning schemes" | ||||
msg_please_enter_a_name_for_your_zpool="Please enter a name for your zpool:" | msg_please_enter_a_name_for_your_zpool="Please enter a name for your zpool:" | ||||
msg_please_enter_amount_of_swap_space="Please enter amount of swap space (SI-Unit suffixes\nrecommended; e.g., \`2g' for 2 Gigabytes):" | msg_please_enter_amount_of_swap_space="Please enter amount of swap space (SI-Unit suffixes\nrecommended; e.g., \`2g' for 2 Gigabytes):" | ||||
msg_please_select_one_or_more_disks="Please select one or more disks to create a zpool:" | msg_please_select_one_or_more_disks="Please select one or more disks to create a zpool:" | ||||
msg_pool_name="Pool Name" | msg_pool_name="Pool Name" | ||||
msg_pool_name_cannot_be_empty="Pool name cannot be empty." | msg_pool_name_cannot_be_empty="Pool name cannot be empty." | ||||
msg_pool_name_help="Customize the name of the zpool to be created (Required)" | msg_pool_name_help="Customize the name of the zpool to be created (Required)" | ||||
msg_pool_type_disks="Pool Type/Disks:" | msg_pool_type_disks="Pool Type/Disks:" | ||||
msg_pool_type_disks_help="Choose type of ZFS Virtual Device and disks to use (Required)" | msg_pool_type_disks_help="Choose type of ZFS Virtual Device and disks to use (Required)" | ||||
▲ Show 20 Lines • Show All 451 Lines • ▼ Show 20 Lines | if ! f_isinteger "$index"; then | ||||
msg_error="$msg_error: $funcname" \ | msg_error="$msg_error: $funcname" \ | ||||
f_show_err "$msg_invalid_index_argument" "$index" | f_show_err "$msg_invalid_index_argument" "$index" | ||||
return $FAILURE | return $FAILURE | ||||
fi | fi | ||||
f_dprintf "$funcname: disk=[%s] index=[%s]" "$disk" "$index" | f_dprintf "$funcname: disk=[%s] index=[%s]" "$disk" "$index" | ||||
# Check for unknown partition scheme before proceeding further | # Check for unknown partition scheme before proceeding further | ||||
case "$ZFSBOOT_PARTITION_SCHEME" in | case "$ZFSBOOT_PARTITION_SCHEME" in | ||||
""|MBR|GPT) : known good ;; | ""|MBR|GPT|BSD) : known good ;; | ||||
*) | *) | ||||
f_dprintf "$funcname: %s is an unsupported partition scheme" \ | f_dprintf "$funcname: %s is an unsupported partition scheme" \ | ||||
"$ZFSBOOT_PARTITION_SCHEME" | "$ZFSBOOT_PARTITION_SCHEME" | ||||
msg_error="$msg_error: $funcname" f_show_err \ | msg_error="$msg_error: $funcname" f_show_err \ | ||||
"$msg_unsupported_partition_scheme" \ | "$msg_unsupported_partition_scheme" \ | ||||
"$ZFSBOOT_PARTITION_SCHEME" | "$ZFSBOOT_PARTITION_SCHEME" | ||||
return $FAILURE | return $FAILURE | ||||
esac | esac | ||||
Show All 39 Lines | f_eval_catch $funcname gpart "$GPART_BOOTCODE_PART" \ | ||||
/boot/pmbr /boot/gptzfsboot 1 $disk || | /boot/pmbr /boot/gptzfsboot 1 $disk || | ||||
return $FAILURE | return $FAILURE | ||||
# NB: zpool will use the `zfs#' GPT labels | # NB: zpool will use the `zfs#' GPT labels | ||||
bootpart=p2 swappart=p2 targetpart=p2 | bootpart=p2 swappart=p2 targetpart=p2 | ||||
[ ${swapsize:-0} -gt 0 ] && targetpart=p3 | [ ${swapsize:-0} -gt 0 ] && targetpart=p3 | ||||
# | # | ||||
# Prepare boot pool if enabled (e.g., for geli(8)) | # 3. Prepare boot pool if enabled (e.g., for geli(8)) | ||||
# | # | ||||
if [ "$ZFSBOOT_BOOT_POOL" ]; then | if [ "$ZFSBOOT_BOOT_POOL" ]; then | ||||
bootpart=p2 swappart=p3 targetpart=p3 | bootpart=p2 swappart=p3 targetpart=p3 | ||||
[ ${swapsize:-0} -gt 0 ] && targetpart=p4 | [ ${swapsize:-0} -gt 0 ] && targetpart=p4 | ||||
f_eval_catch $funcname gpart \ | f_eval_catch $funcname gpart \ | ||||
"$GPART_ADD_LABEL_WITH_SIZE" boot$index \ | "$GPART_ADD_LABEL_WITH_SIZE" boot$index \ | ||||
freebsd-zfs ${bootsize}b $disk || | freebsd-zfs ${bootsize}b $disk || | ||||
return $FAILURE | return $FAILURE | ||||
# Pedantically nuke any old labels | # Pedantically nuke any old labels | ||||
f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ | f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ | ||||
/dev/$disk$bootpart | /dev/$disk$bootpart | ||||
if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then | if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then | ||||
# Pedantically detach targetpart for later | # Pedantically detach targetpart for later | ||||
f_eval_catch -d $funcname geli \ | f_eval_catch -d $funcname geli \ | ||||
"$GELI_DETACH_F" \ | "$GELI_DETACH_F" \ | ||||
/dev/$disk$targetpart | /dev/$disk$targetpart | ||||
fi | fi | ||||
fi | fi | ||||
# | # | ||||
# 3. Add freebsd-swap partition labeled `swap#' | # 4. Add freebsd-swap partition labeled `swap#' | ||||
# | # | ||||
if [ ${swapsize:-0} -gt 0 ]; then | if [ ${swapsize:-0} -gt 0 ]; then | ||||
f_eval_catch $funcname gpart \ | f_eval_catch $funcname gpart \ | ||||
"$GPART_ADD_LABEL_WITH_SIZE" swap$index \ | "$GPART_ADD_LABEL_WITH_SIZE" swap$index \ | ||||
freebsd-swap ${swapsize}b $disk || | freebsd-swap ${swapsize}b $disk || | ||||
return $FAILURE | return $FAILURE | ||||
# Pedantically nuke any old labels on the swap | # Pedantically nuke any old labels on the swap | ||||
f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ | f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ | ||||
/dev/$disk$swappart | /dev/$disk$swappart | ||||
fi | fi | ||||
# | # | ||||
# 4. Add freebsd-zfs partition labeled `zfs#' for zroot | # 5. Add freebsd-zfs partition labeled `zfs#' for zroot | ||||
# | # | ||||
f_eval_catch $funcname gpart "$GPART_ADD_LABEL" \ | f_eval_catch $funcname gpart "$GPART_ADD_LABEL" \ | ||||
zfs$index freebsd-zfs $disk || return $FAILURE | zfs$index freebsd-zfs $disk || return $FAILURE | ||||
f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ | f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ | ||||
/dev/$disk$targetpart | /dev/$disk$targetpart | ||||
;; | ;; | ||||
BSD) f_dprintf "$funcname: Creating BSD layout..." | |||||
# | |||||
# 1. Create BSD layout and write boot sector | |||||
# | |||||
f_eval_catch $funcname gpart "$GPART_CREATE" bsd $disk || | |||||
return $FAILURE | |||||
bootpart=a swappart=b targetpart=a mbrindex=1 | |||||
# | |||||
# 2. Prepare boot pool if enabled (e.g., for geli(8)) | |||||
# | |||||
if [ "$ZFSBOOT_BOOT_POOL" ]; then | |||||
bootpart=a swappart=b targetpart=d mbrindex=4 | |||||
# | |||||
# 3. Create an unencrypted boot pool | |||||
# | |||||
f_eval_catch $funcname gpart \ | |||||
"$GPART_ADD_INDEX_WITH_SIZE" 1 \ | |||||
freebsd-zfs ${bootsize}b $disk || | |||||
return $FAILURE | |||||
# Pedantically detach bootpart | |||||
f_eval_catch -d $funcname geli \ | |||||
"$GELI_DETACH_F" \ | |||||
/dev/$disk$bootpart | |||||
# Pedantically nuke any old labels | |||||
f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ | |||||
/dev/$disk$bootpart | |||||
# | |||||
# 4. Add freebsd-swap partition | |||||
# | |||||
if [ ${swapsize:-0} -gt 0 ]; then | |||||
f_eval_catch $funcname gpart \ | |||||
"$GPART_ADD_INDEX_WITH_SIZE" 2 \ | |||||
freebsd-swap ${swapsize}b $disk || | |||||
return $FAILURE | |||||
# Pedantically nuke any old labels on the swap | |||||
f_eval_catch -d $funcname zpool \ | |||||
"$ZPOOL_LABELCLEAR_F" \ | |||||
/dev/$disk$swappart | |||||
fi | |||||
# | |||||
# 5. Add second freebsd-zfs partition for main pool | |||||
# | |||||
f_eval_catch $funcname gpart "$GPART_ADD_INDEX" \ | |||||
$mbrindex freebsd-zfs $disk || | |||||
return $FAILURE | |||||
# Pedantically detach targetpart | |||||
f_eval_catch -d $funcname geli \ | |||||
"$GELI_DETACH_F" \ | |||||
/dev/$disk$targetpart | |||||
f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ | |||||
/dev/$disk$targetpart | |||||
else | |||||
# | |||||
# 6. Create and boot off of the main pool | |||||
# | |||||
local partsize=$(( $disksize - $swapsize )) | |||||
f_eval_catch $funcname gpart \ | |||||
"$GPART_ADD_INDEX_WITH_SIZE" $mbrindex \ | |||||
freebsd-zfs ${partsize}b $disk || | |||||
return $FAILURE | |||||
# Pedantically nuke any old labels | |||||
f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ | |||||
/dev/$disk$bootpart | |||||
# | |||||
# 7. There is no partition after this, so autosize swap | |||||
# | |||||
if [ ${swapsize:-0} -gt 0 ]; then | |||||
f_eval_catch $funcname gpart \ | |||||
"$GPART_ADD_INDEX" 2 \ | |||||
freebsd-swap $disk || | |||||
return $FAILURE | |||||
# Pedantically nuke any old labels on the swap | |||||
f_eval_catch -d $funcname zpool \ | |||||
"$ZPOOL_LABELCLEAR_F" \ | |||||
/dev/$disk$swappart | |||||
fi | |||||
fi | |||||
;; | |||||
MBR) f_dprintf "$funcname: Creating MBR layout..." | MBR) f_dprintf "$funcname: Creating MBR layout..." | ||||
# | # | ||||
# 1. Create MBR layout (no labels) | # 1. Create MBR layout (no labels) | ||||
# | # | ||||
f_eval_catch $funcname gpart "$GPART_CREATE" mbr $disk || | f_eval_catch $funcname gpart "$GPART_CREATE" mbr $disk || | ||||
return $FAILURE | return $FAILURE | ||||
f_eval_catch $funcname gpart "$GPART_BOOTCODE" /boot/mbr \ | |||||
$disk || return $FAILURE | |||||
# | # | ||||
# 2. Add freebsd slice with all available space | # 2. Add freebsd slice with all available space | ||||
# | # | ||||
f_eval_catch $funcname gpart "$GPART_ADD" freebsd $disk || | f_eval_catch $funcname gpart "$GPART_ADD" freebsd $disk || | ||||
return $FAILURE | return $FAILURE | ||||
f_eval_catch $funcname gpart "$GPART_SET_ACTIVE" 1 $disk || | f_eval_catch $funcname gpart "$GPART_SET_ACTIVE" 1 $disk || | ||||
return $FAILURE | return $FAILURE | ||||
# Pedantically nuke any old labels | # Pedantically nuke any old labels | ||||
f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ | f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ | ||||
/dev/${disk}s1 | /dev/${disk}s1 | ||||
# Pedantically nuke any old scheme | # Pedantically nuke any old scheme | ||||
f_eval_catch -d $funcname gpart "$GPART_DESTROY_F" ${disk}s1 | f_eval_catch -d $funcname gpart "$GPART_DESTROY_F" ${disk}s1 | ||||
# | # | ||||
# 3. Write BSD scheme to the freebsd slice | # 3. Write BSD scheme to the freebsd slice | ||||
# | # | ||||
f_eval_catch $funcname gpart "$GPART_CREATE" BSD ${disk}s1 || | f_eval_catch $funcname gpart "$GPART_CREATE" BSD ${disk}s1 || | ||||
return $FAILURE | return $FAILURE | ||||
# NB: zpool will use s1a (no labels) | bootpart=s1a swappart=s1b targetpart=s1a mbrindex=1 | ||||
bootpart=s1a swappart=s1b targetpart=s1d mbrindex=4 | |||||
# | # | ||||
# Always prepare a boot pool on MBR | # 4. Prepare boot pool if enabled (e.g., for geli(8)) | ||||
# | # | ||||
ZFSBOOT_BOOT_POOL=1 | if [ "$ZFSBOOT_BOOT_POOL" ]; then | ||||
bootpart=s1a swappart=s1b targetpart=s1d mbrindex=4 | |||||
# | |||||
# 5. Create an unencrypted boot pool | |||||
# | |||||
f_eval_catch $funcname gpart \ | f_eval_catch $funcname gpart \ | ||||
"$GPART_ADD_INDEX_WITH_SIZE" \ | "$GPART_ADD_INDEX_WITH_SIZE" 1 \ | ||||
1 freebsd-zfs ${bootsize}b ${disk}s1 || | freebsd-zfs ${bootsize}b $disk || | ||||
return $FAILURE | return $FAILURE | ||||
# Pedantically nuke any old labels | # Pedantically nuke any old labels | ||||
f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ | f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ | ||||
/dev/$disk$bootpart | /dev/$disk$bootpart | ||||
if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then | |||||
# Pedantically detach targetpart for later | # Pedantically detach targetpart for later | ||||
f_eval_catch -d $funcname geli \ | f_eval_catch -d $funcname geli \ | ||||
"$GELI_DETACH_F" \ | "$GELI_DETACH_F" \ | ||||
/dev/$disk$targetpart | /dev/$disk$bootpart | ||||
fi | |||||
# | # | ||||
# 4. Add freebsd-swap partition | # 6. Add freebsd-swap partition | ||||
# | # | ||||
if [ ${swapsize:-0} -gt 0 ]; then | if [ ${swapsize:-0} -gt 0 ]; then | ||||
f_eval_catch $funcname gpart \ | f_eval_catch $funcname gpart \ | ||||
"$GPART_ADD_INDEX_WITH_SIZE" 2 \ | "$GPART_ADD_INDEX_WITH_SIZE" 2 \ | ||||
freebsd-swap ${swapsize}b ${disk}s1 || | freebsd-swap ${swapsize}b \ | ||||
return $FAILURE | ${disk}s1 || return $FAILURE | ||||
# Pedantically nuke any old labels on the swap | # Pedantically nuke any old labels on the swap | ||||
f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ | f_eval_catch -d $funcname zpool \ | ||||
/dev/${disk}s1b | "$ZPOOL_LABELCLEAR_F" \ | ||||
/dev/$disk$swappart | |||||
fi | fi | ||||
# | # | ||||
# 5. Add freebsd-zfs partition for zroot | # 7. Add second freebsd-zfs partition for main pool | ||||
# | # | ||||
f_eval_catch $funcname gpart "$GPART_ADD_INDEX" \ | f_eval_catch $funcname gpart "$GPART_ADD_INDEX" \ | ||||
$mbrindex freebsd-zfs ${disk}s1 || return $FAILURE | $mbrindex freebsd-zfs ${disk}s1 || | ||||
return $FAILURE | |||||
# Pedantically detach targetpart | |||||
f_eval_catch -d $funcname geli \ | |||||
"$GELI_DETACH_F" \ | |||||
/dev/$disk$targetpart | |||||
f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ | f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ | ||||
/dev/$disk$targetpart # Pedantic | /dev/$disk$targetpart # Pedantic | ||||
f_eval_catch $funcname dd "$DD_WITH_OPTIONS" \ | |||||
/boot/zfsboot /dev/${disk}s1 count=1 || | else | ||||
# | |||||
# 8. Create and boot off of the main pool | |||||
# | |||||
local partsize=$(( $disksize - $swapsize )) | |||||
f_eval_catch $funcname gpart \ | |||||
"$GPART_ADD_INDEX_WITH_SIZE" $mbrindex \ | |||||
freebsd-zfs ${partsize}b ${disk}s1 || | |||||
return $FAILURE | return $FAILURE | ||||
# Pedantically nuke any old labels | |||||
f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ | |||||
/dev/$disk$bootpart | |||||
# | |||||
# 9. There is no partition after this, so autosize swap | |||||
# | |||||
if [ ${swapsize:-0} -gt 0 ]; then | |||||
f_eval_catch $funcname gpart \ | |||||
"$GPART_ADD_INDEX" 2 \ | |||||
freebsd-swap ${disk}s1 || | |||||
return $FAILURE | |||||
# Pedantically nuke any old labels on the swap | |||||
f_eval_catch -d $funcname zpool \ | |||||
"$ZPOOL_LABELCLEAR_F" \ | |||||
/dev/$disk$swappart | |||||
fi | |||||
fi | |||||
# | |||||
# 10. Install bootcode | |||||
# | |||||
f_eval_catch $funcname gpart "$GPART_BOOTCODE" /boot/mbr \ | |||||
$disk || return $FAILURE | |||||
;; | ;; | ||||
esac # $ZFSBOOT_PARTITION_SCHEME | esac # $ZFSBOOT_PARTITION_SCHEME | ||||
# Update fstab(5) | # Update fstab(5) | ||||
if [ "$isswapmirror" ]; then | if [ "$isswapmirror" ]; then | ||||
# This is not the first disk in the mirror, do nothing | # This is not the first disk in the mirror, do nothing | ||||
true | |||||
elif [ "$ZFSBOOT_SWAP_ENCRYPTION" -a "$ZFSBOOT_SWAP_MIRROR" ]; then | elif [ "$ZFSBOOT_SWAP_ENCRYPTION" -a "$ZFSBOOT_SWAP_MIRROR" ]; then | ||||
f_eval_catch $funcname printf "$PRINTF_FSTAB" \ | f_eval_catch $funcname printf "$PRINTF_FSTAB" \ | ||||
/dev/mirror/swap.eli none swap sw 0 0 \ | /dev/mirror/swap.eli none swap sw 0 0 \ | ||||
$BSDINSTALL_TMPETC/fstab || | $BSDINSTALL_TMPETC/fstab || | ||||
return $FAILURE | return $FAILURE | ||||
isswapmirror=1 | isswapmirror=1 | ||||
elif [ "$ZFSBOOT_SWAP_MIRROR" ]; then | elif [ "$ZFSBOOT_SWAP_MIRROR" ]; then | ||||
f_eval_catch $funcname printf "$PRINTF_FSTAB" \ | f_eval_catch $funcname printf "$PRINTF_FSTAB" \ | ||||
▲ Show 20 Lines • Show All 311 Lines • ▼ Show 20 Lines | if [ "$ZFSBOOT_BOOT_POOL" ]; then | ||||
$disk$bootpart.nop | $disk$bootpart.nop | ||||
fi | fi | ||||
if [ ! "$ZFSBOOT_GELI_ENCRYPTION" ]; then | if [ ! "$ZFSBOOT_GELI_ENCRYPTION" ]; then | ||||
f_eval_catch -d $funcname gnop "$GNOP_DESTROY" \ | f_eval_catch -d $funcname gnop "$GNOP_DESTROY" \ | ||||
$disk$targetpart.nop | $disk$targetpart.nop | ||||
fi | fi | ||||
done | done | ||||
# MBR boot loader touch-up | # write remainder of boot loader for MBR and BSD | ||||
if [ "$ZFSBOOT_PARTITION_SCHEME" = "MBR" ]; then | if [ "$ZFSBOOT_PARTITION_SCHEME" = "MBR" ]; then | ||||
f_dprintf "$funcname: Updating MBR boot loader on disks..." | f_dprintf "$funcname: Updating MBR boot loader on disks..." | ||||
# Stick the ZFS boot loader in the "convienient hole" after | # Stick the ZFS boot loader in the "convienient hole" after | ||||
# the ZFS internal metadata | # the ZFS internal metadata | ||||
for disk in $disks; do | for disk in $disks; do | ||||
f_eval_catch $funcname dd "$DD_WITH_OPTIONS" \ | f_eval_catch $funcname dd "$DD_WITH_OPTIONS" \ | ||||
/boot/zfsboot /dev/$disk$bootpart \ | /boot/zfsboot /dev/$disk$bootpart \ | ||||
"skip=1 seek=1024" || return $FAILURE | "skip=1 seek=1024" || return $FAILURE | ||||
f_eval_catch $funcname dd "$DD_WITH_OPTIONS" \ | |||||
/boot/zfsboot /dev/${disk}s1 count=1 || | |||||
return $FAILURE | |||||
done | done | ||||
elif [ "$ZFSBOOT_PARTITION_SCHEME" = "BSD" ]; then | |||||
f_dprintf "$funcname: Updating BSD boot loader on disks..." | |||||
# Stick the ZFS boot loader in the "convienient hole" after | |||||
# the ZFS internal metadata | |||||
# Install the first bit last, else odd things happen | |||||
for disk in $disks; do | |||||
f_eval_catch $funcname dd "$DD_WITH_OPTIONS" \ | |||||
/boot/zfsboot /dev/$disk$bootpart \ | |||||
"skip=1 seek=1024" || return $FAILURE | |||||
f_eval_catch $funcname dd "$DD_WITH_OPTIONS" \ | |||||
/boot/zfsboot /dev/${disk} count=1 || | |||||
return $FAILURE | |||||
done | |||||
fi | fi | ||||
# Re-import the ZFS pool(s) | # Re-import the ZFS pool(s) | ||||
f_dprintf "$funcname: Re-importing ZFS pool(s)..." | f_dprintf "$funcname: Re-importing ZFS pool(s)..." | ||||
f_eval_catch $funcname zpool "$ZPOOL_IMPORT_WITH_OPTIONS" \ | f_eval_catch $funcname zpool "$ZPOOL_IMPORT_WITH_OPTIONS" \ | ||||
"-o altroot=\"$BSDINSTALL_CHROOT\"" "$zroot_name" || | "-o altroot=\"$BSDINSTALL_CHROOT\"" "$zroot_name" || | ||||
return $FAILURE | return $FAILURE | ||||
if [ "$ZFSBOOT_BOOT_POOL" ]; then | if [ "$ZFSBOOT_BOOT_POOL" ]; then | ||||
▲ Show 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | then | ||||
minsize=$swapsize teeny_disks= | minsize=$swapsize teeny_disks= | ||||
[ "$ZFSBOOT_BOOT_POOL" ] && | [ "$ZFSBOOT_BOOT_POOL" ] && | ||||
minsize=$(( $minsize + $bootsize )) | minsize=$(( $minsize + $bootsize )) | ||||
for disk in $ZFSBOOT_DISKS; do | for disk in $ZFSBOOT_DISKS; do | ||||
debug= f_device_find -1 \ | debug= f_device_find -1 \ | ||||
$disk $DEVICE_TYPE_DISK device | $disk $DEVICE_TYPE_DISK device | ||||
$device get capacity disksize || continue | $device get capacity disksize || continue | ||||
[ ${disksize:-0} -ge 0 ] || disksize=0 | [ ${disksize:-0} -ge 0 ] || disksize=0 | ||||
disksize=$(( $disksize - $minsize )) | usablesize=$(( $disksize - $minsize )) | ||||
[ $disksize -lt $minsize ] && | [ $usablesize -lt $minsize ] && | ||||
teeny_disks="$teeny_disks $disk" | teeny_disks="$teeny_disks $disk" | ||||
done | done | ||||
if [ "$teeny_disks" ]; then | if [ "$teeny_disks" ]; then | ||||
f_dprintf "swapsize=[%s] bootsize[%s] %s" \ | f_dprintf "swapsize=[%s] bootsize[%s] %s" \ | ||||
"$ZFSBOOT_SWAP_SIZE" \ | "$ZFSBOOT_SWAP_SIZE" \ | ||||
"$ZFSBOOT_BOOT_POOL_SIZE" \ | "$ZFSBOOT_BOOT_POOL_SIZE" \ | ||||
"minsize=[$minsize]" | "minsize=[$minsize]" | ||||
f_dprintf "These disks are too small: %s" \ | f_dprintf "These disks are too small: %s" \ | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | ?" $msg_encrypt_disks") | ||||
if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then | if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then | ||||
ZFSBOOT_GELI_ENCRYPTION= | ZFSBOOT_GELI_ENCRYPTION= | ||||
else | else | ||||
ZFSBOOT_GNOP_4K_FORCE_ALIGN=1 | ZFSBOOT_GNOP_4K_FORCE_ALIGN=1 | ||||
ZFSBOOT_GELI_ENCRYPTION=1 | ZFSBOOT_GELI_ENCRYPTION=1 | ||||
fi | fi | ||||
;; | ;; | ||||
?" $msg_partition_scheme") | ?" $msg_partition_scheme") | ||||
# Toggle between GPT and MBR | # Toggle between GPT, MBR, and BSD | ||||
if [ "$ZFSBOOT_PARTITION_SCHEME" = GPT ]; then | if [ "$ZFSBOOT_PARTITION_SCHEME" = GPT ]; then | ||||
ZFSBOOT_PARTITION_SCHEME=MBR | ZFSBOOT_PARTITION_SCHEME=MBR | ||||
elif [ "$ZFSBOOT_PARTITION_SCHEME" = MBR ]; then | |||||
ZFSBOOT_PARTITION_SCHEME=BSD | |||||
else | else | ||||
ZFSBOOT_PARTITION_SCHEME=GPT | ZFSBOOT_PARTITION_SCHEME=GPT | ||||
fi | fi | ||||
;; | ;; | ||||
?" $msg_swap_size") | ?" $msg_swap_size") | ||||
# Prompt the user to input/change the swap size for each disk | # Prompt the user to input/change the swap size for each disk | ||||
f_dialog_input input \ | f_dialog_input input \ | ||||
"$msg_please_enter_amount_of_swap_space" \ | "$msg_please_enter_amount_of_swap_space" \ | ||||
Show All 27 Lines |