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