Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bsdinstall/scripts/zfsboot
Show All 39 Lines | |||||
############################################################ CONFIGURATION | ############################################################ CONFIGURATION | ||||
# | # | ||||
# Default name of the boot-pool | # Default name of the boot-pool | ||||
# | # | ||||
: ${ZFSBOOT_POOL_NAME:=zroot} | : ${ZFSBOOT_POOL_NAME:=zroot} | ||||
# | # | ||||
# Default pool size is optional | |||||
# | |||||
: ${ZFSBOOT_POOL_SIZE=} | |||||
# | |||||
# Default options to use when creating zroot pool | # Default options to use when creating zroot pool | ||||
# | # | ||||
: ${ZFSBOOT_POOL_CREATE_OPTIONS:=-O compress=lz4 -O atime=off} | : ${ZFSBOOT_POOL_CREATE_OPTIONS:=-O compress=lz4 -O atime=off} | ||||
# | # | ||||
# Default name for the boot environment parent dataset | # Default name for the boot environment parent dataset | ||||
# | # | ||||
: ${ZFSBOOT_BEROOT_NAME:=ROOT} | : ${ZFSBOOT_BEROOT_NAME:=ROOT} | ||||
▲ Show 20 Lines • Show All 201 Lines • ▼ Show 20 Lines | |||||
msg_geli_password="Enter a strong passphrase, used to protect your encryption keys. You will be required to enter this passphrase each time the system is booted" | msg_geli_password="Enter a strong passphrase, used to protect your encryption keys. You will be required to enter this passphrase each time the system is booted" | ||||
msg_geli_setup="Initializing encryption on selected disks,\n this will take several seconds per disk" | msg_geli_setup="Initializing encryption on selected disks,\n this will take several seconds per disk" | ||||
msg_install="Install" | msg_install="Install" | ||||
msg_install_desc="Proceed with Installation" | msg_install_desc="Proceed with Installation" | ||||
msg_install_help="Create ZFS boot pool with displayed options" | msg_install_help="Create ZFS boot pool with displayed options" | ||||
msg_invalid_boot_pool_size="Invalid boot pool size \`%s'" | msg_invalid_boot_pool_size="Invalid boot pool size \`%s'" | ||||
msg_invalid_disk_argument="Invalid disk argument \`%s'" | msg_invalid_disk_argument="Invalid disk argument \`%s'" | ||||
msg_invalid_index_argument="Invalid index argument \`%s'" | msg_invalid_index_argument="Invalid index argument \`%s'" | ||||
msg_invalid_pool_size="Invalid pool size \`%s'" | |||||
msg_invalid_swap_size="Invalid swap size \`%s'" | msg_invalid_swap_size="Invalid swap size \`%s'" | ||||
msg_invalid_virtual_device_type="Invalid Virtual Device type \`%s'" | msg_invalid_virtual_device_type="Invalid Virtual Device type \`%s'" | ||||
msg_last_chance_are_you_sure="Last Chance! Are you sure you want to destroy\nthe current contents of the following disks:\n\n %s" | msg_last_chance_are_you_sure="Last Chance! Are you sure you want to destroy\nthe current contents of the following disks:\n\n %s" | ||||
msg_last_chance_are_you_sure_color='\\ZrLast Chance!\\ZR Are you \\Z1sure\\Zn you want to \\Zr\\Z1destroy\\Zn\nthe current contents of the following disks:\n\n %s' | msg_last_chance_are_you_sure_color='\\ZrLast Chance!\\ZR Are you \\Z1sure\\Zn you want to \\Zr\\Z1destroy\\Zn\nthe current contents of the following disks:\n\n %s' | ||||
msg_mirror_desc="Mirror - n-Way Mirroring" | msg_mirror_desc="Mirror - n-Way Mirroring" | ||||
msg_mirror_help="[2+ Disks] Mirroring provides the best performance, but the least storage" | msg_mirror_help="[2+ Disks] Mirroring provides the best performance, but the least storage" | ||||
msg_missing_disk_arguments="missing disk arguments" | msg_missing_disk_arguments="missing disk arguments" | ||||
msg_missing_one_or_more_scripted_disks="Missing one or more scripted disks!" | msg_missing_one_or_more_scripted_disks="Missing one or more scripted disks!" | ||||
▲ Show 20 Lines • Show All 665 Lines • ▼ Show 20 Lines | if [ ${swapsize:-0} -gt 0 ]; then | ||||
# 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 | # 4. Add freebsd-zfs partition labeled `zfs#' for zroot | ||||
# | # | ||||
if [ "$ZFSBOOT_POOL_SIZE" ]; then | |||||
f_eval_catch $funcname gpart "$GPART_ADD_ALIGN_LABEL_WITH_SIZE" \ | |||||
"$align_big" zfs$index freebsd-zfs $ZFSBOOT_POOL_SIZE $disk || | |||||
return $FAILURE | |||||
else | |||||
f_eval_catch $funcname gpart "$GPART_ADD_ALIGN_LABEL" \ | f_eval_catch $funcname gpart "$GPART_ADD_ALIGN_LABEL" \ | ||||
"$align_big" zfs$index freebsd-zfs $disk || | "$align_big" zfs$index freebsd-zfs $disk || | ||||
return $FAILURE | return $FAILURE | ||||
fi | |||||
f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ | f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ | ||||
/dev/$disk$targetpart | /dev/$disk$targetpart | ||||
;; | ;; | ||||
MBR) f_dprintf "$funcname: Creating MBR layout..." | MBR) f_dprintf "$funcname: Creating MBR layout..." | ||||
# | # | ||||
# Enable boot pool if encryption is desired | # Enable boot pool if encryption is desired | ||||
# | # | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | if [ ${swapsize:-0} -gt 0 ]; then | ||||
# 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}s1b | /dev/${disk}s1b | ||||
fi | fi | ||||
# | # | ||||
# 5. Add freebsd-zfs partition for zroot | # 5. Add freebsd-zfs partition for zroot | ||||
# | # | ||||
if [ "$ZFSBOOT_POOL_SIZE" ]; then | |||||
f_eval_catch $funcname gpart "$GPART_ADD_ALIGN_INDEX_WITH_SIZE" \ | |||||
"$align_small" $mbrindex freebsd-zfs $ZFSBOOT_POOL_SIZE ${disk}s1 || return $FAILURE | |||||
else | |||||
f_eval_catch $funcname gpart "$GPART_ADD_ALIGN_INDEX" \ | f_eval_catch $funcname gpart "$GPART_ADD_ALIGN_INDEX" \ | ||||
"$align_small" $mbrindex freebsd-zfs ${disk}s1 || | "$align_small" $mbrindex freebsd-zfs ${disk}s1 || return $FAILURE | ||||
return $FAILURE | fi | ||||
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" \ | f_eval_catch $funcname dd "$DD_WITH_OPTIONS" \ | ||||
/boot/zfsboot /dev/${disk}s1 count=1 || | /boot/zfsboot /dev/${disk}s1 count=1 || | ||||
return $FAILURE | return $FAILURE | ||||
;; | ;; | ||||
esac # $ZFSBOOT_PARTITION_SCHEME | esac # $ZFSBOOT_PARTITION_SCHEME | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | zfs_create_boot() | ||||
f_eval_catch $funcname printf "$PRINTF_FSTAB" \ | f_eval_catch $funcname printf "$PRINTF_FSTAB" \ | ||||
"# Device" Mountpoint FStype Options Dump "Pass#" \ | "# Device" Mountpoint FStype Options Dump "Pass#" \ | ||||
$BSDINSTALL_TMPETC/fstab || return $FAILURE | $BSDINSTALL_TMPETC/fstab || return $FAILURE | ||||
# | # | ||||
# Expand SI units in desired sizes | # Expand SI units in desired sizes | ||||
# | # | ||||
f_dprintf "$funcname: Expanding supplied size values..." | f_dprintf "$funcname: Expanding supplied size values..." | ||||
local swapsize bootsize | local swapsize bootsize poolsize | ||||
if ! f_expand_number "$ZFSBOOT_SWAP_SIZE" swapsize; then | if ! f_expand_number "$ZFSBOOT_SWAP_SIZE" swapsize; then | ||||
f_dprintf "$funcname: Invalid swap size \`%s'" \ | f_dprintf "$funcname: Invalid swap size \`%s'" \ | ||||
"$ZFSBOOT_SWAP_SIZE" | "$ZFSBOOT_SWAP_SIZE" | ||||
f_show_err "$msg_invalid_swap_size" "$ZFSBOOT_SWAP_SIZE" | f_show_err "$msg_invalid_swap_size" "$ZFSBOOT_SWAP_SIZE" | ||||
return $FAILURE | return $FAILURE | ||||
fi | fi | ||||
if ! f_expand_number "$ZFSBOOT_BOOT_POOL_SIZE" bootsize; then | if ! f_expand_number "$ZFSBOOT_BOOT_POOL_SIZE" bootsize; then | ||||
f_dprintf "$funcname: Invalid boot pool size \`%s'" \ | f_dprintf "$funcname: Invalid boot pool size \`%s'" \ | ||||
"$ZFSBOOT_BOOT_POOL_SIZE" | "$ZFSBOOT_BOOT_POOL_SIZE" | ||||
f_show_err "$msg_invalid_boot_pool_size" \ | f_show_err "$msg_invalid_boot_pool_size" \ | ||||
"$ZFSBOOT_BOOT_POOL_SIZE" | "$ZFSBOOT_BOOT_POOL_SIZE" | ||||
return $FAILURE | return $FAILURE | ||||
fi | fi | ||||
if [ "$ZFSBOOT_POOL_SIZE" ]; then | |||||
if ! f_expand_number "$ZFSBOOT_POOL_SIZE" poolsize; then | |||||
f_dprintf "$funcname: Invalid pool size \`%s'" \ | |||||
"$ZFSBOOT_POOL_SIZE" | |||||
f_show_err "$msg_invalid_pool_size" \ | |||||
"$ZFSBOOT_POOL_SIZE" | |||||
fi | |||||
f_dprintf "$funcname: ZFSBOOT_POOL_SIZE=[%s] poolsize=[%s]" \ | |||||
"$ZFSBOOT_POOL_SIZE" "$poolsize" | |||||
fi | |||||
f_dprintf "$funcname: ZFSBOOT_SWAP_SIZE=[%s] swapsize=[%s]" \ | f_dprintf "$funcname: ZFSBOOT_SWAP_SIZE=[%s] swapsize=[%s]" \ | ||||
"$ZFSBOOT_SWAP_SIZE" "$swapsize" | "$ZFSBOOT_SWAP_SIZE" "$swapsize" | ||||
f_dprintf "$funcname: ZFSBOOT_BOOT_POOL_SIZE=[%s] bootsize=[%s]" \ | f_dprintf "$funcname: ZFSBOOT_BOOT_POOL_SIZE=[%s] bootsize=[%s]" \ | ||||
"$ZFSBOOT_BOOT_POOL_SIZE" "$bootsize" | "$ZFSBOOT_BOOT_POOL_SIZE" "$bootsize" | ||||
# | # | ||||
# Destroy the pool in-case this is our second time 'round (case of | # Destroy the pool in-case this is our second time 'round (case of | ||||
# failure and installer presented ``Retry'' option to come back). | # failure and installer presented ``Retry'' option to come back). | ||||
▲ Show 20 Lines • Show All 483 Lines • ▼ Show 20 Lines | ">>> $msg_install") | ||||
# NB: dialog_menu_layout supports running non-interactively | # NB: dialog_menu_layout supports running non-interactively | ||||
dialog_menu_layout || continue | dialog_menu_layout || continue | ||||
# Make sure each disk will have room for ZFS | # Make sure each disk will have room for ZFS | ||||
if f_expand_number "$ZFSBOOT_SWAP_SIZE" swapsize && | if f_expand_number "$ZFSBOOT_SWAP_SIZE" swapsize && | ||||
f_expand_number "$ZFSBOOT_BOOT_POOL_SIZE" bootsize && | f_expand_number "$ZFSBOOT_BOOT_POOL_SIZE" bootsize && | ||||
f_expand_number "1g" zpoolmin | f_expand_number "1g" zpoolmin | ||||
then | then | ||||
minsize=$(( $swapsize + $zpoolmin )) teeny_disks= | minsize=$swapsize teeny_disks= | ||||
if [ "$ZFSBOOT_POOL_SIZE" ]; then | |||||
f_expand_number "$ZFSBOOT_POOL_SIZE" poolsize | |||||
minsize=$(( $minsize + $poolsize )) | |||||
fi | |||||
[ "$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 -lt $minsize ] && | [ $disksize -lt $minsize ] && | ||||
▲ Show 20 Lines • Show All 146 Lines • Show Last 20 Lines |