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} | ||||
# | # | ||||
# How much space to allocate for the zroot partition | |||||
# MAX means use all the leftover space | |||||
# NOTE: Value passed to gpart(8); which supports SI unit suffixes. | |||||
# | |||||
: ${ZFSBOOT_ZROOT_POOL_SIZE:=MAX} | |||||
# | |||||
# 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_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_swap_size="Invalid swap size \`%s'" | msg_invalid_swap_size="Invalid swap size \`%s'" | ||||
msg_invalid_zroot_pool_size="Invalid zroot pool 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!" | ||||
msg_no="NO" | msg_no="NO" | ||||
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_odd_disk_selected="An even number of disks must be selected to create a RAID 1+0. (%u selected)" | msg_odd_disk_selected="An even number of disks must be selected to create a RAID 1+0. (%u selected)" | ||||
msg_ok="OK" | msg_ok="OK" | ||||
msg_partition_scheme="Partition Scheme" | msg_partition_scheme="Partition Scheme" | ||||
msg_partition_scheme_help="Select partitioning scheme. GPT is recommended." | msg_partition_scheme_help="Select partitioning scheme. GPT is recommended." | ||||
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_zroot_pool_space="Please enter amount of zroot pool 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_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_zroot_pool_size="ZROOT pool Size" | |||||
msg_zroot_pool_size_help="Customize how much space is allocated for the zroot pool" | |||||
msg_zroot_pool_toosmall="The selected pool size (%s) is to small. Please enter a value greater than 100MB or enter MAX for using full remainder" | |||||
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)" | ||||
msg_processing_selection="Processing selection..." | msg_processing_selection="Processing selection..." | ||||
msg_raid10_desc="RAID 1+0 - n x 2-Way Mirrors" | msg_raid10_desc="RAID 1+0 - n x 2-Way Mirrors" | ||||
msg_raid10_help="[4+ Disks] Striped Mirrors provides the best performance, but the least storage" | msg_raid10_help="[4+ Disks] Striped Mirrors provides the best performance, but the least storage" | ||||
msg_raidz1_desc="RAID-Z1 - Single Redundant RAID" | msg_raidz1_desc="RAID-Z1 - Single Redundant RAID" | ||||
msg_raidz1_help="[3+ Disks] Withstand failure of 1 disk. Recommended for: 3, 5 or 9 disks" | msg_raidz1_help="[3+ Disks] Withstand failure of 1 disk. Recommended for: 3, 5 or 9 disks" | ||||
msg_raidz2_desc="RAID-Z2 - Double Redundant RAID" | msg_raidz2_desc="RAID-Z2 - Double Redundant RAID" | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | 'T $msg_pool_type_disks' | ||||
'$ZFSBOOT_VDEV_TYPE: $n $disks_grammar' | '$ZFSBOOT_VDEV_TYPE: $n $disks_grammar' | ||||
'$msg_pool_type_disks_help' | '$msg_pool_type_disks_help' | ||||
'- $msg_rescan_devices' '*' | '- $msg_rescan_devices' '*' | ||||
'$msg_rescan_devices_help' | '$msg_rescan_devices_help' | ||||
'- $msg_disk_info' '*' | '- $msg_disk_info' '*' | ||||
'$msg_disk_info_help' | '$msg_disk_info_help' | ||||
'N $msg_pool_name' '$ZFSBOOT_POOL_NAME' | 'N $msg_pool_name' '$ZFSBOOT_POOL_NAME' | ||||
'$msg_pool_name_help' | '$msg_pool_name_help' | ||||
'Z $msg_zroot_pool_size' | |||||
'$ZFSBOOT_ZROOT_POOL_SIZE' | |||||
'$msg_zroot_pool_size_help' | |||||
'4 $msg_force_4k_sectors' | '4 $msg_force_4k_sectors' | ||||
'$force4k' | '$force4k' | ||||
'$msg_force_4k_sectors_help' | '$msg_force_4k_sectors_help' | ||||
'E $msg_encrypt_disks' '$usegeli' | 'E $msg_encrypt_disks' '$usegeli' | ||||
'$msg_encrypt_disks_help' | '$msg_encrypt_disks_help' | ||||
'P $msg_partition_scheme' | 'P $msg_partition_scheme' | ||||
'$ZFSBOOT_PARTITION_SCHEME ($ZFSBOOT_BOOT_TYPE)' | '$ZFSBOOT_PARTITION_SCHEME ($ZFSBOOT_BOOT_TYPE)' | ||||
'$msg_partition_scheme_help' | '$msg_partition_scheme_help' | ||||
▲ Show 20 Lines • Show All 364 Lines • ▼ Show 20 Lines | |||||
# zfs_create_diskpart $disk $index | # zfs_create_diskpart $disk $index | ||||
# | # | ||||
# For each block device to be used in the zpool, rather than just create the | # For each block device to be used in the zpool, rather than just create the | ||||
# zpool with the raw block devices (e.g., da0, da1, etc.) we create partitions | # zpool with the raw block devices (e.g., da0, da1, etc.) we create partitions | ||||
# so we can have some real swap. This also provides wiggle room incase your | # so we can have some real swap. This also provides wiggle room incase your | ||||
# replacement drivers do not have the exact same sector counts. | # replacement drivers do not have the exact same sector counts. | ||||
# | # | ||||
# NOTE: $swapsize and $bootsize should be defined by the calling function. | # NOTE: $swapsize and $zrootsize, $bootsize should be defined by the calling | ||||
# function. | |||||
# NOTE: Sets $bootpart and $targetpart for the calling function. | # NOTE: Sets $bootpart and $targetpart for the calling function. | ||||
# | # | ||||
zfs_create_diskpart() | zfs_create_diskpart() | ||||
{ | { | ||||
local funcname=zfs_create_diskpart | local funcname=zfs_create_diskpart | ||||
local disk="$1" index="$2" | local disk="$1" index="$2" | ||||
# Check arguments | # Check arguments | ||||
▲ Show 20 Lines • Show All 178 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 [ x"$zrootsize"x = xx -o x"$zrootsize"x = x"MAX"x]; then | |||||
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" zfstest$index freebsd-zfs $disk || | ||||
return $FAILURE | return $FAILURE | ||||
else | |||||
f_eval_catch $funcname gpart \ | |||||
"$GPART_ADD_ALIGN_LABEL_WITH_SIZE" \ | |||||
"$align_big" zfstest$index freebsd-zfs \ | |||||
${zrootsize}b $disk || | |||||
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 | ||||
;; | ;; # END GPT | ||||
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 | ||||
# | # | ||||
[ "$ZFSBOOT_GELI_ENCRYPTION" ] && ZFSBOOT_BOOT_POOL=1 | [ "$ZFSBOOT_GELI_ENCRYPTION" ] && ZFSBOOT_BOOT_POOL=1 | ||||
# | # | ||||
# 1. Create MBR layout (no labels) | # 1. Create MBR layout (no labels) | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | MBR) f_dprintf "$funcname: Creating MBR layout..." | ||||
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 | ||||
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 | ||||
;; | ;; # END MBR | ||||
esac # $ZFSBOOT_PARTITION_SCHEME | esac # $ZFSBOOT_PARTITION_SCHEME | ||||
# Update fstab(5) | # Update fstab(5) | ||||
local swapsize | local swapsize | ||||
f_expand_number "$ZFSBOOT_SWAP_SIZE" swapsize | f_expand_number "$ZFSBOOT_SWAP_SIZE" swapsize | ||||
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 | ||||
▲ Show 20 Lines • Show All 644 Lines • ▼ Show 20 Lines | while :; do | ||||
"- $msg_rescan_devices") f_device_rescan ;; | "- $msg_rescan_devices") f_device_rescan ;; | ||||
"- $msg_disk_info") dialog_menu_diskinfo ;; | "- $msg_disk_info") dialog_menu_diskinfo ;; | ||||
?" $msg_pool_name") | ?" $msg_pool_name") | ||||
# Prompt the user to input/change the name for the new pool | # Prompt the user to input/change the name for the new pool | ||||
f_dialog_input input \ | f_dialog_input input \ | ||||
"$msg_please_enter_a_name_for_your_zpool" \ | "$msg_please_enter_a_name_for_your_zpool" \ | ||||
"$ZFSBOOT_POOL_NAME" && | "$ZFSBOOT_POOL_NAME" && | ||||
ZFSBOOT_POOL_NAME="$input" | ZFSBOOT_POOL_NAME="$input" | ||||
;; | |||||
?" $msg_zroot_pool_size") | |||||
# Prompt the user to input/change the zroot pool size | |||||
while :; do | |||||
f_dialog_input input \ | |||||
"$msg_please_enter_amount_of_zroot_space" \ | |||||
"$ZFSBOOT_ZROOT_POOL_SIZE" && | |||||
ZFSBOOT_ZROOT_POOL_SIZE="$input" | |||||
if [ $ZFSBOOT_ZROOT_POOL_SIZE = "MAX" ]; then | |||||
zrootsize = "MAX" | |||||
break; | |||||
fi | |||||
if f_expand_number "$ZFSBOOT_ZROOT_POOL_SIZE" zrootsize | |||||
then | |||||
if [ $zrootsize -ne 0 -a $zrootsize -lt 104857600 ]; then | |||||
f_show_err "$msg_zroot_pool_toosmall" \ | |||||
"$ZFSBOOT_ZROOT_POOL_SIZE" | |||||
continue; | |||||
else | |||||
break; | |||||
fi | |||||
else | |||||
f_show_err "$msg_zroot_pool_invalid" \ | |||||
"$ZFSBOOT_ZROOT_POOL_SIZE" | |||||
continue; | |||||
fi | |||||
done | |||||
;; | ;; | ||||
?" $msg_force_4k_sectors") | ?" $msg_force_4k_sectors") | ||||
# Toggle the variable referenced both by the menu and later | # Toggle the variable referenced both by the menu and later | ||||
if [ "$ZFSBOOT_FORCE_4K_SECTORS" ]; then | if [ "$ZFSBOOT_FORCE_4K_SECTORS" ]; then | ||||
ZFSBOOT_FORCE_4K_SECTORS= | ZFSBOOT_FORCE_4K_SECTORS= | ||||
else | else | ||||
ZFSBOOT_FORCE_4K_SECTORS=1 | ZFSBOOT_FORCE_4K_SECTORS=1 | ||||
fi | fi | ||||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |