1cd88b886SDevin Teske#!/bin/sh 2cd88b886SDevin Teske#- 3cd88b886SDevin Teske# Copyright (c) 2013 Allan Jude 4cd88b886SDevin Teske# Copyright (c) 2013 Devin Teske 5cd88b886SDevin Teske# All rights reserved. 6cd88b886SDevin Teske# 7cd88b886SDevin Teske# Redistribution and use in source and binary forms, with or without 8cd88b886SDevin Teske# modification, are permitted provided that the following conditions 9cd88b886SDevin Teske# are met: 10cd88b886SDevin Teske# 1. Redistributions of source code must retain the above copyright 11cd88b886SDevin Teske# notice, this list of conditions and the following disclaimer. 12cd88b886SDevin Teske# 2. Redistributions in binary form must reproduce the above copyright 13cd88b886SDevin Teske# notice, this list of conditions and the following disclaimer in the 14cd88b886SDevin Teske# documentation and/or other materials provided with the distribution. 15cd88b886SDevin Teske# 16cd88b886SDevin Teske# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17cd88b886SDevin Teske# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18cd88b886SDevin Teske# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19cd88b886SDevin Teske# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20cd88b886SDevin Teske# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21cd88b886SDevin Teske# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22cd88b886SDevin Teske# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23cd88b886SDevin Teske# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24cd88b886SDevin Teske# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25cd88b886SDevin Teske# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26cd88b886SDevin Teske# SUCH DAMAGE. 27cd88b886SDevin Teske# 28cd88b886SDevin Teske# $FreeBSD$ 29cd88b886SDevin Teske# 30cd88b886SDevin Teske############################################################ INCLUDES 31cd88b886SDevin Teske 32cd88b886SDevin TeskeBSDCFG_SHARE="/usr/share/bsdconfig" 33cd88b886SDevin Teske. $BSDCFG_SHARE/common.subr || exit 1 34cd88b886SDevin Teskef_dprintf "%s: loading includes..." "$0" 35cd88b886SDevin Teskef_include $BSDCFG_SHARE/device.subr 36cd88b886SDevin Teskef_include $BSDCFG_SHARE/dialog.subr 37cd88b886SDevin Teskef_include $BSDCFG_SHARE/password/password.subr 38cd88b886SDevin Teskef_include $BSDCFG_SHARE/variable.subr 39cd88b886SDevin Teske 40cd88b886SDevin Teske############################################################ CONFIGURATION 41cd88b886SDevin Teske 42cd88b886SDevin Teske# 43cd88b886SDevin Teske# Default name of the boot-pool 44cd88b886SDevin Teske# 45cd88b886SDevin Teske: ${ZFSBOOT_POOL_NAME:=zroot} 46cd88b886SDevin Teske 47cd88b886SDevin Teske# 48cd88b886SDevin Teske# Default name for the boot environment parent dataset 49cd88b886SDevin Teske# 5067635c19SDevin Teske: ${ZFSBOOT_BEROOT_NAME:=ROOT} 51cd88b886SDevin Teske 52cd88b886SDevin Teske# 53cd88b886SDevin Teske# Default name for the primany boot environment 54cd88b886SDevin Teske# 55cd88b886SDevin Teske: ${ZFSBOOT_BOOTFS_NAME:=default} 56cd88b886SDevin Teske 57cd88b886SDevin Teske# 58cd88b886SDevin Teske# Default Virtual Device (vdev) type to create 59cd88b886SDevin Teske# 60cd88b886SDevin Teske: ${ZFSBOOT_VDEV_TYPE:=stripe} 61cd88b886SDevin Teske 62cd88b886SDevin Teske# 63cd88b886SDevin Teske# Should we use gnop(8) to configure a transparent mapping to 4K sectors? 64cd88b886SDevin Teske# 65cd88b886SDevin Teske: ${ZFSBOOT_GNOP_4K_FORCE_ALIGN:=1} 66cd88b886SDevin Teske 67cd88b886SDevin Teske# 68cd88b886SDevin Teske# Should we use geli(8) to encrypt the drives? 69*7cae6aabSDevin Teske# NB: Automatically enables ZFSBOOT_BOOT_POOL 70cd88b886SDevin Teske# 71bc4a673fSDevin Teske: ${ZFSBOOT_GELI_ENCRYPTION=} 72cd88b886SDevin Teske 73cd88b886SDevin Teske# 74cd88b886SDevin Teske# Default path to the geli(8) keyfile used in drive encryption 75cd88b886SDevin Teske# 76cd88b886SDevin Teske: ${ZFSBOOT_GELI_KEY_FILE:=/boot/encryption.key} 77cd88b886SDevin Teske 78cd88b886SDevin Teske# 79*7cae6aabSDevin Teske# Create a separate boot pool? 80*7cae6aabSDevin Teske# NB: Automatically set when using geli(8) or MBR 81*7cae6aabSDevin Teske# 82*7cae6aabSDevin Teske: ${ZFSBOOT_BOOT_POOL=} 83*7cae6aabSDevin Teske 84*7cae6aabSDevin Teske# 85*7cae6aabSDevin Teske# Default name for boot pool when enabled (e.g., geli(8) or MBR) 86*7cae6aabSDevin Teske# 87*7cae6aabSDevin Teske: ${ZFSBOOT_BOOT_POOL_NAME:=bootpool} 88*7cae6aabSDevin Teske 89*7cae6aabSDevin Teske# 90*7cae6aabSDevin Teske# Default size for boot pool when enabled (e.g., geli(8) or MBR) 91*7cae6aabSDevin Teske# 92*7cae6aabSDevin Teske: ${ZFSBOOT_BOOT_POOL_SIZE:=2g} 93*7cae6aabSDevin Teske 94*7cae6aabSDevin Teske# 95cd88b886SDevin Teske# Default disks to use (always empty unless being scripted) 96cd88b886SDevin Teske# 97cd88b886SDevin Teske: ${ZFSBOOT_DISKS:=} 98cd88b886SDevin Teske 99cd88b886SDevin Teske# 100cd88b886SDevin Teske# Default partitioning scheme to use on disks 101cd88b886SDevin Teske# 102cd88b886SDevin Teske: ${ZFSBOOT_PARTITION_SCHEME:=GPT} 103cd88b886SDevin Teske 104cd88b886SDevin Teske# 105cd88b886SDevin Teske# How much swap to put on each block device in the boot zpool 106cd88b886SDevin Teske# NOTE: Value passed to gpart(8); which supports SI unit suffixes. 107cd88b886SDevin Teske# 108cd88b886SDevin Teske: ${ZFSBOOT_SWAP_SIZE:=2g} 109cd88b886SDevin Teske 110cd88b886SDevin Teske# 111bc4a673fSDevin Teske# Default ZFS datasets for root zpool 112cd88b886SDevin Teske# 113cd88b886SDevin Teske# NOTE: Requires /tmp, /var/tmp, /$ZFSBOOT_BOOTFS_NAME/$ZFSBOOT_BOOTFS_NAME 114cd88b886SDevin Teske# NOTE: Anything after pound/hash character [#] is ignored as a comment. 115cd88b886SDevin Teske# 116cd88b886SDevin Teskef_isset ZFSBOOT_DATASETS || ZFSBOOT_DATASETS=" 117cd88b886SDevin Teske # DATASET OPTIONS (comma or space separated; or both) 118cd88b886SDevin Teske 119cd88b886SDevin Teske # Boot Environment [BE] root and default boot dataset 120cd88b886SDevin Teske /$ZFSBOOT_BEROOT_NAME mountpoint=none 121cd88b886SDevin Teske /$ZFSBOOT_BEROOT_NAME/$ZFSBOOT_BOOTFS_NAME mountpoint=/ 122cd88b886SDevin Teske 123cd88b886SDevin Teske # Compress /tmp, allow exec but not setuid 124cd88b886SDevin Teske /tmp mountpoint=/tmp,compression=lz4,exec=on,setuid=off 125cd88b886SDevin Teske 126cd88b886SDevin Teske # Don't mount /usr so that 'base' files go to the BEROOT 127cd88b886SDevin Teske /usr mountpoint=/usr,canmount=off 128cd88b886SDevin Teske 129cd88b886SDevin Teske # Home directories separated so they are common to all BEs 130bc4a673fSDevin Teske /usr/home # NB: /home is a symlink to /usr/home 131cd88b886SDevin Teske 132cd88b886SDevin Teske # Ports tree 133cd88b886SDevin Teske /usr/ports compression=lz4,setuid=off 134cd88b886SDevin Teske 135cd88b886SDevin Teske # Source tree (compressed) 136cd88b886SDevin Teske /usr/src compression=lz4,exec=off,setuid=off 137cd88b886SDevin Teske 138cd88b886SDevin Teske # Create /var and friends 139cd88b886SDevin Teske /var mountpoint=/var 140cd88b886SDevin Teske /var/crash compression=lz4,exec=off,setuid=off 141cd88b886SDevin Teske /var/log compression=lz4,exec=off,setuid=off 142a6c8532cSDevin Teske /var/mail compression=lz4,atime=on 143cd88b886SDevin Teske /var/tmp compression=lz4,exec=on,setuid=off 144cd88b886SDevin Teske" # END-QUOTE 145cd88b886SDevin Teske 146bc4a673fSDevin Teske# 147bc4a673fSDevin Teske# If interactive and the user has not explicitly chosen a vdev type or disks, 148bc4a673fSDevin Teske# make the user confirm scripted/default choices when proceeding to install. 149bc4a673fSDevin Teske# 150bc4a673fSDevin Teske: ${ZFSBOOT_CONFIRM_LAYOUT:=1} 151bc4a673fSDevin Teske 152cd88b886SDevin Teske############################################################ GLOBALS 153cd88b886SDevin Teske 154cd88b886SDevin Teske# 155bc4a673fSDevin Teske# Format of a line in printf(1) syntax to add to fstab(5) 156bc4a673fSDevin Teske# 157bc4a673fSDevin TeskeFSTAB_FMT="%s\t\t%s\t%s\t%s\t\t%s\t%s\n" 158bc4a673fSDevin Teske 159bc4a673fSDevin Teske# 160bc4a673fSDevin Teske# Command strings for various tasks 161bc4a673fSDevin Teske# 162bc4a673fSDevin TeskeCHMOD_MODE='chmod %s "%s"' 163bc4a673fSDevin TeskeDD_WITH_OPTIONS='dd if="%s" of="%s" %s' 164bc4a673fSDevin TeskeECHO_APPEND='echo "%s" >> "%s"' 165bc4a673fSDevin TeskeGELI_ATTACH='geli attach -j - -k "%s" "%s"' 166a622223fSDevin TeskeGELI_DETACH_F='geli detach -f "%s"' 167bc4a673fSDevin TeskeGELI_PASSWORD_INIT='geli init -b -B "%s" -e %s -J - -K "%s" -l 256 -s 4096 "%s"' 168bc4a673fSDevin TeskeGNOP_CREATE='gnop create -S 4096 "%s"' 169a622223fSDevin TeskeGNOP_DESTROY='gnop destroy "%s"' 170bc4a673fSDevin TeskeGPART_ADD='gpart add -t %s "%s"' 171bc4a673fSDevin TeskeGPART_ADD_INDEX='gpart add -i %s -t %s "%s"' 172bc4a673fSDevin TeskeGPART_ADD_INDEX_WITH_SIZE='gpart add -i %s -t %s -s %s "%s"' 173bc4a673fSDevin TeskeGPART_ADD_LABEL='gpart add -l %s -t %s "%s"' 174bc4a673fSDevin TeskeGPART_ADD_LABEL_WITH_SIZE='gpart add -l %s -t %s -s %s "%s"' 175bc4a673fSDevin TeskeGPART_BOOTCODE='gpart bootcode -b "%s" "%s"' 176bc4a673fSDevin TeskeGPART_BOOTCODE_PART='gpart bootcode -b "%s" -p "%s" -i %s "%s"' 177bc4a673fSDevin TeskeGPART_CREATE='gpart create -s %s "%s"' 178a622223fSDevin TeskeGPART_DESTROY_F='gpart destroy -F "%s"' 179bc4a673fSDevin TeskeGPART_SET_ACTIVE='gpart set -a active -i %s "%s"' 180a622223fSDevin TeskeGRAID_DELETE='graid delete "%s"' 181bc4a673fSDevin TeskeLN_SF='ln -sf "%s" "%s"' 182bc4a673fSDevin TeskeMKDIR_P='mkdir -p "%s"' 183bc4a673fSDevin TeskeMOUNT_TYPE='mount -t %s "%s" "%s"' 184bc4a673fSDevin TeskePRINTF_CONF="printf '%s=\"%%s\"\\\n' %s >> \"%s\"" 185bc4a673fSDevin TeskePRINTF_FSTAB='printf "$FSTAB_FMT" "%s" "%s" "%s" "%s" "%s" "%s" >> "%s"' 186bc4a673fSDevin TeskeSHELL_TRUNCATE=':> "%s"' 187a622223fSDevin TeskeUMOUNT='umount "%s"' 188bc4a673fSDevin TeskeZFS_CREATE_WITH_OPTIONS='zfs create %s "%s"' 189bc4a673fSDevin TeskeZFS_SET='zfs set "%s" "%s"' 190bc4a673fSDevin TeskeZFS_UNMOUNT='zfs unmount "%s"' 191bc4a673fSDevin TeskeZPOOL_CREATE_WITH_OPTIONS='zpool create %s "%s" %s %s' 192bc4a673fSDevin TeskeZPOOL_EXPORT='zpool export "%s"' 193bc4a673fSDevin TeskeZPOOL_IMPORT_WITH_OPTIONS='zpool import %s "%s"' 194a622223fSDevin TeskeZPOOL_LABELCLEAR_F='zpool labelclear -f "%s"' 195bc4a673fSDevin TeskeZPOOL_SET='zpool set %s "%s"' 196bc4a673fSDevin Teske 197bc4a673fSDevin Teske# 198cd88b886SDevin Teske# Strings that should be moved to an i18n file and loaded with f_include_lang() 199cd88b886SDevin Teske# 200cd88b886SDevin Teskehline_alnum_arrows_punc_tab_enter="Use alnum, arrows, punctuation, TAB or ENTER" 201cd88b886SDevin Teskehline_arrows_space_tab_enter="Use arrows, SPACE, TAB or ENTER" 202cd88b886SDevin Teskehline_arrows_tab_enter="Press arrows, TAB or ENTER" 203bc4a673fSDevin Teskemsg_an_unknown_error_occurred="An unknown error occurred" 204cd88b886SDevin Teskemsg_back="Back" 205cd88b886SDevin Teskemsg_cancel="Cancel" 206bc4a673fSDevin Teskemsg_change_selection="Change Selection" 207cd88b886SDevin Teskemsg_configure_options="Configure Options:" 208cd88b886SDevin Teskemsg_detailed_disk_info="gpart(8) show %s:\n%s\n\ncamcontrol(8) inquiry %s:\n%s\n\n\ncamcontrol(8) identify %s:\n%s\n" 209cd88b886SDevin Teskemsg_disk_info="Disk Info" 210cd88b886SDevin Teskemsg_disk_info_help="Get detailed information on disk device(s)" 211bc4a673fSDevin Teskemsg_encrypt_disks="Encrypt Disks?" 212bc4a673fSDevin Teskemsg_encrypt_disks_help="Use geli(8) to encrypt all data partitions" 213bc4a673fSDevin Teskemsg_error="Error" 214cd88b886SDevin Teskemsg_force_4k_sectors="Force 4K Sectors?" 215cd88b886SDevin Teskemsg_force_4k_sectors_help="Use gnop(8) to configure forced 4K sector alignment" 216cd88b886SDevin Teskemsg_freebsd_installer="FreeBSD Installer" 217cd88b886SDevin Teskemsg_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" 218cd88b886SDevin Teskemsg_geli_setup="Initializing encryption on the selected disks, this will take several seconds per disk" 219bc4a673fSDevin Teskemsg_install="Install" 220bc4a673fSDevin Teskemsg_install_desc="Proceed with Installation" 221bc4a673fSDevin Teskemsg_install_help="Create ZFS boot pool with displayed options" 222*7cae6aabSDevin Teskemsg_invalid_boot_pool_size="Invalid boot pool size \`%s'" 223bc4a673fSDevin Teskemsg_invalid_disk_argument="Invalid disk argument \`%s'" 224bc4a673fSDevin Teskemsg_invalid_index_argument="Invalid index argument \`%s'" 225bc4a673fSDevin Teskemsg_invalid_swap_size="Invalid swap size \`%s'" 226cd88b886SDevin Teskemsg_invalid_virtual_device_type="Invalid Virtual Device type \`%s'" 227bc4a673fSDevin Teskemsg_last_chance_are_you_sure="Last Chance! Are you sure you want to destroy\nthe current contents of the following disks:\n\n %s" 228bc4a673fSDevin Teskemsg_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' 229cd88b886SDevin Teskemsg_mirror_desc="Mirror - n-Way Mirroring" 230cd88b886SDevin Teskemsg_mirror_help="[2+ Disks] Mirroring provides the best performance, but the least storage" 231bc4a673fSDevin Teskemsg_missing_disk_arguments="missing disk arguments" 232bc4a673fSDevin Teskemsg_missing_one_or_more_scripted_disks="Missing one or more scripted disks!" 233cd88b886SDevin Teskemsg_no="NO" 234cd88b886SDevin Teskemsg_no_disks_present_to_configure="No disk(s) present to configure" 235cd88b886SDevin Teskemsg_no_disks_selected="No disks selected." 236bc4a673fSDevin Teskemsg_not_enough_disks_selected="Not enough disks selected. (%u < %u minimum)" 237bc4a673fSDevin Teskemsg_null_disk_argument="NULL disk argument" 238bc4a673fSDevin Teskemsg_null_index_argument="NULL index argument" 239bc4a673fSDevin Teskemsg_null_poolname="NULL poolname" 240cd88b886SDevin Teskemsg_ok="OK" 241cd88b886SDevin Teskemsg_partition_scheme="Partition Scheme" 242cd88b886SDevin Teskemsg_partition_scheme_help="Toggle between GPT and MBR partitioning schemes" 243cd88b886SDevin Teskemsg_please_enter_a_name_for_your_zpool="Please enter a name for your zpool:" 244cd88b886SDevin Teskemsg_please_enter_amount_of_swap_space="Please enter amount of swap space (SI-Unit suffixes\nrecommended; e.g., \`2g' for 2 Gigabytes):" 245cd88b886SDevin Teskemsg_please_select_one_or_more_disks="Please select one or more disks to create a zpool:" 246cd88b886SDevin Teskemsg_pool_name="Pool Name" 247cd88b886SDevin Teskemsg_pool_name_cannot_be_empty="Pool name cannot be empty." 248cd88b886SDevin Teskemsg_pool_name_help="Customize the name of the zpool to be created (Required)" 249bc4a673fSDevin Teskemsg_pool_type_disks="Pool Type/Disks:" 250bc4a673fSDevin Teskemsg_pool_type_disks_help="Choose type of ZFS Virtual Device and disks to use (Required)" 251cd88b886SDevin Teskemsg_processing_selection="Processing selection..." 252cd88b886SDevin Teskemsg_raidz1_desc="RAID-Z1 - Single Redundant RAID" 253cd88b886SDevin Teskemsg_raidz1_help="[3+ Disks] Withstand failure of 1 disk. Recommended for: 3, 5 or 9 disks" 254cd88b886SDevin Teskemsg_raidz2_desc="RAID-Z2 - Double Redundant RAID" 255cd88b886SDevin Teskemsg_raidz2_help="[4+ Disks] Withstand failure of 2 disks. Recommended for: 4, 6 or 10 disks" 256cd88b886SDevin Teskemsg_raidz3_desc="RAID-Z3 - Triple Redundant RAID" 257cd88b886SDevin Teskemsg_raidz3_help="[5+ Disks] Withstand failure of 3 disks. Recommended for: 5, 7 or 11 disks" 258cd88b886SDevin Teskemsg_rescan_devices="Rescan Devices" 259cd88b886SDevin Teskemsg_rescan_devices_help="Scan for device changes" 260cd88b886SDevin Teskemsg_select="Select" 261cd88b886SDevin Teskemsg_select_a_disk_device="Select a disk device" 262cd88b886SDevin Teskemsg_select_virtual_device_type="Select Virtual Device type:" 263cd88b886SDevin Teskemsg_stripe_desc="Stripe - No Redundancy" 264cd88b886SDevin Teskemsg_stripe_help="[1+ Disks] Striping provides maximum storage but no redundancy" 265cd88b886SDevin Teskemsg_swap_size="Swap Size" 266cd88b886SDevin Teskemsg_swap_size_help="Customize how much swap space is allocated to each selected disk" 267bc4a673fSDevin Teskemsg_these_disks_are_too_small="These disks are too small given the amount of requested\nswap (%s) and/or geli(8) (%s) partitions, which would\ntake 50%% or more of each of the following selected disk\ndevices (not recommended):\n\n %s\n\nRecommend changing partition size(s) and/or selecting a\ndifferent set of devices." 268bc4a673fSDevin Teskemsg_unable_to_get_disk_capacity="Unable to get disk capacity of \`%s'" 269bc4a673fSDevin Teskemsg_unsupported_partition_scheme="%s is an unsupported partition scheme" 270bc4a673fSDevin Teskemsg_user_cancelled="User Cancelled." 271cd88b886SDevin Teskemsg_yes="YES" 272cd88b886SDevin Teskemsg_zfs_configuration="ZFS Configuration" 273cd88b886SDevin Teske 274cd88b886SDevin Teske############################################################ FUNCTIONS 275cd88b886SDevin Teske 276cd88b886SDevin Teske# dialog_menu_main 277cd88b886SDevin Teske# 278cd88b886SDevin Teske# Display the dialog(1)-based application main menu. 279cd88b886SDevin Teske# 280cd88b886SDevin Teskedialog_menu_main() 281cd88b886SDevin Teske{ 282cd88b886SDevin Teske local title="$DIALOG_TITLE" 283cd88b886SDevin Teske local btitle="$DIALOG_BACKTITLE" 284cd88b886SDevin Teske local prompt="$msg_configure_options" 285cd88b886SDevin Teske local force4k="$msg_no" 286cd88b886SDevin Teske local usegeli="$msg_no" 287cd88b886SDevin Teske [ "$ZFSBOOT_GNOP_4K_FORCE_ALIGN" ] && force4k="$msg_yes" 288cd88b886SDevin Teske [ "$ZFSBOOT_GELI_ENCRYPTION" ] && usegeli="$msg_yes" 289bc4a673fSDevin Teske local disks n=$( set -- $ZFSBOOT_DISKS; echo $# ) 290bc4a673fSDevin Teske { [ $n -eq 1 ] && disks=disk; } || disks=disks # grammar 291cd88b886SDevin Teske local menu_list=" 292bc4a673fSDevin Teske '>>> $msg_install' '$msg_install_desc' 293bc4a673fSDevin Teske '$msg_install_help' 294bc4a673fSDevin Teske 'T $msg_pool_type_disks' '$ZFSBOOT_VDEV_TYPE: $n $disks' 295bc4a673fSDevin Teske '$msg_pool_type_disks_help' 296cd88b886SDevin Teske '- $msg_rescan_devices' '*' 297cd88b886SDevin Teske '$msg_rescan_devices_help' 298cd88b886SDevin Teske '- $msg_disk_info' '*' 299cd88b886SDevin Teske '$msg_disk_info_help' 300bc4a673fSDevin Teske 'N $msg_pool_name' '$ZFSBOOT_POOL_NAME' 301cd88b886SDevin Teske '$msg_pool_name_help' 302cd88b886SDevin Teske '4 $msg_force_4k_sectors' '$force4k' 303cd88b886SDevin Teske '$msg_force_4k_sectors_help' 304bc4a673fSDevin Teske 'E $msg_encrypt_disks' '$usegeli' 305bc4a673fSDevin Teske '$msg_encrypt_disks_help' 306bc4a673fSDevin Teske 'P $msg_partition_scheme' '$ZFSBOOT_PARTITION_SCHEME' 307cd88b886SDevin Teske '$msg_partition_scheme_help' 308bc4a673fSDevin Teske 'S $msg_swap_size' '$ZFSBOOT_SWAP_SIZE' 309cd88b886SDevin Teske '$msg_swap_size_help' 310cd88b886SDevin Teske " # END-QUOTE 311cd88b886SDevin Teske local defaultitem= # Calculated below 312cd88b886SDevin Teske local hline="$hline_alnum_arrows_punc_tab_enter" 313cd88b886SDevin Teske 314cd88b886SDevin Teske local height width rows 315cd88b886SDevin Teske eval f_dialog_menu_with_help_size height width rows \ 316cd88b886SDevin Teske \"\$title\" \"\$btitle\" \"\$prompt\" \"\$hline\" $menu_list 317cd88b886SDevin Teske 318cd88b886SDevin Teske # Obtain default-item from previously stored selection 319cd88b886SDevin Teske f_dialog_default_fetch defaultitem 320cd88b886SDevin Teske 321cd88b886SDevin Teske local menu_choice 322cd88b886SDevin Teske menu_choice=$( eval $DIALOG \ 323cd88b886SDevin Teske --title \"\$title\" \ 324cd88b886SDevin Teske --backtitle \"\$btitle\" \ 325cd88b886SDevin Teske --hline \"\$hline\" \ 326cd88b886SDevin Teske --item-help \ 327cd88b886SDevin Teske --ok-label \"\$msg_select\" \ 328cd88b886SDevin Teske --cancel-label \"\$msg_cancel\" \ 329cd88b886SDevin Teske --default-item \"\$defaultitem\" \ 330cd88b886SDevin Teske --menu \"\$prompt\" \ 331cd88b886SDevin Teske $height $width $rows \ 332cd88b886SDevin Teske $menu_list \ 333cd88b886SDevin Teske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 334cd88b886SDevin Teske ) 335cd88b886SDevin Teske local retval=$? 336cd88b886SDevin Teske f_dialog_data_sanitize menu_choice 337cd88b886SDevin Teske f_dialog_menutag_store "$menu_choice" 338cd88b886SDevin Teske 339cd88b886SDevin Teske # Only update default-item on success 340cd88b886SDevin Teske [ $retval -eq $DIALOG_OK ] && f_dialog_default_store "$menu_choice" 341cd88b886SDevin Teske 342cd88b886SDevin Teske return $retval 343cd88b886SDevin Teske} 344cd88b886SDevin Teske 345bc4a673fSDevin Teske# dialog_last_chance $disks ... 346cd88b886SDevin Teske# 347bc4a673fSDevin Teske# Display a list of the disks that the user is about to destroy. The default 348bc4a673fSDevin Teske# action is to return error status unless the user explicitly (non-default) 349bc4a673fSDevin Teske# selects "Yes" from the noyes dialog. 350cd88b886SDevin Teske# 351bc4a673fSDevin Teskedialog_last_chance() 352cd88b886SDevin Teske{ 353cd88b886SDevin Teske local title="$DIALOG_TITLE" 354cd88b886SDevin Teske local btitle="$DIALOG_BACKTITLE" 355bc4a673fSDevin Teske local prompt # Calculated below 356bc4a673fSDevin Teske local hline="$hline_arrows_tab_enter" 357cd88b886SDevin Teske 358bc4a673fSDevin Teske local height=8 width=50 prefix=" " 359bc4a673fSDevin Teske local plen=${#prefix} list= line= 360bc4a673fSDevin Teske local max_width=$(( $width - 3 - $plen )) 361bc4a673fSDevin Teske 362bc4a673fSDevin Teske local yes no defaultno extra_args format 363bc4a673fSDevin Teske if [ "$USE_XDIALOG" ]; then 364bc4a673fSDevin Teske yes=ok no=cancel defaultno=default-no 365bc4a673fSDevin Teske extra_args="--wrap --left" 366bc4a673fSDevin Teske format="$msg_last_chance_are_you_sure" 367bc4a673fSDevin Teske else 368bc4a673fSDevin Teske yes=yes no=no defaultno=defaultno 369bc4a673fSDevin Teske extra_args="--colors --cr-wrap" 370bc4a673fSDevin Teske format="$msg_last_chance_are_you_sure_color" 371bc4a673fSDevin Teske fi 372bc4a673fSDevin Teske 373bc4a673fSDevin Teske local disk line_width 374bc4a673fSDevin Teske for disk in $*; do 375bc4a673fSDevin Teske if [ "$line" ]; then 376bc4a673fSDevin Teske line_width=${#line} 377bc4a673fSDevin Teske else 378bc4a673fSDevin Teske line_width=$plen 379bc4a673fSDevin Teske fi 380bc4a673fSDevin Teske line_width=$(( $line_width + 1 + ${#disk} )) 381bc4a673fSDevin Teske # Add newline before disk if it would exceed max_width 382bc4a673fSDevin Teske if [ $line_width -gt $max_width ]; then 383bc4a673fSDevin Teske list="$list$line\n" 384bc4a673fSDevin Teske line="$prefix" 385bc4a673fSDevin Teske height=$(( $height + 1 )) 386bc4a673fSDevin Teske fi 387bc4a673fSDevin Teske # Add the disk to the list 388bc4a673fSDevin Teske line="$line $disk" 389bc4a673fSDevin Teske done 390bc4a673fSDevin Teske # Append the left-overs 391bc4a673fSDevin Teske if [ "${line#$prefix}" ]; then 392bc4a673fSDevin Teske list="$list$line" 393bc4a673fSDevin Teske height=$(( $height + 1 )) 394bc4a673fSDevin Teske fi 395bc4a673fSDevin Teske 396bc4a673fSDevin Teske # Add height for Xdialog(1) 397bc4a673fSDevin Teske [ "$USE_XDIALOG" ] && height=$(( $height + $height / 5 + 3 )) 398bc4a673fSDevin Teske 399bc4a673fSDevin Teske prompt=$( printf "$format" "$list" ) 400bc4a673fSDevin Teske f_dprintf "%s: Last Chance!" "$0" 401bc4a673fSDevin Teske $DIALOG \ 402bc4a673fSDevin Teske --title "$title" \ 403bc4a673fSDevin Teske --backtitle "$btitle" \ 404bc4a673fSDevin Teske --hline "$hline" \ 405bc4a673fSDevin Teske --$defaultno \ 406bc4a673fSDevin Teske --$yes-label "$msg_yes" \ 407bc4a673fSDevin Teske --$no-label "$msg_no" \ 408bc4a673fSDevin Teske $extra_args \ 409bc4a673fSDevin Teske --yesno "$prompt" $height $width 410bc4a673fSDevin Teske} 411bc4a673fSDevin Teske 412bc4a673fSDevin Teske# dialog_menu_layout 413cd88b886SDevin Teske# 414bc4a673fSDevin Teske# Configure Virtual Device type and disks to use for the ZFS boot pool. User 415bc4a673fSDevin Teske# must select enough disks to satisfy the chosen vdev type. 416cd88b886SDevin Teske# 417bc4a673fSDevin Teskedialog_menu_layout() 418bc4a673fSDevin Teske{ 419bc4a673fSDevin Teske local funcname=dialog_menu_layout 420bc4a673fSDevin Teske local title="$DIALOG_TITLE" 421bc4a673fSDevin Teske local btitle="$DIALOG_BACKTITLE" 422bc4a673fSDevin Teske local vdev_prompt="$msg_select_virtual_device_type" 423bc4a673fSDevin Teske local disk_prompt="$msg_please_select_one_or_more_disks" 424bc4a673fSDevin Teske local vdev_menu_list=" 425bc4a673fSDevin Teske 'stripe' '$msg_stripe_desc' '$msg_stripe_help' 426bc4a673fSDevin Teske 'mirror' '$msg_mirror_desc' '$msg_mirror_help' 427bc4a673fSDevin Teske 'raidz1' '$msg_raidz1_desc' '$msg_raidz1_help' 428bc4a673fSDevin Teske 'raidz2' '$msg_raidz2_desc' '$msg_raidz2_help' 429bc4a673fSDevin Teske 'raidz3' '$msg_raidz3_desc' '$msg_raidz3_help' 430bc4a673fSDevin Teske " # END-QUOTE 431bc4a673fSDevin Teske local disk_check_list= # Calculated below 432bc4a673fSDevin Teske local vdev_hline="$hline_arrows_tab_enter" 433bc4a673fSDevin Teske local disk_hline="$hline_arrows_space_tab_enter" 434bc4a673fSDevin Teske 435bc4a673fSDevin Teske # Warn the user if vdev type is not valid 436bc4a673fSDevin Teske case "$ZFSBOOT_VDEV_TYPE" in 437bc4a673fSDevin Teske stripe|mirror|raidz1|raidz2|raidz3) : known good ;; 438bc4a673fSDevin Teske *) 439bc4a673fSDevin Teske f_dprintf "%s: Invalid virtual device type \`%s'" \ 440bc4a673fSDevin Teske $funcname "$ZFSBOOT_VDEV_TYPE" 441bc4a673fSDevin Teske f_show_err "$msg_invalid_virtual_device_type" \ 442bc4a673fSDevin Teske "$ZFSBOOT_VDEV_TYPE" 443bc4a673fSDevin Teske f_interactive || return $FAILURE 444bc4a673fSDevin Teske esac 445bc4a673fSDevin Teske 446bc4a673fSDevin Teske # Calculate size of vdev menu once only 447bc4a673fSDevin Teske local vheight vwidth vrows 448bc4a673fSDevin Teske eval f_dialog_menu_with_help_size vheight vwidth vrows \ 449bc4a673fSDevin Teske \"\$title\" \"\$btitle\" \"\$vdev_prompt\" \"\$vdev_hline\" \ 450bc4a673fSDevin Teske $vdev_menu_list 451bc4a673fSDevin Teske 452bc4a673fSDevin Teske # Get a list of probed disk devices 453bc4a673fSDevin Teske local disks= 454cd88b886SDevin Teske f_device_find "" $DEVICE_TYPE_DISK disks 455bc4a673fSDevin Teske f_dprintf "$funcname: disks=[%s]" "$disks" 456cd88b886SDevin Teske if [ ! "$disks" ]; then 457bc4a673fSDevin Teske f_dprintf "No disk(s) present to configure" 458bc4a673fSDevin Teske f_show_err "$msg_no_disks_present_to_configure" 459cd88b886SDevin Teske return $FAILURE 460cd88b886SDevin Teske fi 461cd88b886SDevin Teske 462cd88b886SDevin Teske # Lets sort the disks array to be more user friendly 463cd88b886SDevin Teske disks=$( echo "$disks" | tr ' ' '\n' | sort | tr '\n' ' ' ) 464cd88b886SDevin Teske 465cd88b886SDevin Teske # 466bc4a673fSDevin Teske # Operate in a loop so we can (if interactive) repeat if not enough 467bc4a673fSDevin Teske # disks are selected to satisfy the chosen vdev type or user wants to 468bc4a673fSDevin Teske # back-up to the previous menu. 469cd88b886SDevin Teske # 470bc4a673fSDevin Teske local vardisk ndisks onoff selections vdev_choice 471bc4a673fSDevin Teske while :; do 472cd88b886SDevin Teske # 473bc4a673fSDevin Teske # Confirm the vdev type that was selected 474cd88b886SDevin Teske # 475bc4a673fSDevin Teske if f_interactive && [ "$ZFSBOOT_CONFIRM_LAYOUT" ]; then 476bc4a673fSDevin Teske vdev_choice=$( eval $DIALOG \ 477cd88b886SDevin Teske --title \"\$title\" \ 478cd88b886SDevin Teske --backtitle \"\$btitle\" \ 479bc4a673fSDevin Teske --hline \"\$vdev_hline\" \ 480cd88b886SDevin Teske --ok-label \"\$msg_ok\" \ 481cd88b886SDevin Teske --cancel-label \"\$msg_cancel\" \ 482cd88b886SDevin Teske --item-help \ 483bc4a673fSDevin Teske --default-item \"\$ZFSBOOT_VDEV_TYPE\" \ 484bc4a673fSDevin Teske --menu \"\$vdev_prompt\" \ 485bc4a673fSDevin Teske $vheight $vwidth $vrows \ 486bc4a673fSDevin Teske $vdev_menu_list \ 487cd88b886SDevin Teske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 488bc4a673fSDevin Teske ) || return $? 489bc4a673fSDevin Teske # Exit if user pressed ESC or chose Cancel/No 490bc4a673fSDevin Teske f_dialog_data_sanitize vdev_choice 491cd88b886SDevin Teske 492bc4a673fSDevin Teske ZFSBOOT_VDEV_TYPE="$vdev_choice" 493bc4a673fSDevin Teske f_dprintf "$funcname: ZFSBOOT_VDEV_TYPE=[%s]" \ 494bc4a673fSDevin Teske "$ZFSBOOT_VDEV_TYPE" 495bc4a673fSDevin Teske fi 496bc4a673fSDevin Teske 497bc4a673fSDevin Teske # Determine the number of disks needed for this vdev type 498bc4a673fSDevin Teske local want_disks=0 499bc4a673fSDevin Teske case "$ZFSBOOT_VDEV_TYPE" in 500cd88b886SDevin Teske stripe) want_disks=1 ;; 501cd88b886SDevin Teske mirror) want_disks=2 ;; 502cd88b886SDevin Teske raidz1) want_disks=3 ;; 503cd88b886SDevin Teske raidz2) want_disks=4 ;; 504cd88b886SDevin Teske raidz3) want_disks=5 ;; 505cd88b886SDevin Teske esac 506bc4a673fSDevin Teske 507bc4a673fSDevin Teske # Warn the user if any scripted disks are invalid 508bc4a673fSDevin Teske local disk valid_disks= 509bc4a673fSDevin Teske local all_valid=${ZFSBOOT_DISKS:+1} # optimism 510bc4a673fSDevin Teske for disk in $ZFSBOOT_DISKS; do 511bc4a673fSDevin Teske if f_struct device_$disk; then 512bc4a673fSDevin Teske valid_disks="$valid_disks $disk" 513bc4a673fSDevin Teske continue 514cd88b886SDevin Teske fi 515bc4a673fSDevin Teske f_dprintf "$funcname: \`%s' is not a real disk" "$disk" 516bc4a673fSDevin Teske all_valid= 517bc4a673fSDevin Teske done 518bc4a673fSDevin Teske if [ ! "$all_valid" ]; then 519bc4a673fSDevin Teske if [ "$ZFSBOOT_DISKS" ]; then 520bc4a673fSDevin Teske f_show_err \ 521bc4a673fSDevin Teske "$msg_missing_one_or_more_scripted_disks" 522bc4a673fSDevin Teske else 523bc4a673fSDevin Teske f_dprintf "No disks selected." 524bc4a673fSDevin Teske f_interactive || 525bc4a673fSDevin Teske f_show_err "$msg_no_disks_selected" 526bc4a673fSDevin Teske fi 527bc4a673fSDevin Teske f_interactive || return $FAILURE 528bc4a673fSDevin Teske fi 529bc4a673fSDevin Teske ZFSBOOT_DISKS="${valid_disks# }" 530bc4a673fSDevin Teske 531bc4a673fSDevin Teske # 532bc4a673fSDevin Teske # Short-circuit if we're running non-interactively 533bc4a673fSDevin Teske # 534bc4a673fSDevin Teske if ! f_interactive || [ ! "$ZFSBOOT_CONFIRM_LAYOUT" ]; then 535bc4a673fSDevin Teske ndisks=$( set -- $ZFSBOOT_DISKS; echo $# ) 536bc4a673fSDevin Teske [ $ndisks -ge $want_disks ] && break # to success 537bc4a673fSDevin Teske 538bc4a673fSDevin Teske # Not enough disks selected 539bc4a673fSDevin Teske f_dprintf "$funcname: %s: %s (%u < %u minimum)" \ 540bc4a673fSDevin Teske "$ZFSBOOT_VDEV_TYPE" \ 541bc4a673fSDevin Teske "Not enough disks selected." \ 542bc4a673fSDevin Teske $ndisks $want_disks 543bc4a673fSDevin Teske f_interactive || return $FAILURE 544bc4a673fSDevin Teske msg_yes="$msg_change_selection" msg_no="$msg_cancel" \ 545bc4a673fSDevin Teske f_yesno "%s: $msg_not_enough_disks_selected" \ 546bc4a673fSDevin Teske "$ZFSBOOT_VDEV_TYPE" $ndisks $want_disks || 547bc4a673fSDevin Teske return $FAILURE 548bc4a673fSDevin Teske fi 549bc4a673fSDevin Teske 550bc4a673fSDevin Teske # 551bc4a673fSDevin Teske # Confirm the disks that were selected 552bc4a673fSDevin Teske # Loop until the user cancels or selects enough disks 553bc4a673fSDevin Teske # 554bc4a673fSDevin Teske local breakout= 555bc4a673fSDevin Teske while :; do 556bc4a673fSDevin Teske # Loop over list of available disks, resetting state 557bc4a673fSDevin Teske for disk in $disks; do unset _${disk}_status; done 558bc4a673fSDevin Teske 559bc4a673fSDevin Teske # Loop over list of selected disks and create temporary 560bc4a673fSDevin Teske # locals to map statuses onto up-to-date list of disks 561bc4a673fSDevin Teske for disk in $ZFSBOOT_DISKS; do 562bc4a673fSDevin Teske local _${disk}_status=on 563bc4a673fSDevin Teske done 564bc4a673fSDevin Teske 565bc4a673fSDevin Teske # Create the checklist menu of discovered disk devices 566bc4a673fSDevin Teske disk_check_list= 567bc4a673fSDevin Teske for disk in $disks; do 568bc4a673fSDevin Teske local desc= 569bc4a673fSDevin Teske device_$disk get desc desc 570bc4a673fSDevin Teske f_shell_escape "$desc" desc 571bc4a673fSDevin Teske f_getvar _${disk}_status:-off onoff 572bc4a673fSDevin Teske disk_check_list="$disk_check_list 573bc4a673fSDevin Teske $disk '$desc' $onoff" 574bc4a673fSDevin Teske done 575bc4a673fSDevin Teske 576bc4a673fSDevin Teske local height width rows 577bc4a673fSDevin Teske eval f_dialog_checklist_size height width rows \ 578bc4a673fSDevin Teske \"\$title\" \"\$btitle\" \"\$prompt\" \ 579bc4a673fSDevin Teske \"\$hline\" $disk_check_list 580bc4a673fSDevin Teske 581bc4a673fSDevin Teske selections=$( eval $DIALOG \ 582bc4a673fSDevin Teske --title \"\$DIALOG_TITLE\" \ 583bc4a673fSDevin Teske --backtitle \"\$DIALOG_BACKTITLE\" \ 584bc4a673fSDevin Teske --hline \"\$hline\" \ 585bc4a673fSDevin Teske --ok-label \"\$msg_ok\" \ 586bc4a673fSDevin Teske --cancel-label \"\$msg_back\" \ 587bc4a673fSDevin Teske --checklist \"\$prompt\" \ 588bc4a673fSDevin Teske $height $width $rows \ 589bc4a673fSDevin Teske $disk_check_list \ 590bc4a673fSDevin Teske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 591bc4a673fSDevin Teske ) || break 592bc4a673fSDevin Teske # Loop if user pressed ESC or chose Cancel/No 593bc4a673fSDevin Teske f_dialog_data_sanitize selections 594bc4a673fSDevin Teske 595bc4a673fSDevin Teske ZFSBOOT_DISKS="$selections" 596bc4a673fSDevin Teske f_dprintf "$funcname: ZFSBOOT_DISKS=[%s]" \ 597bc4a673fSDevin Teske "$ZFSBOOT_DISKS" 598bc4a673fSDevin Teske 599bc4a673fSDevin Teske ndisks=$( set -- $ZFSBOOT_DISKS; echo $# ) 600bc4a673fSDevin Teske [ $ndisks -ge $want_disks ] && 601bc4a673fSDevin Teske breakout=break && break 602bc4a673fSDevin Teske 603bc4a673fSDevin Teske # Not enough disks selected 604bc4a673fSDevin Teske f_dprintf "$funcname: %s: %s (%u < %u minimum)" \ 605bc4a673fSDevin Teske "$ZFSBOOT_VDEV_TYPE" \ 606bc4a673fSDevin Teske "Not enough disks selected." \ 607bc4a673fSDevin Teske $ndisks $want_disks 608bc4a673fSDevin Teske msg_yes="$msg_change_selection" msg_no="$msg_cancel" \ 609bc4a673fSDevin Teske f_yesno "%s: $msg_not_enough_disks_selected" \ 610bc4a673fSDevin Teske "$ZFSBOOT_VDEV_TYPE" $ndisks $want_disks || 611bc4a673fSDevin Teske break 612bc4a673fSDevin Teske done 613bc4a673fSDevin Teske [ "$breakout" = "break" ] && break 614bc4a673fSDevin Teske [ "$ZFSBOOT_CONFIRM_LAYOUT" ] || return $FAILURE 615bc4a673fSDevin Teske done 616bc4a673fSDevin Teske 617bc4a673fSDevin Teske return $DIALOG_OK 618cd88b886SDevin Teske} 619cd88b886SDevin Teske 620cd88b886SDevin Teske# zfs_create_diskpart $disk $index 621cd88b886SDevin Teske# 622cd88b886SDevin Teske# For each block device to be used in the zpool, rather than just create the 623cd88b886SDevin Teske# zpool with the raw block devices (e.g., da0, da1, etc.) we create partitions 624cd88b886SDevin Teske# so we can have some real swap. This also provides wiggle room incase your 625cd88b886SDevin Teske# replacement drivers do not have the exact same sector counts. 626cd88b886SDevin Teske# 627*7cae6aabSDevin Teske# NOTE: $swapsize and $bootsize should be defined by the calling function. 628a622223fSDevin Teske# NOTE: Sets $bootpart and $targetpart for the calling function. 629cd88b886SDevin Teske# 630cd88b886SDevin Teskezfs_create_diskpart() 631cd88b886SDevin Teske{ 632cd88b886SDevin Teske local funcname=zfs_create_diskpart 633bc4a673fSDevin Teske local disk="$1" index="$2" 634cd88b886SDevin Teske 635cd88b886SDevin Teske # Check arguments 636bc4a673fSDevin Teske if [ ! "$disk" ]; then 637bc4a673fSDevin Teske f_dprintf "$funcname: NULL disk argument" 638bc4a673fSDevin Teske msg_error="$msg_error: $funcname" \ 639bc4a673fSDevin Teske f_show_err "$msg_null_disk_argument" 640bc4a673fSDevin Teske return $FAILURE 641bc4a673fSDevin Teske fi 642bc4a673fSDevin Teske if [ "${disk#*[$IFS]}" != "$disk" ]; then 643bc4a673fSDevin Teske f_dprintf "$funcname: Invalid disk argument \`%s'" "$disk" 644bc4a673fSDevin Teske msg_error="$msg_error: $funcname" \ 645bc4a673fSDevin Teske f_show_err "$msg_invalid_disk_argument" "$disk" 646bc4a673fSDevin Teske return $FAILURE 647bc4a673fSDevin Teske fi 648bc4a673fSDevin Teske if [ ! "$index" ]; then 649bc4a673fSDevin Teske f_dprintf "$funcname: NULL index argument" 650bc4a673fSDevin Teske msg_error="$msg_error: $funcname" \ 651bc4a673fSDevin Teske f_show_err "$msg_null_index_argument" 652bc4a673fSDevin Teske return $FAILURE 653bc4a673fSDevin Teske fi 654bc4a673fSDevin Teske if ! f_isinteger "$index"; then 655bc4a673fSDevin Teske f_dprintf "$funcname: Invalid index argument \`%s'" "$index" 656bc4a673fSDevin Teske msg_error="$msg_error: $funcname" \ 657bc4a673fSDevin Teske f_show_err "$msg_invalid_index_argument" "$index" 658bc4a673fSDevin Teske return $FAILURE 659bc4a673fSDevin Teske fi 660bc4a673fSDevin Teske f_dprintf "$funcname: disk=[%s] index=[%s]" "$disk" "$index" 661cd88b886SDevin Teske 662d4d729e4SDevin Teske # Check for unknown partition scheme before proceeding further 663d4d729e4SDevin Teske case "$ZFSBOOT_PARTITION_SCHEME" in 664d4d729e4SDevin Teske ""|MBR|GPT) : known good ;; 665d4d729e4SDevin Teske *) 666d4d729e4SDevin Teske f_dprintf "$funcname: %s is an unsupported partition scheme" \ 667d4d729e4SDevin Teske "$ZFSBOOT_PARTITION_SCHEME" 668d4d729e4SDevin Teske msg_error="$msg_error: $funcname" f_show_err \ 669d4d729e4SDevin Teske "$msg_unsupported_partition_scheme" \ 670d4d729e4SDevin Teske "$ZFSBOOT_PARTITION_SCHEME" 671d4d729e4SDevin Teske return $FAILURE 672d4d729e4SDevin Teske esac 673d4d729e4SDevin Teske 674cd88b886SDevin Teske # 675cd88b886SDevin Teske # Destroy whatever partition layout is currently on disk. 676cd88b886SDevin Teske # NOTE: `-F' required to destroy if partitions still exist. 677cd88b886SDevin Teske # NOTE: Failure is ok here, blank disk will have nothing to destroy. 678cd88b886SDevin Teske # 679bc4a673fSDevin Teske f_dprintf "$funcname: Destroying all data/layouts on \`%s'..." "$disk" 680a622223fSDevin Teske f_eval_catch -d $funcname gpart "$GPART_DESTROY_F" $disk 681a622223fSDevin Teske f_eval_catch -d $funcname graid "$GRAID_DELETE" $disk 682a622223fSDevin Teske f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" /dev/$disk 683cd88b886SDevin Teske 684cd88b886SDevin Teske # Make doubly-sure backup GPT is destroyed 685a622223fSDevin Teske f_eval_catch -d $funcname gpart "$GPART_CREATE" gpt $disk 686a622223fSDevin Teske f_eval_catch -d $funcname gpart "$GPART_DESTROY_F" $disk 687cd88b886SDevin Teske 688*7cae6aabSDevin Teske # 689*7cae6aabSDevin Teske # Enable boot pool if encryption is desired 690*7cae6aabSDevin Teske # 691*7cae6aabSDevin Teske [ "$ZFSBOOT_GELI_ENCRYPTION" ] && ZFSBOOT_BOOT_POOL=1 692cd88b886SDevin Teske 693cd88b886SDevin Teske # 694cd88b886SDevin Teske # Lay down the desired type of partition scheme 695cd88b886SDevin Teske # 696cd88b886SDevin Teske local setsize mbrindex 697cd88b886SDevin Teske case "$ZFSBOOT_PARTITION_SCHEME" in 698bc4a673fSDevin Teske ""|GPT) f_dprintf "$funcname: Creating GPT layout..." 699cd88b886SDevin Teske # 700cd88b886SDevin Teske # 1. Create GPT layout using labels 701cd88b886SDevin Teske # 702a622223fSDevin Teske f_eval_catch $funcname gpart "$GPART_CREATE" gpt $disk || 703bc4a673fSDevin Teske return $FAILURE 704cd88b886SDevin Teske 705cd88b886SDevin Teske # 706cd88b886SDevin Teske # 2. Add small freebsd-boot partition labeled `boot#' 707cd88b886SDevin Teske # 708bc4a673fSDevin Teske f_eval_catch $funcname gpart "$GPART_ADD_LABEL_WITH_SIZE" \ 709a622223fSDevin Teske gptboot$index freebsd-boot 512k $disk || 710cd88b886SDevin Teske return $FAILURE 711bc4a673fSDevin Teske f_eval_catch $funcname gpart "$GPART_BOOTCODE_PART" \ 712a622223fSDevin Teske /boot/pmbr /boot/gptzfsboot 1 $disk || 713cd88b886SDevin Teske return $FAILURE 714cd88b886SDevin Teske 715a622223fSDevin Teske # NB: zpool will use the `zfs#' GPT labels 716cd88b886SDevin Teske bootpart=p2 targetpart=p2 717*7cae6aabSDevin Teske [ ${swapsize:-0} -gt 0 ] && targetpart=p3 718cd88b886SDevin Teske 719*7cae6aabSDevin Teske # 720*7cae6aabSDevin Teske # Prepare boot pool if enabled (e.g., for geli(8)) 721*7cae6aabSDevin Teske # 722*7cae6aabSDevin Teske if [ "$ZFSBOOT_BOOT_POOL" ]; then 723cd88b886SDevin Teske bootpart=p2 targetpart=p3 724*7cae6aabSDevin Teske [ ${swapsize:-0} -gt 0 ] && targetpart=p4 725bc4a673fSDevin Teske f_eval_catch $funcname gpart \ 726a622223fSDevin Teske "$GPART_ADD_LABEL_WITH_SIZE" boot$index \ 727*7cae6aabSDevin Teske freebsd-zfs ${bootsize}b $disk || 728bc4a673fSDevin Teske return $FAILURE 729*7cae6aabSDevin Teske # Pedantically nuke any old labels 730a622223fSDevin Teske f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ 731a622223fSDevin Teske /dev/$disk$bootpart 732*7cae6aabSDevin Teske if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then 733*7cae6aabSDevin Teske # Pedantically detach targetpart for later 734*7cae6aabSDevin Teske f_eval_catch -d $funcname geli \ 735*7cae6aabSDevin Teske "$GELI_DETACH_F" \ 736a622223fSDevin Teske /dev/$disk$targetpart 737cd88b886SDevin Teske fi 738*7cae6aabSDevin Teske fi 739cd88b886SDevin Teske 740cd88b886SDevin Teske # 741*7cae6aabSDevin Teske # 3. Add freebsd-swap partition labeled `swap#' 742cd88b886SDevin Teske # 743bc4a673fSDevin Teske if [ ${swapsize:-0} -gt 0 ]; then 744bc4a673fSDevin Teske f_eval_catch $funcname gpart \ 745*7cae6aabSDevin Teske "$GPART_ADD_LABEL_WITH_SIZE" swap$index \ 746*7cae6aabSDevin Teske freebsd-swap ${swapsize}b $disk || 747cd88b886SDevin Teske return $FAILURE 748cd88b886SDevin Teske # Update fstab(5) 749bc4a673fSDevin Teske f_eval_catch $funcname printf "$PRINTF_FSTAB" \ 750a622223fSDevin Teske /dev/gpt/swap$index none swap sw 0 0 \ 751a622223fSDevin Teske $BSDINSTALL_TMPETC/fstab || 752bc4a673fSDevin Teske return $FAILURE 753cd88b886SDevin Teske fi 754*7cae6aabSDevin Teske 755*7cae6aabSDevin Teske # 756*7cae6aabSDevin Teske # 4. Add freebsd-zfs partition labeled `zfs#' for zroot 757*7cae6aabSDevin Teske # 758*7cae6aabSDevin Teske f_eval_catch $funcname gpart "$GPART_ADD_LABEL" \ 759*7cae6aabSDevin Teske zfs$index freebsd-zfs $disk || return $FAILURE 760*7cae6aabSDevin Teske f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ 761*7cae6aabSDevin Teske /dev/$disk$targetpart 762cd88b886SDevin Teske ;; 763cd88b886SDevin Teske 764bc4a673fSDevin Teske MBR) f_dprintf "$funcname: Creating MBR layout..." 765cd88b886SDevin Teske # 766cd88b886SDevin Teske # 1. Create MBR layout (no labels) 767cd88b886SDevin Teske # 768a622223fSDevin Teske f_eval_catch $funcname gpart "$GPART_CREATE" mbr $disk || 769bc4a673fSDevin Teske return $FAILURE 7702925848dSDevin Teske f_eval_catch $funcname gpart "$GPART_BOOTCODE" /boot/mbr \ 771a622223fSDevin Teske $disk || return $FAILURE 772cd88b886SDevin Teske 773cd88b886SDevin Teske # 774cd88b886SDevin Teske # 2. Add freebsd slice with all available space 775cd88b886SDevin Teske # 776a622223fSDevin Teske f_eval_catch $funcname gpart "$GPART_ADD" freebsd $disk || 777bc4a673fSDevin Teske return $FAILURE 778a622223fSDevin Teske f_eval_catch $funcname gpart "$GPART_SET_ACTIVE" 1 $disk || 779bc4a673fSDevin Teske return $FAILURE 780a622223fSDevin Teske # Pedantically nuke any old labels 781a622223fSDevin Teske f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ 782a622223fSDevin Teske /dev/${disk}s1 783a622223fSDevin Teske # Pedantically nuke any old scheme 784a622223fSDevin Teske f_eval_catch -d $funcname gpart "$GPART_DESTROY_F" ${disk}s1 785cd88b886SDevin Teske 786cd88b886SDevin Teske # 787bc4a673fSDevin Teske # 3. Write BSD scheme to the freebsd slice 788cd88b886SDevin Teske # 789a622223fSDevin Teske f_eval_catch $funcname gpart "$GPART_CREATE" BSD ${disk}s1 || 790bc4a673fSDevin Teske return $FAILURE 791cd88b886SDevin Teske 792*7cae6aabSDevin Teske # NB: zpool will use s1a (no labels) 793*7cae6aabSDevin Teske bootpart=s1a targetpart=s1d mbrindex=4 794cd88b886SDevin Teske 795*7cae6aabSDevin Teske # 796*7cae6aabSDevin Teske # Always prepare a boot pool on MBR 797*7cae6aabSDevin Teske # 798*7cae6aabSDevin Teske ZFSBOOT_BOOT_POOL=1 799bc4a673fSDevin Teske f_eval_catch $funcname gpart \ 800bc4a673fSDevin Teske "$GPART_ADD_INDEX_WITH_SIZE" \ 801*7cae6aabSDevin Teske 1 freebsd-zfs ${bootsize}b ${disk}s1 || 802bc4a673fSDevin Teske return $FAILURE 803a622223fSDevin Teske # Pedantically nuke any old labels 804a622223fSDevin Teske f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ 805a622223fSDevin Teske /dev/$disk$bootpart 806*7cae6aabSDevin Teske if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then 807a622223fSDevin Teske # Pedantically detach targetpart for later 808a622223fSDevin Teske f_eval_catch -d $funcname geli \ 809a622223fSDevin Teske "$GELI_DETACH_F" \ 810a622223fSDevin Teske /dev/$disk$targetpart 811cd88b886SDevin Teske fi 812cd88b886SDevin Teske 813cd88b886SDevin Teske # 814*7cae6aabSDevin Teske # 4. Add freebsd-swap partition 815cd88b886SDevin Teske # 816bc4a673fSDevin Teske if [ ${swapsize:-0} -gt 0 ]; then 817bc4a673fSDevin Teske f_eval_catch $funcname gpart \ 818*7cae6aabSDevin Teske "$GPART_ADD_INDEX_WITH_SIZE" 2 \ 819*7cae6aabSDevin Teske freebsd-swap ${swapsize}b ${disk}s1 || 820cd88b886SDevin Teske return $FAILURE 821cd88b886SDevin Teske # Update fstab(5) 822bc4a673fSDevin Teske f_eval_catch $funcname printf "$PRINTF_FSTAB" \ 823a622223fSDevin Teske /dev/${disk}s1b none swap sw 0 0 \ 824a622223fSDevin Teske $BSDINSTALL_TMPETC/fstab || 825bc4a673fSDevin Teske return $FAILURE 826cd88b886SDevin Teske fi 827*7cae6aabSDevin Teske 828*7cae6aabSDevin Teske # 829*7cae6aabSDevin Teske # 5. Add freebsd-zfs partition for zroot 830*7cae6aabSDevin Teske # 831*7cae6aabSDevin Teske f_eval_catch $funcname gpart "$GPART_ADD_INDEX" \ 832*7cae6aabSDevin Teske $mbrindex freebsd-zfs ${disk}s1 || return $FAILURE 833*7cae6aabSDevin Teske f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ 834*7cae6aabSDevin Teske /dev/$disk$targetpart # Pedantic 835*7cae6aabSDevin Teske f_eval_catch $funcname dd "$DD_WITH_OPTIONS" \ 836*7cae6aabSDevin Teske /boot/zfsboot /dev/${disk}s1 count=1 || 837*7cae6aabSDevin Teske return $FAILURE 838cd88b886SDevin Teske ;; 839cd88b886SDevin Teske 840cd88b886SDevin Teske esac # $ZFSBOOT_PARTITION_SCHEME 841cd88b886SDevin Teske 842cd88b886SDevin Teske return $SUCCESS 843cd88b886SDevin Teske} 844cd88b886SDevin Teske 845bc4a673fSDevin Teske# zfs_create_boot $poolname $vdev_type $disks ... 846cd88b886SDevin Teske# 847cd88b886SDevin Teske# Creates boot pool and dataset layout. Returns error if something goes wrong. 848cd88b886SDevin Teske# Errors are printed to stderr for collection and display. 849cd88b886SDevin Teske# 850cd88b886SDevin Teskezfs_create_boot() 851cd88b886SDevin Teske{ 852cd88b886SDevin Teske local funcname=zfs_create_boot 853*7cae6aabSDevin Teske local zroot_name="$1" 854*7cae6aabSDevin Teske local zroot_vdevtype="$2" 855*7cae6aabSDevin Teske local zroot_vdevs= # Calculated below 856*7cae6aabSDevin Teske local boot_vdevs= # Used for geli(8) and/or MBR layouts 857a622223fSDevin Teske shift 2 # poolname vdev_type 858a622223fSDevin Teske local disks="$*" disk 859a622223fSDevin Teske local bootpart targetpart # Set by zfs_create_diskpart() below 860cd88b886SDevin Teske 861a622223fSDevin Teske # 862cd88b886SDevin Teske # Pedantic checks; should never be seen 863a622223fSDevin Teske # 864*7cae6aabSDevin Teske if [ ! "$zroot_name" ]; then 865bc4a673fSDevin Teske f_dprintf "$funcname: NULL poolname" 866bc4a673fSDevin Teske msg_error="$msg_error: $funcname" \ 867bc4a673fSDevin Teske f_show_err "$msg_null_poolname" 868cd88b886SDevin Teske return $FAILURE 869cd88b886SDevin Teske fi 870cd88b886SDevin Teske if [ $# -lt 1 ]; then 871bc4a673fSDevin Teske f_dprintf "$funcname: missing disk arguments" 872bc4a673fSDevin Teske msg_error="$msg_error: $funcname" \ 873bc4a673fSDevin Teske f_show_err "$msg_missing_disk_arguments" 874cd88b886SDevin Teske return $FAILURE 875cd88b886SDevin Teske fi 876bc4a673fSDevin Teske f_dprintf "$funcname: poolname=[%s] vdev_type=[%s]" \ 877*7cae6aabSDevin Teske "$zroot_name" "$zroot_vdevtype" 878cd88b886SDevin Teske 879a622223fSDevin Teske # 880cd88b886SDevin Teske # Initialize fstab(5) 881a622223fSDevin Teske # 882bc4a673fSDevin Teske f_dprintf "$funcname: Initializing temporary fstab(5) file..." 883a622223fSDevin Teske f_eval_catch $funcname sh "$SHELL_TRUNCATE" $BSDINSTALL_TMPETC/fstab || 884bc4a673fSDevin Teske return $FAILURE 885bc4a673fSDevin Teske f_eval_catch $funcname printf "$PRINTF_FSTAB" \ 886cd88b886SDevin Teske "# Device" Mountpoint FStype Options Dump "Pass#" \ 887a622223fSDevin Teske $BSDINSTALL_TMPETC/fstab || return $FAILURE 888cd88b886SDevin Teske 889a622223fSDevin Teske # 890cd88b886SDevin Teske # Expand SI units in desired sizes 891a622223fSDevin Teske # 892*7cae6aabSDevin Teske f_dprintf "$funcname: Expanding supplied size values..." 893*7cae6aabSDevin Teske local swapsize bootsize 894bc4a673fSDevin Teske if ! f_expand_number "$ZFSBOOT_SWAP_SIZE" swapsize; then 895bc4a673fSDevin Teske f_dprintf "$funcname: Invalid swap size \`%s'" \ 896bc4a673fSDevin Teske "$ZFSBOOT_SWAP_SIZE" 897bc4a673fSDevin Teske f_show_err "$msg_invalid_swap_size" "$ZFSBOOT_SWAP_SIZE" 898bc4a673fSDevin Teske return $FAILURE 899bc4a673fSDevin Teske fi 900*7cae6aabSDevin Teske if ! f_expand_number "$ZFSBOOT_BOOT_POOL_SIZE" bootsize; then 901*7cae6aabSDevin Teske f_dprintf "$funcname: Invalid boot pool size \`%s'" \ 902*7cae6aabSDevin Teske "$ZFSBOOT_BOOT_POOL_SIZE" 903*7cae6aabSDevin Teske f_show_err "$msg_invalid_boot_pool_size" \ 904*7cae6aabSDevin Teske "$ZFSBOOT_BOOT_POOL_SIZE" 905bc4a673fSDevin Teske return $FAILURE 906bc4a673fSDevin Teske fi 907bc4a673fSDevin Teske f_dprintf "$funcname: ZFSBOOT_SWAP_SIZE=[%s] swapsize=[%s]" \ 908bc4a673fSDevin Teske "$ZFSBOOT_SWAP_SIZE" "$swapsize" 909*7cae6aabSDevin Teske f_dprintf "$funcname: ZFSBOOT_BOOT_POOL_SIZE=[%s] bootsize=[%s]" \ 910*7cae6aabSDevin Teske "$ZFSBOOT_BOOT_POOL_SIZE" "$bootsize" 911cd88b886SDevin Teske 912a622223fSDevin Teske # 913*7cae6aabSDevin Teske # Prepare the disks and build pool device list(s) 914a622223fSDevin Teske # 915bc4a673fSDevin Teske f_dprintf "$funcname: Preparing disk partitions for ZFS pool..." 916*7cae6aabSDevin Teske [ "$ZFSBOOT_GNOP_4K_FORCE_ALIGN" ] && 917*7cae6aabSDevin Teske f_dprintf "$funcname: With 4k alignment using gnop(8)..." 918cd88b886SDevin Teske local n=0 919a622223fSDevin Teske for disk in $disks; do 920cd88b886SDevin Teske zfs_create_diskpart $disk $n || return $FAILURE 921a622223fSDevin Teske # Now $bootpart and $targetpart are set (suffix for $disk) 922cd88b886SDevin Teske 923*7cae6aabSDevin Teske # Forced 4k alignment support using Geom NOP (see gnop(8)) 924cd88b886SDevin Teske if [ "$ZFSBOOT_GNOP_4K_FORCE_ALIGN" ]; then 925*7cae6aabSDevin Teske if [ "$ZFSBOOT_BOOT_POOL" ]; then 926*7cae6aabSDevin Teske boot_vdevs="$boot_vdevs $disk$bootpart.nop" 927bc4a673fSDevin Teske f_eval_catch $funcname gnop "$GNOP_CREATE" \ 928*7cae6aabSDevin Teske $disk$bootpart || return $FAILURE 929cd88b886SDevin Teske fi 930*7cae6aabSDevin Teske # Don't gnop encrypted partition 931*7cae6aabSDevin Teske if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then 932*7cae6aabSDevin Teske zroot_vdevs="$zroot_vdevs $disk$targetpart.eli" 933cd88b886SDevin Teske else 934*7cae6aabSDevin Teske zroot_vdevs="$zroot_vdevs $disk$targetpart.nop" 935*7cae6aabSDevin Teske f_eval_catch $funcname gnop "$GNOP_CREATE" \ 936*7cae6aabSDevin Teske $disk$targetpart || 937*7cae6aabSDevin Teske return $FAILURE 938*7cae6aabSDevin Teske fi 939*7cae6aabSDevin Teske else 940*7cae6aabSDevin Teske if [ "$ZFSBOOT_BOOT_POOL" ]; then 941*7cae6aabSDevin Teske boot_vdevs="$boot_vdevs $disk$bootpart" 942*7cae6aabSDevin Teske fi 943*7cae6aabSDevin Teske zroot_vdevs="$zroot_vdevs $disk$targetpart" 944*7cae6aabSDevin Teske fi 945*7cae6aabSDevin Teske 946*7cae6aabSDevin Teske n=$(( $n + 1 )) 947*7cae6aabSDevin Teske done # disks 948*7cae6aabSDevin Teske 949*7cae6aabSDevin Teske # 950*7cae6aabSDevin Teske # If we need/want a boot pool, create it 951*7cae6aabSDevin Teske # 952*7cae6aabSDevin Teske if [ "$ZFSBOOT_BOOT_POOL" ]; then 953*7cae6aabSDevin Teske local bootpool_vdevtype= # Calculated below 954*7cae6aabSDevin Teske local bootpool_options= # Calculated below 955*7cae6aabSDevin Teske local bootpool_name="$ZFSBOOT_BOOT_POOL_NAME" 956*7cae6aabSDevin Teske local bootpool="$BSDINSTALL_CHROOT/$bootpool_name" 957*7cae6aabSDevin Teske local zroot_key="${ZFSBOOT_GELI_KEY_FILE#/}" 958*7cae6aabSDevin Teske 959*7cae6aabSDevin Teske f_dprintf "$funcname: Setting up boot pool..." 960cd88b886SDevin Teske [ "$ZFSBOOT_GELI_ENCRYPTION" ] && 961*7cae6aabSDevin Teske f_dprintf "$funcname: For encrypted root disk..." 962cd88b886SDevin Teske 963*7cae6aabSDevin Teske # Create parent directory for boot pool 964a622223fSDevin Teske f_eval_catch -d $funcname umount "$UMOUNT" /mnt 965bc4a673fSDevin Teske f_eval_catch $funcname mount "$MOUNT_TYPE" tmpfs none \ 966a622223fSDevin Teske $BSDINSTALL_CHROOT || return $FAILURE 967cd88b886SDevin Teske 968*7cae6aabSDevin Teske # Create mirror across the boot partition on all disks 969*7cae6aabSDevin Teske [ $( set -- $boot_vdevs; echo $# ) -gt 1 ] && 970*7cae6aabSDevin Teske bootpool_vdevtype=mirror 971cd88b886SDevin Teske 972*7cae6aabSDevin Teske bootpool_options="-o altroot=$BSDINSTALL_CHROOT" 973*7cae6aabSDevin Teske bootpool_options="$bootpool_options -m \"/$bootpool_name\" -f" 974bc4a673fSDevin Teske f_eval_catch $funcname zpool "$ZPOOL_CREATE_WITH_OPTIONS" \ 975*7cae6aabSDevin Teske "$bootpool_options" "$bootpool_name" \ 976*7cae6aabSDevin Teske $bootpool_vdevtype $boot_vdevs || return $FAILURE 97745df402eSDevin Teske 978*7cae6aabSDevin Teske f_eval_catch $funcname mkdir "$MKDIR_P" "$bootpool/boot" || 979cd88b886SDevin Teske return $FAILURE 980cd88b886SDevin Teske 981*7cae6aabSDevin Teske if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then 982cd88b886SDevin Teske # Generate an encryption key using random(4) 983bc4a673fSDevin Teske f_eval_catch $funcname dd "$DD_WITH_OPTIONS" \ 984*7cae6aabSDevin Teske /dev/random "$bootpool/$zroot_key" \ 985*7cae6aabSDevin Teske "bs=4096 count=1" || return $FAILURE 986*7cae6aabSDevin Teske else 987*7cae6aabSDevin Teske # Clean up 988*7cae6aabSDevin Teske f_eval_catch $funcname zfs "$ZFS_UNMOUNT" \ 989*7cae6aabSDevin Teske "$bootpool_name" || return $FAILURE 990*7cae6aabSDevin Teske f_eval_catch -d $funcname umount "$UMOUNT" /mnt # tmpfs 991*7cae6aabSDevin Teske fi 992*7cae6aabSDevin Teske 993*7cae6aabSDevin Teske fi 994cd88b886SDevin Teske 995a622223fSDevin Teske # 996cd88b886SDevin Teske # Create the geli(8) GEOMS 997a622223fSDevin Teske # 998*7cae6aabSDevin Teske if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then 999*7cae6aabSDevin Teske # Prompt user for password (twice) 1000bc4a673fSDevin Teske if ! msg_enter_new_password="$msg_geli_password" \ 1001bc4a673fSDevin Teske f_dialog_input_password 1002bc4a673fSDevin Teske then 1003bc4a673fSDevin Teske f_dprintf "$funcname: User cancelled" 1004bc4a673fSDevin Teske f_show_err "$msg_user_cancelled" 1005bc4a673fSDevin Teske return $FAILURE 1006bc4a673fSDevin Teske fi 1007a622223fSDevin Teske 1008a622223fSDevin Teske # Initialize geli(8) on each of the target partitions 1009bc4a673fSDevin Teske for disk in $disks; do 1010cd88b886SDevin Teske f_dialog_info "$msg_geli_setup" \ 1011cd88b886SDevin Teske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 1012a622223fSDevin Teske if ! echo "$pw_password" | f_eval_catch \ 1013a622223fSDevin Teske $funcname geli "$GELI_PASSWORD_INIT" \ 1014*7cae6aabSDevin Teske "$bootpool/boot/$disk$targetpart.eli" \ 1015*7cae6aabSDevin Teske AES-XTS "$bootpool/$zroot_key" \ 1016a622223fSDevin Teske $disk$targetpart 1017bc4a673fSDevin Teske then 1018bc4a673fSDevin Teske f_interactive || f_die 1019a622223fSDevin Teske unset pw_password # Sensitive info 1020cd88b886SDevin Teske return $FAILURE 1021bc4a673fSDevin Teske fi 1022a622223fSDevin Teske if ! echo "$pw_password" | f_eval_catch \ 1023a622223fSDevin Teske $funcname geli "$GELI_ATTACH" \ 1024*7cae6aabSDevin Teske "$bootpool/$zroot_key" $disk$targetpart 1025bc4a673fSDevin Teske then 1026bc4a673fSDevin Teske f_interactive || f_die 1027a622223fSDevin Teske unset pw_password # Sensitive info 1028bc4a673fSDevin Teske return $FAILURE 1029bc4a673fSDevin Teske fi 1030cd88b886SDevin Teske done 1031a622223fSDevin Teske unset pw_password # Sensitive info 1032a622223fSDevin Teske 1033a622223fSDevin Teske # Clean up 1034*7cae6aabSDevin Teske f_eval_catch $funcname zfs "$ZFS_UNMOUNT" "$bootpool_name" || 1035*7cae6aabSDevin Teske return $FAILURE 1036a622223fSDevin Teske f_eval_catch -d $funcname umount "$UMOUNT" /mnt # tmpfs 1037cd88b886SDevin Teske fi 1038cd88b886SDevin Teske 1039cd88b886SDevin Teske # 1040a622223fSDevin Teske # Create the ZFS root pool with desired type and disk devices 1041cd88b886SDevin Teske # 1042*7cae6aabSDevin Teske f_dprintf "$funcname: Creating root pool..." 1043bc4a673fSDevin Teske f_eval_catch $funcname zpool "$ZPOOL_CREATE_WITH_OPTIONS" \ 1044a622223fSDevin Teske "-o altroot=$BSDINSTALL_CHROOT -m none -f" \ 1045*7cae6aabSDevin Teske "$zroot_name" $zroot_vdevtype $zroot_vdevs 1046cd88b886SDevin Teske 1047*7cae6aabSDevin Teske # Customize the zroot a bit... 1048bc4a673fSDevin Teske local option 1049*7cae6aabSDevin Teske f_dprintf "$funcname: Setting miscellaneous options on root pool..." 1050bc4a673fSDevin Teske for option in checksum=fletcher4 atime=off; do 1051*7cae6aabSDevin Teske f_eval_catch $funcname zfs "$ZFS_SET" $option "$zroot_name" || 1052bc4a673fSDevin Teske return $FAILURE 1053bc4a673fSDevin Teske done 1054cd88b886SDevin Teske 1055cd88b886SDevin Teske # 1056*7cae6aabSDevin Teske # Create ZFS dataset layout within the new root pool 1057cd88b886SDevin Teske # 1058bc4a673fSDevin Teske f_dprintf "$funcname: Creating ZFS datasets..." 1059cd88b886SDevin Teske echo "$ZFSBOOT_DATASETS" | while read dataset options; do 1060cd88b886SDevin Teske # Skip blank lines and comments 1061cd88b886SDevin Teske case "$dataset" in "#"*|"") continue; esac 1062cd88b886SDevin Teske # Remove potential inline comments in options 1063cd88b886SDevin Teske options="${options%%#*}" 1064cd88b886SDevin Teske # Replace tabs with spaces 1065cd88b886SDevin Teske f_replaceall "$options" " " " " options 1066cd88b886SDevin Teske # Reduce contiguous runs of space to one single space 1067cd88b886SDevin Teske oldoptions= 1068cd88b886SDevin Teske while [ "$oldoptions" != "$options" ]; do 1069cd88b886SDevin Teske oldoptions="$options" 1070cd88b886SDevin Teske f_replaceall "$options" " " " " options 1071cd88b886SDevin Teske done 1072cd88b886SDevin Teske # Replace both commas and spaces with ` -o ' 1073cd88b886SDevin Teske f_replaceall "$options" "[ ,]" " -o " options 1074cd88b886SDevin Teske # Create the dataset with desired options 1075bc4a673fSDevin Teske f_eval_catch $funcname zfs "$ZFS_CREATE_WITH_OPTIONS" \ 1076*7cae6aabSDevin Teske "${options:+-o $options}" "$zroot_name$dataset" || 1077cd88b886SDevin Teske return $FAILURE 1078cd88b886SDevin Teske done 1079cd88b886SDevin Teske 1080cd88b886SDevin Teske # Touch up permissions on the tmp directories 1081bc4a673fSDevin Teske f_dprintf "$funcname: Modifying directory permissions..." 1082bc4a673fSDevin Teske local dir 1083bc4a673fSDevin Teske for dir in /tmp /var/tmp; do 1084bc4a673fSDevin Teske f_eval_catch $funcname chmod "$CHMOD_MODE" 1777 \ 1085a622223fSDevin Teske $BSDINSTALL_CHROOTDIR$dir || return $FAILURE 1086bc4a673fSDevin Teske done 1087cd88b886SDevin Teske 1088cd88b886SDevin Teske # Create symlink(s) 1089*7cae6aabSDevin Teske if [ "$ZFSBOOT_BOOT_POOL" ]; then 1090*7cae6aabSDevin Teske f_dprintf "$funcname: Creating /boot symlink for boot pool..." 1091*7cae6aabSDevin Teske f_eval_catch $funcname ln "$LN_SF" "$bootpool_name/boot" \ 1092a622223fSDevin Teske $BSDINSTALL_CHROOT/boot || return $FAILURE 1093bc4a673fSDevin Teske fi 1094cd88b886SDevin Teske 1095cd88b886SDevin Teske # Set bootfs property 1096*7cae6aabSDevin Teske local zroot_bootfs="$ZFSBOOT_BEROOT_NAME/$ZFSBOOT_BOOTFS_NAME" 1097bc4a673fSDevin Teske f_dprintf "$funcname: Setting bootfs property..." 1098bc4a673fSDevin Teske f_eval_catch $funcname zpool "$ZPOOL_SET" \ 1099*7cae6aabSDevin Teske "bootfs=\"$zroot_name/$zroot_bootfs\"" "$zroot_name" || 1100*7cae6aabSDevin Teske return $FAILURE 1101cd88b886SDevin Teske 1102cd88b886SDevin Teske # Export the pool(s) 1103bc4a673fSDevin Teske f_dprintf "$funcname: Temporarily exporting ZFS pool(s)..." 1104*7cae6aabSDevin Teske f_eval_catch $funcname zpool "$ZPOOL_EXPORT" "$zroot_name" || 1105bc4a673fSDevin Teske return $FAILURE 1106*7cae6aabSDevin Teske if [ "$ZFSBOOT_BOOT_POOL" ]; then 1107bc4a673fSDevin Teske f_eval_catch $funcname zpool "$ZPOOL_EXPORT" \ 1108*7cae6aabSDevin Teske "$bootpool_name" || return $FAILURE 1109bc4a673fSDevin Teske fi 1110cd88b886SDevin Teske 1111cd88b886SDevin Teske # Destroy the gnop devices (if enabled) 1112bc4a673fSDevin Teske for disk in ${ZFSBOOT_GNOP_4K_FORCE_ALIGN:+$disks}; do 1113*7cae6aabSDevin Teske if [ "$ZFSBOOT_BOOT_POOL" ]; then 1114a622223fSDevin Teske f_eval_catch -d $funcname gnop "$GNOP_DESTROY" \ 1115a622223fSDevin Teske $disk$bootpart.nop 1116*7cae6aabSDevin Teske fi 1117*7cae6aabSDevin Teske if [ ! "$ZFSBOOT_GELI_ENCRYPTION" ]; then 1118a622223fSDevin Teske f_eval_catch -d $funcname gnop "$GNOP_DESTROY" \ 1119a622223fSDevin Teske $disk$targetpart.nop 1120cd88b886SDevin Teske fi 1121cd88b886SDevin Teske done 1122cd88b886SDevin Teske 1123*7cae6aabSDevin Teske # MBR boot loader touch-up 1124cd88b886SDevin Teske if [ "$ZFSBOOT_PARTITION_SCHEME" = "MBR" ]; then 1125bc4a673fSDevin Teske f_dprintf "$funcname: Updating MBR boot loader on disks..." 1126cd88b886SDevin Teske # Stick the ZFS boot loader in the "convienient hole" after 1127cd88b886SDevin Teske # the ZFS internal metadata 1128bc4a673fSDevin Teske for disk in $disks; do 1129bc4a673fSDevin Teske f_eval_catch $funcname dd "$DD_WITH_OPTIONS" \ 1130a622223fSDevin Teske /boot/zfsboot /dev/$disk$bootpart \ 1131bc4a673fSDevin Teske "skip=1 seek=1024" || return $FAILURE 1132cd88b886SDevin Teske done 1133cd88b886SDevin Teske fi 1134cd88b886SDevin Teske 1135cd88b886SDevin Teske # Re-import the ZFS pool(s) 1136bc4a673fSDevin Teske f_dprintf "$funcname: Re-importing ZFS pool(s)..." 1137bc4a673fSDevin Teske f_eval_catch $funcname zpool "$ZPOOL_IMPORT_WITH_OPTIONS" \ 1138*7cae6aabSDevin Teske "-o altroot=\"$BSDINSTALL_CHROOT\"" "$zroot_name" || 1139bc4a673fSDevin Teske return $FAILURE 1140*7cae6aabSDevin Teske if [ "$ZFSBOOT_BOOT_POOL" ]; then 1141bc4a673fSDevin Teske f_eval_catch $funcname zpool "$ZPOOL_IMPORT_WITH_OPTIONS" \ 1142*7cae6aabSDevin Teske "-o altroot=\"$BSDINSTALL_CHROOT\"" \ 1143*7cae6aabSDevin Teske "$bootpool_name" || return $FAILURE 1144bc4a673fSDevin Teske fi 1145cd88b886SDevin Teske 1146cd88b886SDevin Teske # While this is apparently not needed, it seems to help MBR 1147bc4a673fSDevin Teske f_dprintf "$funcname: Configuring zpool.cache..." 1148a622223fSDevin Teske f_eval_catch $funcname mkdir "$MKDIR_P" $BSDINSTALL_CHROOT/boot/zfs || 1149bc4a673fSDevin Teske return $FAILURE 1150bc4a673fSDevin Teske f_eval_catch $funcname zpool "$ZPOOL_SET" \ 1151a622223fSDevin Teske "cachefile=\"$BSDINSTALL_CHROOT/boot/zfs/zpool.cache\"" \ 1152*7cae6aabSDevin Teske "$zroot_name" || return $FAILURE 1153cd88b886SDevin Teske 115413d8e1ceSDevin Teske # Last, but not least... required lines for rc.conf(5)/loader.conf(5) 1155cd88b886SDevin Teske # NOTE: We later concatenate these into their destination 1156bc4a673fSDevin Teske f_dprintf "%s: Configuring rc.conf(5)/loader.conf(5) additions..." \ 1157bc4a673fSDevin Teske "$funcname" 1158bc4a673fSDevin Teske f_eval_catch $funcname echo "$ECHO_APPEND" 'zfs_enable=\"YES\"' \ 1159a622223fSDevin Teske $BSDINSTALL_TMPETC/rc.conf.zfs || return $FAILURE 1160bc4a673fSDevin Teske f_eval_catch $funcname echo "$ECHO_APPEND" 'zfs_load=\"YES\"' \ 1161a622223fSDevin Teske $BSDINSTALL_TMPBOOT/loader.conf.zfs || return $FAILURE 1162cd88b886SDevin Teske 1163*7cae6aabSDevin Teske # We're all done unless we should go on for boot pool 1164*7cae6aabSDevin Teske [ "$ZFSBOOT_BOOT_POOL" ] || return $SUCCESS 1165cd88b886SDevin Teske 1166bc4a673fSDevin Teske # Some additional geli(8) requirements for loader.conf(5) 1167bc4a673fSDevin Teske for option in \ 1168a622223fSDevin Teske 'zpool_cache_load=\"YES\"' \ 1169a622223fSDevin Teske 'zpool_cache_type=\"/boot/zfs/zpool.cache\"' \ 1170a622223fSDevin Teske 'zpool_cache_name=\"/boot/zfs/zpool.cache\"' \ 1171bc4a673fSDevin Teske ; do 1172a622223fSDevin Teske f_eval_catch $funcname echo "$ECHO_APPEND" "$option" \ 1173a622223fSDevin Teske $BSDINSTALL_TMPBOOT/loader.conf.zfs || 1174bc4a673fSDevin Teske return $FAILURE 1175bc4a673fSDevin Teske done 1176*7cae6aabSDevin Teske f_eval_catch $funcname printf "$PRINTF_CONF" vfs.root.mountfrom \ 1177*7cae6aabSDevin Teske "\"zfs:$zroot_name/$zroot_bootfs\"" \ 1178*7cae6aabSDevin Teske $BSDINSTALL_TMPBOOT/loader.conf.root || return $FAILURE 1179*7cae6aabSDevin Teske 1180*7cae6aabSDevin Teske # We're all done unless we should go on to do encryption 1181*7cae6aabSDevin Teske [ "$ZFSBOOT_GELI_ENCRYPTION" ] || return $SUCCESS 118213d8e1ceSDevin Teske 1183cd88b886SDevin Teske # 1184cd88b886SDevin Teske # Configure geli(8)-based encryption 1185cd88b886SDevin Teske # 1186bc4a673fSDevin Teske f_dprintf "$funcname: Configuring disk encryption..." 1187bc4a673fSDevin Teske f_eval_catch $funcname echo "$ECHO_APPEND" 'aesni_load=\"YES\"' \ 1188a622223fSDevin Teske $BSDINSTALL_TMPBOOT/loader.conf.aesni || return $FAILURE 1189bc4a673fSDevin Teske f_eval_catch $funcname echo "$ECHO_APPEND" 'geom_eli_load=\"YES\"' \ 1190a622223fSDevin Teske $BSDINSTALL_TMPBOOT/loader.conf.geli || return $FAILURE 1191bc4a673fSDevin Teske for disk in $disks; do 1192bc4a673fSDevin Teske f_eval_catch $funcname printf "$PRINTF_CONF" \ 1193a622223fSDevin Teske geli_%s_keyfile0_load "$disk$targetpart YES" \ 1194a622223fSDevin Teske $BSDINSTALL_TMPBOOT/loader.conf.$disk$targetpart || 1195cd88b886SDevin Teske return $FAILURE 1196bc4a673fSDevin Teske f_eval_catch $funcname printf "$PRINTF_CONF" \ 1197bc4a673fSDevin Teske geli_%s_keyfile0_type \ 1198a622223fSDevin Teske "$disk$targetpart $disk$targetpart:geli_keyfile0" \ 1199a622223fSDevin Teske $BSDINSTALL_TMPBOOT/loader.conf.$disk$targetpart || 1200cd88b886SDevin Teske return $FAILURE 1201bc4a673fSDevin Teske f_eval_catch $funcname printf "$PRINTF_CONF" \ 1202bc4a673fSDevin Teske geli_%s_keyfile0_name \ 1203a622223fSDevin Teske "$disk$targetpart \"$ZFSBOOT_GELI_KEY_FILE\"" \ 1204a622223fSDevin Teske $BSDINSTALL_TMPBOOT/loader.conf.$disk$targetpart || 1205cd88b886SDevin Teske return $FAILURE 1206cd88b886SDevin Teske done 1207cd88b886SDevin Teske 1208cd88b886SDevin Teske return $SUCCESS 1209cd88b886SDevin Teske} 1210cd88b886SDevin Teske 1211cd88b886SDevin Teske# dialog_menu_diskinfo 1212cd88b886SDevin Teske# 1213cd88b886SDevin Teske# Prompt the user to select a disk and then provide detailed info on it. 1214cd88b886SDevin Teske# 1215cd88b886SDevin Teskedialog_menu_diskinfo() 1216cd88b886SDevin Teske{ 1217cd88b886SDevin Teske local disk 1218cd88b886SDevin Teske 1219cd88b886SDevin Teske # 1220cd88b886SDevin Teske # Break from loop when user cancels disk selection 1221cd88b886SDevin Teske # 1222cd88b886SDevin Teske while :; do 1223cd88b886SDevin Teske disk=$( msg_cancel="$msg_back" f_device_menu \ 1224cd88b886SDevin Teske "$DIALOG_TITLE" "$msg_select_a_disk_device" "" \ 1225cd88b886SDevin Teske $DEVICE_TYPE_DISK 2>&1 ) || break 1226cd88b886SDevin Teske 1227cd88b886SDevin Teske # Show gpart(8) `show' and camcontrol(8) `inquiry' data 1228cd88b886SDevin Teske f_show_msg "$msg_detailed_disk_info" \ 1229cd88b886SDevin Teske "$disk" "$( gpart show $disk 2> /dev/null )" \ 1230cd88b886SDevin Teske "$disk" "$( camcontrol inquiry $disk 2> /dev/null )" \ 1231cd88b886SDevin Teske "$disk" "$( camcontrol identify $disk 2> /dev/null )" 1232cd88b886SDevin Teske done 1233cd88b886SDevin Teske 1234cd88b886SDevin Teske return $SUCCESS 1235cd88b886SDevin Teske} 1236cd88b886SDevin Teske 1237cd88b886SDevin Teske############################################################ MAIN 1238cd88b886SDevin Teske 1239cd88b886SDevin Teske# 1240cd88b886SDevin Teske# Initialize 1241cd88b886SDevin Teske# 1242cd88b886SDevin Teskef_dialog_title "$msg_zfs_configuration" 1243cd88b886SDevin Teskef_dialog_backtitle "$msg_freebsd_installer" 1244cd88b886SDevin Teske 1245cd88b886SDevin Teske# User may have specifically requested ZFS-related operations be interactive 1246cd88b886SDevin Teske! f_interactive && f_zfsinteractive && unset $VAR_NONINTERACTIVE 1247cd88b886SDevin Teske 1248cd88b886SDevin Teske# 1249bc4a673fSDevin Teske# Debugging 1250bc4a673fSDevin Teske# 1251bc4a673fSDevin Teskef_dprintf "BSDINSTALL_CHROOT=[%s]" "$BSDINSTALL_CHROOT" 1252bc4a673fSDevin Teskef_dprintf "BSDINSTALL_TMPETC=[%s]" "$BSDINSTALL_TMPETC" 1253a622223fSDevin Teskef_dprintf "FSTAB_FMT=[%s]" "$FSTAB_FMT" 1254bc4a673fSDevin Teske 1255bc4a673fSDevin Teske# 1256cd88b886SDevin Teske# Loop over the main menu until we've accomplished what we came here to do 1257cd88b886SDevin Teske# 1258cd88b886SDevin Teskewhile :; do 1259cd88b886SDevin Teske if ! f_interactive; then 1260cd88b886SDevin Teske retval=$DIALOG_OK 1261bc4a673fSDevin Teske mtag=">>> $msg_install" 1262cd88b886SDevin Teske else 1263cd88b886SDevin Teske dialog_menu_main 1264cd88b886SDevin Teske retval=$? 1265cd88b886SDevin Teske f_dialog_menutag_fetch mtag 1266cd88b886SDevin Teske fi 1267cd88b886SDevin Teske 1268bc4a673fSDevin Teske f_dprintf "retval=%u mtag=[%s]" $retval "$mtag" 1269cd88b886SDevin Teske [ $retval -eq $DIALOG_OK ] || f_die 1270cd88b886SDevin Teske 1271cd88b886SDevin Teske case "$mtag" in 1272bc4a673fSDevin Teske ">>> $msg_install") 1273cd88b886SDevin Teske # 1274cd88b886SDevin Teske # First, validate the user's selections 1275cd88b886SDevin Teske # 1276cd88b886SDevin Teske 1277cd88b886SDevin Teske # Make sure they gave us a name for the pool 1278cd88b886SDevin Teske if [ ! "$ZFSBOOT_POOL_NAME" ]; then 1279bc4a673fSDevin Teske f_dprintf "Pool name cannot be empty." 1280bc4a673fSDevin Teske f_show_err "$msg_pool_name_cannot_be_empty" 1281cd88b886SDevin Teske continue 1282cd88b886SDevin Teske fi 1283bc4a673fSDevin Teske 1284bc4a673fSDevin Teske # Validate vdev type against number of disks selected/scripted 1285bc4a673fSDevin Teske # (also validates that ZFSBOOT_DISKS are real [probed] disks) 1286bc4a673fSDevin Teske # NB: dialog_menu_layout supports running non-interactively 1287bc4a673fSDevin Teske dialog_menu_layout || continue 1288bc4a673fSDevin Teske 1289cd88b886SDevin Teske # Make sure each disk will be at least 50% ZFS 1290cd88b886SDevin Teske if f_expand_number "$ZFSBOOT_SWAP_SIZE" swapsize && 1291*7cae6aabSDevin Teske f_expand_number "$ZFSBOOT_BOOT_POOL_SIZE" bootsize 1292cd88b886SDevin Teske then 1293cd88b886SDevin Teske minsize=$swapsize teeny_disks= 1294*7cae6aabSDevin Teske [ "$ZFSBOOT_BOOT_POOL" ] && 1295*7cae6aabSDevin Teske minsize=$(( $minsize + $bootsize )) 1296bc4a673fSDevin Teske for disk in $ZFSBOOT_DISKS; do 1297cd88b886SDevin Teske device_$disk get capacity disksize || continue 1298cd88b886SDevin Teske disksize=$(( $disksize - $minsize )) 1299cd88b886SDevin Teske [ $disksize -lt $minsize ] && 1300cd88b886SDevin Teske teeny_disks="$teeny_disks $disk" 1301cd88b886SDevin Teske done 1302cd88b886SDevin Teske if [ "$teeny_disks" ]; then 1303*7cae6aabSDevin Teske f_dprintf "swapsize=[%s] bootsize[%s] %s" \ 1304bc4a673fSDevin Teske "$ZFSBOOT_SWAP_SIZE" \ 1305*7cae6aabSDevin Teske "$ZFSBOOT_BOOT_POOL_SIZE" \ 1306*7cae6aabSDevin Teske "minsize=[$minsize]" 1307bc4a673fSDevin Teske f_dprintf "These disks are too small: %s" \ 1308bc4a673fSDevin Teske "$teeny_disks" 1309bc4a673fSDevin Teske f_show_err "$msg_these_disks_are_too_small" \ 1310cd88b886SDevin Teske "$ZFSBOOT_SWAP_SIZE" \ 1311*7cae6aabSDevin Teske "$ZFSBOOT_BOOT_POOL_SIZE" \ 1312cd88b886SDevin Teske "$teeny_disks" 1313cd88b886SDevin Teske continue 1314cd88b886SDevin Teske fi 1315cd88b886SDevin Teske fi 1316cd88b886SDevin Teske 1317cd88b886SDevin Teske # 1318cd88b886SDevin Teske # Last Chance! 1319cd88b886SDevin Teske # 1320bc4a673fSDevin Teske if f_interactive; then 1321bc4a673fSDevin Teske dialog_last_chance $ZFSBOOT_DISKS || continue 1322cd88b886SDevin Teske fi 1323cd88b886SDevin Teske 1324cd88b886SDevin Teske # 1325cd88b886SDevin Teske # Let's do this 1326cd88b886SDevin Teske # 1327cd88b886SDevin Teske 1328cd88b886SDevin Teske vdev_type="$ZFSBOOT_VDEV_TYPE" 1329cd88b886SDevin Teske 1330cd88b886SDevin Teske # Blank the vdev type for the default layout 1331cd88b886SDevin Teske [ "$vdev_type" = "stripe" ] && vdev_type= 1332cd88b886SDevin Teske 1333bc4a673fSDevin Teske zfs_create_boot "$ZFSBOOT_POOL_NAME" \ 1334bc4a673fSDevin Teske "$vdev_type" $ZFSBOOT_DISKS || continue 1335cd88b886SDevin Teske 1336cd88b886SDevin Teske break # to success 1337cd88b886SDevin Teske ;; 1338bc4a673fSDevin Teske ?" $msg_pool_type_disks") 1339bc4a673fSDevin Teske ZFSBOOT_CONFIRM_LAYOUT=1 1340bc4a673fSDevin Teske dialog_menu_layout 1341bc4a673fSDevin Teske # User has poked settings, disable later confirmation 1342bc4a673fSDevin Teske ZFSBOOT_CONFIRM_LAYOUT= 1343bc4a673fSDevin Teske ;; 1344cd88b886SDevin Teske "- $msg_rescan_devices") f_device_rescan ;; 1345cd88b886SDevin Teske "- $msg_disk_info") dialog_menu_diskinfo ;; 1346cd88b886SDevin Teske ?" $msg_pool_name") 1347cd88b886SDevin Teske # Prompt the user to input/change the name for the new pool 1348cd88b886SDevin Teske f_dialog_input input \ 1349cd88b886SDevin Teske "$msg_please_enter_a_name_for_your_zpool" \ 1350cd88b886SDevin Teske "$ZFSBOOT_POOL_NAME" && 1351cd88b886SDevin Teske ZFSBOOT_POOL_NAME="$input" 1352cd88b886SDevin Teske ;; 1353cd88b886SDevin Teske ?" $msg_force_4k_sectors") 1354cd88b886SDevin Teske # Toggle the variable referenced both by the menu and later 1355cd88b886SDevin Teske if [ "$ZFSBOOT_GNOP_4K_FORCE_ALIGN" ]; then 1356cd88b886SDevin Teske ZFSBOOT_GNOP_4K_FORCE_ALIGN= 1357cd88b886SDevin Teske else 1358cd88b886SDevin Teske ZFSBOOT_GNOP_4K_FORCE_ALIGN=1 1359cd88b886SDevin Teske fi 1360cd88b886SDevin Teske ;; 1361bc4a673fSDevin Teske ?" $msg_encrypt_disks") 1362cd88b886SDevin Teske # Toggle the variable referenced both by the menu and later 1363cd88b886SDevin Teske if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then 1364cd88b886SDevin Teske ZFSBOOT_GELI_ENCRYPTION= 1365cd88b886SDevin Teske else 1366cd88b886SDevin Teske ZFSBOOT_GELI_ENCRYPTION=1 1367cd88b886SDevin Teske fi 1368cd88b886SDevin Teske ;; 1369cd88b886SDevin Teske ?" $msg_partition_scheme") 1370cd88b886SDevin Teske # Toggle between GPT and MBR 1371cd88b886SDevin Teske if [ "$ZFSBOOT_PARTITION_SCHEME" = GPT ]; then 1372cd88b886SDevin Teske ZFSBOOT_PARTITION_SCHEME=MBR 1373cd88b886SDevin Teske else 1374cd88b886SDevin Teske ZFSBOOT_PARTITION_SCHEME=GPT 1375cd88b886SDevin Teske fi 1376cd88b886SDevin Teske ;; 1377cd88b886SDevin Teske ?" $msg_swap_size") 1378cd88b886SDevin Teske # Prompt the user to input/change the swap size for each disk 1379cd88b886SDevin Teske f_dialog_input input \ 1380cd88b886SDevin Teske "$msg_please_enter_amount_of_swap_space" \ 1381cd88b886SDevin Teske "$ZFSBOOT_SWAP_SIZE" && 138230c8ebe9SDevin Teske ZFSBOOT_SWAP_SIZE="${input:-0}" 1383cd88b886SDevin Teske ;; 1384cd88b886SDevin Teske esac 1385cd88b886SDevin Teskedone 1386cd88b886SDevin Teske 1387cd88b886SDevin Teskereturn $SUCCESS 1388cd88b886SDevin Teske 1389cd88b886SDevin Teske################################################################################ 1390cd88b886SDevin Teske# END 1391cd88b886SDevin Teske################################################################################ 1392