zfsboot (257507) | zfsboot (258421) |
---|---|
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 --- 11 unchanged lines hidden (view full) --- 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 --- 11 unchanged lines hidden (view full) --- 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 257507 2013-11-01 15:54:57Z gjb $ | 28# $FreeBSD: stable/10/usr.sbin/bsdinstall/scripts/zfsboot 258421 2013-11-21 03:40:52Z 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 --- 5 unchanged lines hidden (view full) --- 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# | 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 --- 5 unchanged lines hidden (view full) --- 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:=bootenv} | 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# | 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# |
70: ${ZFSBOOT_GELI_ENCRYPTION:=} | 70: ${ZFSBOOT_GELI_ENCRYPTION=} |
71 72# 73# Default name the unencrypted pool when using geli(8) to encrypt the drives 74# 75: ${ZFSBOOT_GELI_POOL_NAME:=bootpool} 76 77# 78# Default size for the unencrypted boot pool when using geli(8) --- 17 unchanged lines hidden (view full) --- 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# | 71 72# 73# Default name the unencrypted pool when using geli(8) to encrypt the drives 74# 75: ${ZFSBOOT_GELI_POOL_NAME:=bootpool} 76 77# 78# Default size for the unencrypted boot pool when using geli(8) --- 17 unchanged lines hidden (view full) --- 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 layout for root zpool | 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 | 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 /usr/local # local files (i.e. from packages) separate from base system 123 | |
124 # Home directories separated so they are common to all BEs | 122 # Home directories separated so they are common to all BEs |
125 /usr/home setuid=off | 123 /usr/home # NB: /home is a symlink to /usr/home |
126 127 # Ports tree 128 /usr/ports compression=lz4,setuid=off | 124 125 # Ports tree 126 /usr/ports compression=lz4,setuid=off |
129 /usr/ports/distfiles compression=off,exec=off,setuid=off 130 /usr/ports/packages compression=off,exec=off,setuid=off | |
131 132 # Source tree (compressed) 133 /usr/src compression=lz4,exec=off,setuid=off | 127 128 # Source tree (compressed) 129 /usr/src compression=lz4,exec=off,setuid=off |
134 /usr/obj # Object files | |
135 136 # Create /var and friends 137 /var mountpoint=/var 138 /var/crash 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 |
139 /var/db exec=off,setuid=off 140 /var/db/pkg compression=lz4,exec=off,setuid=off 141 /var/empty exec=off,setuid=off | |
142 /var/log compression=lz4,exec=off,setuid=off | 134 /var/log compression=lz4,exec=off,setuid=off |
143 /var/mail compression=lz4,exec=off,setuid=off 144 /var/run exec=off,setuid=off | |
145 /var/tmp compression=lz4,exec=on,setuid=off 146" # END-QUOTE 147 | 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 |
|
148############################################################ GLOBALS 149 150# | 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"' 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"' 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"' 168GPART_SET_ACTIVE='gpart set -a active -i %s "%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"' 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"' 181ZPOOL_SET='zpool set %s "%s"' 182 183# |
|
151# Strings that should be moved to an i18n file and loaded with f_include_lang() 152# 153hline_alnum_arrows_punc_tab_enter="Use alnum, arrows, punctuation, TAB or ENTER" 154hline_arrows_space_tab_enter="Use arrows, SPACE, TAB or ENTER" 155hline_arrows_tab_enter="Press arrows, TAB or ENTER" | 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" |
|
156msg_back="Back" 157msg_cancel="Cancel" | 190msg_back="Back" 191msg_cancel="Cancel" |
158msg_change="Change Selection" | 192msg_change_selection="Change Selection" |
159msg_configure_options="Configure Options:" | 193msg_configure_options="Configure Options:" |
160msg_create="Install" 161msg_create_desc="Proceed with Installation" 162msg_create_help="Create ZFS boot pool with displayed options" | |
163msg_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" 164msg_disk_info="Disk Info" 165msg_disk_info_help="Get detailed information on disk device(s)" | 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)" |
166msg_disks_to_use="Disks To Use" 167msg_disks_to_use_help="Choose which disks to use for the Virtual Device (Required)" | 197msg_encrypt_disks="Encrypt Disks?" 198msg_encrypt_disks_help="Use geli(8) to encrypt all data partitions" 199msg_error="Error" |
168msg_force_4k_sectors="Force 4K Sectors?" 169msg_force_4k_sectors_help="Use gnop(8) to configure forced 4K sector alignment" 170msg_freebsd_installer="FreeBSD Installer" | 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" |
171msg_geli_encryption="Encrypt Disks?" 172msg_geli_encryption_help="Use geli(8) to encrypt all data partitions" | |
173msg_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" 174msg_geli_setup="Initializing encryption on the selected disks, this will take several seconds per disk" | 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" 204msg_geli_setup="Initializing encryption on the selected disks, 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" 208msg_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'" |
|
175msg_invalid_virtual_device_type="Invalid Virtual Device type \`%s'" | 212msg_invalid_virtual_device_type="Invalid Virtual Device type \`%s'" |
176msg_invalid_virtual_device_type_help="Select another Virtual Device type or Cancel to\nreturn to the ZFS menu. From there you can select\nmore disks or rescan for additional devices." 177msg_last_chance_are_you_sure="Last Chance! Are you sure you want to destroy the current contents of the following disks:\n%s" 178msg_last_chance_are_you_sure_color="\\\\ZrLast Chance!\\\\ZR Are you \\\\Z1sure\\\\Zn you want to \\\\Zr\\\\Z1destroy\\\\Zn the current contents of the following disks:\n%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' |
179msg_mirror_desc="Mirror - n-Way Mirroring" 180msg_mirror_help="[2+ Disks] Mirroring provides the best performance, but the least storage" | 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!" |
|
181msg_no="NO" 182msg_no_disks_present_to_configure="No disk(s) present to configure" 183msg_no_disks_selected="No disks selected." | 219msg_no="NO" 220msg_no_disks_present_to_configure="No disk(s) present to configure" 221msg_no_disks_selected="No disks selected." |
184msg_not_enough_disks_selected="Not enough disks selected. (%u < %u wanted)" | 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" |
185msg_ok="OK" 186msg_partition_scheme="Partition Scheme" 187msg_partition_scheme_help="Toggle between GPT and MBR partitioning schemes" 188msg_please_enter_a_name_for_your_zpool="Please enter a name for your zpool:" 189msg_please_enter_amount_of_swap_space="Please enter amount of swap space (SI-Unit suffixes\nrecommended; e.g., \`2g' for 2 Gigabytes):" 190msg_please_select_one_or_more_disks="Please select one or more disks to create a zpool:" 191msg_pool_name="Pool Name" 192msg_pool_name_cannot_be_empty="Pool name cannot be empty." 193msg_pool_name_help="Customize the name of the zpool to be created (Required)" | 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)" |
|
194msg_processing_selection="Processing selection..." 195msg_raidz1_desc="RAID-Z1 - Single Redundant RAID" 196msg_raidz1_help="[3+ Disks] Withstand failure of 1 disk. Recommended for: 3, 5 or 9 disks" 197msg_raidz2_desc="RAID-Z2 - Double Redundant RAID" 198msg_raidz2_help="[4+ Disks] Withstand failure of 2 disks. Recommended for: 4, 6 or 10 disks" 199msg_raidz3_desc="RAID-Z3 - Triple Redundant RAID" 200msg_raidz3_help="[5+ Disks] Withstand failure of 3 disks. Recommended for: 5, 7 or 11 disks" 201msg_rescan_devices="Rescan Devices" 202msg_rescan_devices_help="Scan for device changes" 203msg_select="Select" 204msg_select_a_disk_device="Select a disk device" 205msg_select_virtual_device_type="Select Virtual Device type:" 206msg_stripe_desc="Stripe - No Redundancy" 207msg_stripe_help="[1+ Disks] Striping provides maximum storage but no redundancy" 208msg_swap_size="Swap Size" 209msg_swap_size_help="Customize how much swap space is allocated to each selected disk" | 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" |
210msg_these_disks_are_too_small="These disks are too small given the amount of requested\nswap (%s) and/or GELI (%s) partitions, which would take\n50%% or more (not recommended) of each of the following\nselected disk devices:\n\n %s\n\nRecommend changing partition size(s) and/or selecting a\ndifferent set of devices." | 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." |
211msg_yes="YES" 212msg_zfs_configuration="ZFS Configuration" | 257msg_yes="YES" 258msg_zfs_configuration="ZFS Configuration" |
213msg_zfs_vdev_type="ZFS VDev Type" 214msg_zfs_vdev_type_help="Select type of ZFS Virtual Device to create" | |
215 216############################################################ FUNCTIONS 217 218# dialog_menu_main 219# 220# Display the dialog(1)-based application main menu. 221# 222dialog_menu_main() 223{ 224 local title="$DIALOG_TITLE" 225 local btitle="$DIALOG_BACKTITLE" 226 local prompt="$msg_configure_options" 227 local force4k="$msg_no" 228 local usegeli="$msg_no" 229 [ "$ZFSBOOT_GNOP_4K_FORCE_ALIGN" ] && force4k="$msg_yes" 230 [ "$ZFSBOOT_GELI_ENCRYPTION" ] && usegeli="$msg_yes" | 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 |
|
231 local menu_list=" | 277 local menu_list=" |
232 '>>> $msg_create' '$msg_create_desc' 233 '$msg_create_help' | 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' |
234 '- $msg_rescan_devices' '*' 235 '$msg_rescan_devices_help' 236 '- $msg_disk_info' '*' 237 '$msg_disk_info_help' | 282 '- $msg_rescan_devices' '*' 283 '$msg_rescan_devices_help' 284 '- $msg_disk_info' '*' 285 '$msg_disk_info_help' |
238 '1 $msg_pool_name' '$ZFSBOOT_POOL_NAME' | 286 'N $msg_pool_name' '$ZFSBOOT_POOL_NAME' |
239 '$msg_pool_name_help' | 287 '$msg_pool_name_help' |
240 '2 $msg_disks_to_use' '$ZFSBOOT_DISKS' 241 '$msg_disks_to_use_help' 242 '3 $msg_zfs_vdev_type' '$ZFSBOOT_VDEV_TYPE' 243 '$msg_zfs_vdev_type_help' | |
244 '4 $msg_force_4k_sectors' '$force4k' 245 '$msg_force_4k_sectors_help' | 288 '4 $msg_force_4k_sectors' '$force4k' 289 '$msg_force_4k_sectors_help' |
246 '5 $msg_geli_encryption' '$usegeli' 247 '$msg_geli_encryption_help' 248 '6 $msg_partition_scheme' '$ZFSBOOT_PARTITION_SCHEME' | 290 'E $msg_encrypt_disks' '$usegeli' 291 '$msg_encrypt_disks_help' 292 'P $msg_partition_scheme' '$ZFSBOOT_PARTITION_SCHEME' |
249 '$msg_partition_scheme_help' | 293 '$msg_partition_scheme_help' |
250 '7 $msg_swap_size' '$ZFSBOOT_SWAP_SIZE' | 294 'S $msg_swap_size' '$ZFSBOOT_SWAP_SIZE' |
251 '$msg_swap_size_help' 252 " # END-QUOTE 253 local defaultitem= # Calculated below 254 local hline="$hline_alnum_arrows_punc_tab_enter" 255 256 local height width rows 257 eval f_dialog_menu_with_help_size height width rows \ 258 \"\$title\" \"\$btitle\" \"\$prompt\" \"\$hline\" $menu_list --- 20 unchanged lines hidden (view full) --- 279 f_dialog_menutag_store "$menu_choice" 280 281 # Only update default-item on success 282 [ $retval -eq $DIALOG_OK ] && f_dialog_default_store "$menu_choice" 283 284 return $retval 285} 286 | 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 --- 20 unchanged lines hidden (view full) --- 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 |
287# dialog_edit_disks | 331# dialog_last_chance $disks ... |
288# | 332# |
289# Edit the list of disks to be used by the ZFS boot pool. | 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. |
290# | 336# |
291dialog_edit_disks() | 337dialog_last_chance() |
292{ 293 local title="$DIALOG_TITLE" 294 local btitle="$DIALOG_BACKTITLE" | 338{ 339 local title="$DIALOG_TITLE" 340 local btitle="$DIALOG_BACKTITLE" |
295 local prompt="$msg_please_select_one_or_more_disks" 296 local check_list= # Calculated below 297 local hline="$hline_arrows_space_tab_enter" 298 local dev vardev disks= | 341 local prompt # Calculated below 342 local hline="$hline_arrows_tab_enter" |
299 | 343 |
300 # 301 # Get a [new] list of disk devices 302 # 303 f_device_find "" $DEVICE_TYPE_DISK disks 304 if [ ! "$disks" ]; then 305 f_show_msg "$msg_no_disks_present_to_configure" 306 return $FAILURE | 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" |
307 fi 308 | 357 fi 358 |
309 # Lets sort the disks array to be more user friendly 310 disks=$( echo "$disks" | tr ' ' '\n' | sort | tr '\n' ' ' ) 311 312 # 313 # Loop through the list of selected disks and create temporary local 314 # variables mapping their status onto an up-to-date list of disks. 315 # 316 for dev in $ZFSBOOT_DISKS; do 317 f_str2varname "$dev" vardev 318 local _${vardev}_status=on | 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" |
319 done | 375 done |
376 # Append the left-overs 377 if [ "${line#$prefix}" ]; then 378 list="$list$line" 379 height=$(( $height + 1 )) 380 fi |
|
320 | 381 |
321 # 322 # Create the checklist menu of discovered disk devices 323 # 324 local on_off 325 for dev in $disks; do 326 local desc= 327 device_$dev get desc desc 328 f_shell_escape "$desc" desc 329 f_str2varname "$dev" vardev 330 f_getvar _${vardev}_status:-off on_off 331 check_list="$check_list '$dev' '$desc' $on_off" 332 done | 382 # Add height for Xdialog(1) 383 [ "$USE_XDIALOG" ] && height=$(( $height + $height / 5 + 3 )) |
333 | 384 |
334 # 335 # Prompt the user to check some disks 336 # 337 local height width rows 338 eval f_dialog_checklist_size height width rows \ 339 \"\$title\" \"\$btitle\" \"\$prompt\" \"\$hline\" $check_list 340 disks=$( eval $DIALOG \ 341 --title \"\$DIALOG_TITLE\" \ 342 --backtitle \"\$DIALOG_BACKTITLE\" \ 343 --hline \"\$hline\" \ 344 --ok-label \"\$msg_ok\" \ 345 --cancel-label \"\$msg_cancel\" \ 346 --checklist \"\$prompt\" \ 347 $height $width $rows \ 348 $check_list \ 349 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 350 ) || return $? 351 # Exit if user either pressed ESC or chose Cancel/No 352 f_dialog_data_sanitize disks 353 354 ZFSBOOT_DISKS="$disks" 355 356 return $DIALOG_OK | 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 |
357} 358 | 396} 397 |
359# dialog_menu_vdev | 398# dialog_menu_layout |
360# | 399# |
361# Prompt the user to select a a Virtual Device type. | 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. |
362# | 402# |
363dialog_menu_vdev() | 403dialog_menu_layout() |
364{ | 404{ |
405 local funcname=dialog_menu_layout |
|
365 local title="$DIALOG_TITLE" 366 local btitle="$DIALOG_BACKTITLE" | 406 local title="$DIALOG_TITLE" 407 local btitle="$DIALOG_BACKTITLE" |
367 local prompt="$msg_select_virtual_device_type" 368 369 # Make sure [potentially scripted] selections are real 370 real_disks= 371 for disk in $ZFSBOOT_DISKS; do 372 f_struct device_$disk && real_disks="$real_disks $disk" 373 done 374 # Make sure we have at least one real disk selected 375 ndisks=$( set -- $real_disks; echo $# ) 376 377 local menu_list=" | 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=" |
378 'stripe' '$msg_stripe_desc' '$msg_stripe_help' 379 'mirror' '$msg_mirror_desc' '$msg_mirror_help' 380 'raidz1' '$msg_raidz1_desc' '$msg_raidz1_help' 381 'raidz2' '$msg_raidz2_desc' '$msg_raidz2_help' 382 'raidz3' '$msg_raidz3_desc' '$msg_raidz3_help' 383 " # END-QUOTE | 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" |
|
384 | 420 |
385 local defaultitem="$ZFSBOOT_VDEV_TYPE" 386 local hline="$hline_arrows_tab_enter" 387 local error_msg revalidate_choice 388 389 local mheight mwidth mrows 390 eval f_dialog_menu_size mheight mwidth mrows \ 391 \"\$title\" \"\$btitle\" \"\$prompt\" \"\$hline\" $menu_list 392 local iheight iwidth 393 f_dialog_infobox_size iheight iwidth \ 394 "$DIALOG_TITLE" "$DIALOG_BACKTITLE" "$msg_processing_selection" 395 396 local menu_choice 397 menu_choice=$( eval $DIALOG \ 398 --title \"\$title\" \ 399 --backtitle \"\$btitle\" \ 400 --hline \"\$hline\" \ 401 --ok-label \"\$msg_ok\" \ 402 --cancel-label \"\$msg_cancel\" \ 403 --item-help \ 404 --default-item \"\$defaultitem\" \ 405 --menu \"\$prompt\" \ 406 $mheight $mwidth $mrows \ 407 $menu_list \ 408 --and-widget \ 409 ${USE_XDIALOG:+--no-buttons} \ 410 --infobox \"\$msg_processing_selection\" \ 411 $iheight $iwidth \ 412 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 413 ) || return $FAILURE 414 f_dialog_data_sanitize menu_choice 415 sleep 0.5 # Give time to read `--and-widget --info-box' 416 417 # Make sure we have enough disks for the desired vdev type 418 case "$menu_choice" in 419 stripe) want_disks=1 ;; 420 mirror) want_disks=2 ;; 421 raidz1) want_disks=3 ;; 422 raidz2) want_disks=4 ;; 423 raidz3) want_disks=5 ;; | 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 *) | 424 *) |
425 f_show_msg "$msg_invalid_virtual_device_type" \ 426 "$menu_choice" 427 continue | 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 |
428 esac | 430 esac |
429 if [ $ndisks -lt $want_disks ]; then 430 msg_yes="$msg_change" msg_no="$msg_cancel" f_yesno \ 431 "%s: $msg_not_enough_disks_selected\n%s" \ 432 "$menu_choice" $ndisks $want_disks \ 433 "$msg_invalid_virtual_device_type_help" || 434 return $FAILURE 435 dialog_menu_vdev 436 else 437 ZFSBOOT_VDEV_TYPE="$menu_choice" | 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 |
438 fi | 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 |
|
439} 440 441# zfs_create_diskpart $disk $index 442# 443# For each block device to be used in the zpool, rather than just create the 444# zpool with the raw block devices (e.g., da0, da1, etc.) we create partitions 445# so we can have some real swap. This also provides wiggle room incase your 446# replacement drivers do not have the exact same sector counts. 447# 448# NOTE: The MBR layout is more complicated (GPT is preferred). 449# 450zfs_create_diskpart() 451{ | 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# 613# NOTE: The MBR layout is more complicated (GPT is preferred). 614# 615zfs_create_diskpart() 616{ |
452 local disk="$1" index="$2" | |
453 local funcname=zfs_create_diskpart | 617 local funcname=zfs_create_diskpart |
618 local disk="$1" index="$2" |
|
454 local disksize partsize 455 456 # Check arguments | 619 local disksize partsize 620 621 # Check arguments |
457 [ "$disk" -a "$index" ] || return $FAILURE | 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" |
458 | 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 |
|
459 # 460 # Destroy whatever partition layout is currently on disk. 461 # NOTE: `-F' required to destroy if partitions still exist. 462 # NOTE: Failure is ok here, blank disk will have nothing to destroy. 463 # | 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" |
|
464 f_quietly gpart destroy -F $disk | 666 f_quietly gpart destroy -F $disk |
667 f_quietly graid destroy $disk |
|
465 f_quietly zpool labelclear -f /dev/$disk # Kill it with fire 466 467 # Make doubly-sure backup GPT is destroyed | 668 f_quietly zpool labelclear -f /dev/$disk # Kill it with fire 669 670 # Make doubly-sure backup GPT is destroyed |
468 f_quietly gpart create -s gpt $disk || return $FAILURE 469 f_quietly gpart destroy -F $disk || return $FAILURE | 671 f_quietly gpart create -s gpt $disk 672 f_quietly gpart destroy -F $disk |
470 471 # Calculate partition size given desired amount of swap | 673 674 # Calculate partition size given desired amount of swap |
472 device_$disk get capacity disksize || return $FAILURE | 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 |
473 partsize=$(( $disksize - $swapsize )) | 683 partsize=$(( $disksize - $swapsize )) |
684 f_dprintf "$funcname: disksize=[%s] partsize=[%s]" \ 685 "$disksize" "$partsize" |
|
474 475 # 476 # Lay down the desired type of partition scheme 477 # 478 local setsize mbrindex 479 case "$ZFSBOOT_PARTITION_SCHEME" in | 686 687 # 688 # Lay down the desired type of partition scheme 689 # 690 local setsize mbrindex 691 case "$ZFSBOOT_PARTITION_SCHEME" in |
480 ""|GPT) | 692 ""|GPT) f_dprintf "$funcname: Creating GPT layout..." |
481 # 482 # 1. Create GPT layout using labels 483 # | 693 # 694 # 1. Create GPT layout using labels 695 # |
484 gpart create -s gpt $disk || return $FAILURE | 696 f_eval_catch $funcname gpart "$GPART_CREATE" gpt \$disk || 697 return $FAILURE |
485 486 # 487 # 2. Add small freebsd-boot partition labeled `boot#' 488 # | 698 699 # 700 # 2. Add small freebsd-boot partition labeled `boot#' 701 # |
489 gpart add -l gptboot$index -t freebsd-boot -s 512k $disk || 490 return $FAILURE 491 gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 $disk || 492 return $FAILURE | 702 f_eval_catch $funcname gpart "$GPART_ADD_LABEL_WITH_SIZE" \ 703 gptboot\$index freebsd-boot 512k \$disk || 704 return $FAILURE 705 f_eval_catch $funcname gpart "$GPART_BOOTCODE_PART" \ 706 /boot/pmbr /boot/gptzfsboot 1 \$disk || 707 return $FAILURE |
493 494 # zpool will use the `zfs#' GPT labels 495 bootpart=p2 targetpart=p2 496 | 708 709 # zpool will use the `zfs#' GPT labels 710 bootpart=p2 targetpart=p2 711 |
497 # Change things around if we are using GELI | 712 # Change things around if we are using geli(8) |
498 if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then 499 bootpart=p2 targetpart=p3 500 partsize=$(( $partsize - $gelisize )) | 713 if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then 714 bootpart=p2 targetpart=p3 715 partsize=$(( $partsize - $gelisize )) |
501 gpart add -l boot$index -t freebsd-zfs \ 502 -s ${gelisize}b -a 1m $disk || return $FAILURE | 716 f_dprintf "$funcname: gelisize=[%s]" \ 717 "gelisize=[$gelisize]" 718 f_eval_catch $funcname gpart \ 719 "$GPART_ADD_LABEL_WITH_SIZE" boot\$index \ 720 freebsd-zfs \${gelisize}b \$disk || 721 return $FAILURE 722 |
503 # Pedantically nuke any old labels, stop geli | 723 # Pedantically nuke any old labels, stop geli |
504 f_quietly zpool labelclear -f /dev/$disk$bootpart 505 f_quietly geli detach -f /dev/$disk$targetpart | 724 f_quietly zpool labelclear -f "/dev/$disk$bootpart" 725 f_quietly geli detach -f "/dev/$disk$targetpart" |
506 fi 507 508 # 509 # 3. Add freebsd-zfs partition labeled `zfs#' for zpool 510 # NOTE: Using above calculated partsize to leave room for swap. 511 # | 726 fi 727 728 # 729 # 3. Add freebsd-zfs partition labeled `zfs#' for zpool 730 # NOTE: Using above calculated partsize to leave room for swap. 731 # |
512 [ $swapsize -gt 0 ] && setsize="-s ${partsize}b" 513 gpart add -l zfs$index -t freebsd-zfs $setsize -a 1m $disk || 514 return $FAILURE 515 f_quietly zpool labelclear -f /dev/$disk$targetpart # Pedantic | 732 if [ ${swapsize:-0} -gt 0 ]; then 733 f_dprintf "$funcname: partsize=[%s]" \ 734 "partsize=[$partsize]" 735 f_eval_catch $funcname gpart \ 736 "$GPART_ADD_LABEL_WITH_SIZE" zfs\$index \ 737 freebsd-zfs \${partsize}b \$disk || 738 return $FAILURE 739 else 740 f_eval_catch $funcname gpart "$GPART_ADD_LABEL" \ 741 zfs\$index freebsd-zfs \$disk || 742 return $FAILURE 743 fi 744 f_quietly zpool labelclear -f "/dev/$disk$targetpart" |
516 517 # 518 # 4. Add freebsd-swap partition labeled `swap#' 519 # 520 if [ $swapsize -gt 0 ]; then | 745 746 # 747 # 4. Add freebsd-swap partition labeled `swap#' 748 # 749 if [ $swapsize -gt 0 ]; then |
521 gpart add -l swap$index -t freebsd-swap -a 1m $disk || 522 return $FAILURE | 750 f_eval_catch $funcname gpart "$GPART_ADD_LABEL" \ 751 swap\$index freebsd-swap \$disk || 752 return $FAILURE |
523 # Update fstab(5) | 753 # Update fstab(5) |
524 printf "$fstab_fmt" \ 525 /dev/gpt/swap$index none swap sw 0 0 \ 526 >> $BSDINSTALL_TMPETC/fstab || return $FAILURE | 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 |
527 fi 528 ;; 529 | 758 fi 759 ;; 760 |
530 MBR) | 761 MBR) f_dprintf "$funcname: Creating MBR layout..." |
531 # 532 # 1. Create MBR layout (no labels) 533 # | 762 # 763 # 1. Create MBR layout (no labels) 764 # |
534 gpart create -s mbr $disk || return $FAILURE 535 gpart bootcode -b /boot/boot0 $disk || return $FAILURE | 765 f_eval_catch $funcname gpart "$GPART_CREATE" mbr \$disk || 766 return $FAILURE 767 f_eval_catch $funcname gpart "$GPART_BOOTCODE" /boot/mbr \ 768 \$disk || return $FAILURE |
536 537 # 538 # 2. Add freebsd slice with all available space 539 # | 769 770 # 771 # 2. Add freebsd slice with all available space 772 # |
540 gpart add -t freebsd $disk || return $FAILURE 541 gpart set -a active -i 1 $disk || return $FAILURE | 773 f_eval_catch $funcname gpart "$GPART_ADD" freebsd \$disk || 774 return $FAILURE 775 f_eval_catch $funcname gpart "$GPART_SET_ACTIVE" 1 \$disk || 776 return $FAILURE |
542 f_quietly zpool labelclear -f /dev/${disk}s1 # Pedantic 543 f_quietly gpart destroy -F ${disk}s1 # Pedantic 544 545 # | 777 f_quietly zpool labelclear -f /dev/${disk}s1 # Pedantic 778 f_quietly gpart destroy -F ${disk}s1 # Pedantic 779 780 # |
546 # 3. Write BSD sceme to the freebsd slice | 781 # 3. Write BSD scheme to the freebsd slice |
547 # | 782 # |
548 gpart create -s BSD ${disk}s1 || return $FAILURE | 783 f_eval_catch $funcname gpart "$GPART_CREATE" BSD \${disk}s1 || 784 return $FAILURE |
549 550 # zpool will use s1a (no labels) 551 bootpart=s1a targetpart=s1a mbrindex=1 552 | 785 786 # zpool will use s1a (no labels) 787 bootpart=s1a targetpart=s1a mbrindex=1 788 |
553 # Change things around if we are using GELI | 789 # Change things around if we are using geli(8) |
554 if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then 555 bootpart=s1a targetpart=s1d 556 partsize=$(( $partsize - $gelisize )) 557 mbrindex=4 # If this is s1a then make the zpool s1d | 790 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 |
558 gpart add -t freebsd-zfs -i 1 -s ${gelisize}b \ 559 ${disk}s1 || return $FAILURE | 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 |
560 # Pedantically nuke any old labels, stop geli | 800 # Pedantically nuke any old labels, stop geli |
561 f_quietly zpool labelclear -f /dev/$disk$bootpart 562 f_quietly geli detach -f /dev/$disk$targetpart | 801 f_quietly zpool labelclear -f "/dev/$disk$bootpart" 802 f_quietly geli detach -f "/dev/$disk$targetpart" |
563 fi 564 565 # 566 # 4. Partition the BSD slice for ZFS 567 # NOTE: Using above calculated partsize to leave room for swap. 568 # | 803 fi 804 805 # 806 # 4. Partition the BSD slice for ZFS 807 # NOTE: Using above calculated partsize to leave room for swap. 808 # |
569 [ $swapsize -gt 0 ] && setsize="-s ${partsize}b" 570 gpart add -t freebsd-zfs -i $mbrindex $setsize ${disk}s1 || 571 return $FAILURE | 809 if [ ${swapsize:-0} -gt 0 ]; then 810 f_dprintf "$funcname: mbrindex=[%s] partsize=[%s]" \ 811 "$mbrindex" "$partsize" 812 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 || 820 return $FAILURE 821 fi |
572 f_quietly zpool labelclear -f /dev/$disk$targetpart # Pedantic 573 574 # 575 # 5. Add freebsd-swap partition 576 # 577 if [ $swapsize -gt 0 ]; then | 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 |
578 gpart add -t freebsd-swap -i 2 ${disk}s1 || 579 return $FAILURE | 828 f_eval_catch $funcname gpart "$GPART_ADD_INDEX" \ 829 2 freebsd-swap \${disk}s1 || 830 return $FAILURE |
580 # Update fstab(5) | 831 # Update fstab(5) |
581 printf "$fstab_fmt" /dev/${disk}s1b none swap sw 0 0 \ 582 >> $BSDINSTALL_TMPETC/fstab || return $FAILURE | 832 f_eval_catch $funcname printf "$PRINTF_FSTAB" \ 833 /dev/\${disk}s1b none swap sw 0 0 \ 834 \$BSDINSTALL_TMPETC/fstab || 835 return $FAILURE |
583 fi 584 ;; 585 | 836 fi 837 ;; 838 |
586 *) 587 printf "%s: %s is an unsupported partition scheme" \ 588 "$funcname" "$ZFSBOOT_PARTITION_SCHEME" >&2 589 return $FAILURE 590 | |
591 esac # $ZFSBOOT_PARTITION_SCHEME 592 593 return $SUCCESS 594} 595 | 839 esac # $ZFSBOOT_PARTITION_SCHEME 840 841 return $SUCCESS 842} 843 |
596# zfs_create_boot $poolname $vdev_type $real_disks ... | 844# zfs_create_boot $poolname $vdev_type $disks ... |
597# 598# Creates boot pool and dataset layout. Returns error if something goes wrong. 599# Errors are printed to stderr for collection and display. 600# 601zfs_create_boot() 602{ | 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{ |
603 local poolname="$1" vdev_type="$2" 604 local fstab_fmt="%s\t\t%s\t%s\t%s\t\t%s\t%s\n" | |
605 local funcname=zfs_create_boot | 851 local funcname=zfs_create_boot |
852 local poolname="$1" vdev_type="$2" |
|
606 local bootpart targetpart 607 608 shift 2 # name vdev_type 609 610 # We may need this later | 853 local bootpart targetpart 854 855 shift 2 # name vdev_type 856 857 # We may need this later |
611 local realdisks=$* | 858 local disks="$*" |
612 613 # Pedantic checks; should never be seen 614 if [ ! "$poolname" ]; then | 859 860 # Pedantic checks; should never be seen 861 if [ ! "$poolname" ]; then |
615 echo "$funcname: NULL poolname" >&2 | 862 f_dprintf "$funcname: NULL poolname" 863 msg_error="$msg_error: $funcname" \ 864 f_show_err "$msg_null_poolname" |
616 return $FAILURE 617 fi 618 if [ $# -lt 1 ]; then | 865 return $FAILURE 866 fi 867 if [ $# -lt 1 ]; then |
619 echo "$funcname: missing disk arguments" >&2 | 868 f_dprintf "$funcname: missing disk arguments" 869 msg_error="$msg_error: $funcname" \ 870 f_show_err "$msg_missing_disk_arguments" |
620 return $FAILURE 621 fi | 871 return $FAILURE 872 fi |
873 f_dprintf "$funcname: poolname=[%s] vdev_type=[%s]" \ 874 "$poolname" "$vdev_type" |
|
622 623 # Initialize fstab(5) | 875 876 # Initialize fstab(5) |
624 printf "$fstab_fmt" \ 625 "# Device" Mountpoint FStype Options Dump "Pass#" \ 626 >> $BSDINSTALL_TMPETC/fstab || return $FAILURE | 877 f_dprintf "$funcname: Initializing temporary fstab(5) file..." 878 f_eval_catch $funcname sh \ 879 "$SHELL_TRUNCATE" \$BSDINSTALL_TMPETC/fstab || 880 return $FAILURE 881 f_eval_catch $funcname printf "$PRINTF_FSTAB" \ 882 "# Device" Mountpoint FStype Options Dump "Pass#" \ 883 \$BSDINSTALL_TMPETC/fstab || return $FAILURE |
627 628 # Expand SI units in desired sizes | 884 885 # Expand SI units in desired sizes |
886 f_dprintf "$funcname: Expanding supplied swapsize/gelisize values..." |
|
629 local swapsize gelisize | 887 local swapsize gelisize |
630 f_expand_number "$ZFSBOOT_SWAP_SIZE" swapsize || return $FAILURE 631 f_expand_number "$ZFSBOOT_GELI_BOOT_SIZE" gelisize || return $FAILURE | 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 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" 899 return $FAILURE 900 fi 901 f_dprintf "$funcname: ZFSBOOT_SWAP_SIZE=[%s] swapsize=[%s]" \ 902 "$ZFSBOOT_SWAP_SIZE" "$swapsize" 903 f_dprintf "$funcname: ZFSBOOT_GELI_BOOT_SIZE=[%s] gelisize=[%s]" \ 904 "$ZFSBOOT_GELI_BOOT_SIZE" "$gelisize" |
632 633 # Prepare the disks | 905 906 # Prepare the disks |
907 f_dprintf "$funcname: Preparing disk partitions for ZFS pool..." |
|
634 local n=0 635 for disk in $*; do 636 zfs_create_diskpart $disk $n || return $FAILURE 637 n=$(( $n + 1 )) 638 done 639 640 # MBR boot loader hack part 1 641 # We have to do this early because geli gets in the way later 642 if [ "$ZFSBOOT_PARTITION_SCHEME" = "MBR" ]; then | 908 local n=0 909 for disk in $*; do 910 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 |
643 for disk in $realdisks; do 644 dd if=/boot/zfsboot of=/dev/${disk}s1 count=1 || 645 return $FAILURE | 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 |
646 done 647 fi 648 649 # Forced 4k alignment support provided by Geom NOP (see gnop(8)) 650 local unenc_list= 651 if [ "$ZFSBOOT_GNOP_4K_FORCE_ALIGN" ]; then | 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 |
652 local new_list= | 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]" "$*" |
653 for disk in $*; do | 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 |
|
654 if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then | 943 if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then |
655 # We don't gnop the encrypted partition 656 # because geli will do this for us 657 # gnop the unencrypted disk 658 gnop create -S 4096 $disk$bootpart || 659 return $FAILURE 660 unenc_list="$unenc_list $disk$bootpart.nop" | 944 unenc_list="$unenc_list $disk$part.nop" |
661 else | 945 else |
662 gnop create -S 4096 $disk$targetpart || 663 return $FAILURE | |
664 new_list="$new_list $disk$targetpart.nop" 665 fi 666 done 667 set -- $new_list 668 else 669 local new_list= 670 for disk in $*; do 671 new_list="$new_list $disk$targetpart" --- 6 unchanged lines hidden (view full) --- 678 # 679 # If encryption is enabled, we need to create the GEOMs 680 # 681 if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then 682 local bootvdev= 683 local geli_pool="$BSDINSTALL_CHROOT/$ZFSBOOT_GELI_POOL_NAME" 684 local key="$ZFSBOOT_GELI_KEY_FILE" 685 | 946 new_list="$new_list $disk$targetpart.nop" 947 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" --- 6 unchanged lines hidden (view full) --- 960 # 961 # If encryption is enabled, we need to create the GEOMs 962 # 963 if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then 964 local bootvdev= 965 local geli_pool="$BSDINSTALL_CHROOT/$ZFSBOOT_GELI_POOL_NAME" 966 local key="$ZFSBOOT_GELI_KEY_FILE" 967 |
968 f_dprintf "$funcname: Setting up disk encryption..." 969 |
|
686 # Create the parent directories for our unencrypted pool 687 f_quietly umount /mnt | 970 # Create the parent directories for our unencrypted pool 971 f_quietly umount /mnt |
688 mount -t tmpfs none $BSDINSTALL_CHROOT || return $FAILURE | 972 f_eval_catch $funcname mount "$MOUNT_TYPE" tmpfs none \ 973 \$BSDINSTALL_CHROOT || return $FAILURE |
689 690 # Create mirror across the unencrypted partition on all disks 691 [ $( set -- $unenc_list; echo $# ) -gt 1 ] && bootvdev=mirror 692 | 974 975 # Create mirror across the unencrypted partition on all disks 976 [ $( set -- $unenc_list; echo $# ) -gt 1 ] && bootvdev=mirror 977 |
693 zpool create -o altroot=$BSDINSTALL_CHROOT \ 694 -m "/$ZFSBOOT_GELI_POOL_NAME" -f \ 695 "$ZFSBOOT_GELI_POOL_NAME" $bootvdev $unenc_list || 696 return $FAILURE 697 mkdir -p $geli_pool/boot || return $FAILURE | 978 f_dprintf "$funcname: %s %s %s" \ 979 "ZFSBOOT_GELI_POOL_NAME=[$ZFSBOOT_GELI_POOL_NAME]" \ 980 "bootvdev=[$bootvdev]" "unenc_list=[$unenc_list]" 981 f_eval_catch $funcname zpool "$ZPOOL_CREATE_WITH_OPTIONS" \ 982 "-o altroot=\"\$BSDINSTALL_CHROOT\" 983 -m \"/\$ZFSBOOT_GELI_POOL_NAME\" -f" \ 984 \$ZFSBOOT_GELI_POOL_NAME \$bootvdev \ 985 \$unenc_list || return $FAILURE 986 f_dprintf "$funcname: geli_pool=[%s]" "$geli_pool" 987 f_eval_catch $funcname mkdir "$MKDIR_P" \$geli_pool/boot || 988 return $FAILURE |
698 699 # Generate an encryption key using random(4) | 989 990 # Generate an encryption key using random(4) |
700 dd if=/dev/random of="$geli_pool/$key" bs=4096 count=1 || 701 return $FAILURE | 991 f_dprintf "$funcname: key=[%s]" "$key" 992 f_eval_catch $funcname dd "$DD_WITH_OPTIONS" \ 993 /dev/random \$geli_pool/\$key "bs=4096 count=1" || 994 return $FAILURE |
702 703 # Create the geli(8) GEOMS 704 local geli_list | 995 996 # Create the geli(8) GEOMS 997 local geli_list |
705 msg_enter_new_password="$msg_geli_password" \ 706 f_dialog_input_password || return $FAILURE 707 f_dialog_info "$msg_geli_setup" \ 708 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 709 for disk in $realdisks; do 710 echo "$pw_password" | geli init -b -B \ 711 "$geli_pool/boot/$disk$targetpart.eli" \ 712 -e AES-XTS -J - -K "$geli_pool/$key" -l 256 \ 713 -s 4096 $disk$targetpart || return $FAILURE 714 echo "$pw_password" | geli attach -j - \ 715 -k "$geli_pool/$key" $disk$targetpart || | 998 if ! msg_enter_new_password="$msg_geli_password" \ 999 f_dialog_input_password 1000 then 1001 f_dprintf "$funcname: User cancelled" 1002 f_show_err "$msg_user_cancelled" 1003 return $FAILURE 1004 fi 1005 f_dprintf "$funcname: disks=[%s]" "$disks" 1006 for disk in $disks; do 1007 f_dprintf "$funcname: disk=[%s] targetpart=[%s]" \ 1008 "$disk" "$targetpart" 1009 f_dialog_info "$msg_geli_setup" \ 1010 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 1011 if ! echo "$pw_password" | f_eval_catch $funcname \ 1012 geli "$GELI_PASSWORD_INIT" \ 1013 \$geli_pool/boot/\$disk\$targetpart.eli \ 1014 AES-XTS \$geli_pool/\$key \$disk\$targetpart 1015 then 1016 f_interactive || f_die |
716 return $FAILURE | 1017 return $FAILURE |
1018 fi 1019 if ! echo "$pw_password" | f_eval_catch $funcname \ 1020 geli "$GELI_ATTACH" \$geli_pool/\$key \ 1021 \$disk\$targetpart 1022 then 1023 f_interactive || f_die 1024 return $FAILURE 1025 fi |
|
717 geli_list="$geli_list $disk$targetpart.eli" 718 done 719 set -- $geli_list | 1026 geli_list="$geli_list $disk$targetpart.eli" 1027 done 1028 set -- $geli_list |
720 zfs unmount "$ZFSBOOT_GELI_POOL_NAME" || return $FAILURE | 1029 f_eval_catch $funcname zfs "$ZFS_UNMOUNT" \ 1030 \$ZFSBOOT_GELI_POOL_NAME || return $FAILURE |
721 f_quietly umount /mnt # done with tmpfs 722 fi 723 724 # 725 # Create the ZFS pool with desired type and disk devices 726 # | 1031 f_quietly umount /mnt # done with tmpfs 1032 fi 1033 1034 # 1035 # Create the ZFS pool with desired type and disk devices 1036 # |
727 zpool create -o altroot=$BSDINSTALL_CHROOT -m none -f \ 728 "$poolname" $vdev_type $* || return $FAILURE | 1037 local vdevs="$*" 1038 f_dprintf "$funcname: Creating boot pool..." 1039 f_dprintf "poolname=[%s] vdev_type=[%s] vdevs=[%s]" \ 1040 "$poolname" "$vdev_type" "$vdevs" 1041 f_eval_catch $funcname zpool "$ZPOOL_CREATE_WITH_OPTIONS" \ 1042 "-o altroot=\"\$BSDINSTALL_CHROOT\" -m none -f" \ 1043 \$poolname \$vdev_type \$vdevs |
729 730 # Customize the zpool a bit... | 1044 1045 # Customize the zpool a bit... |
731 zfs set checksum=fletcher4 "$poolname" || return $FAILURE 732 zfs set atime=off "$poolname" || return $FAILURE | 1046 local option 1047 f_dprintf "$funcname: Setting miscellaneous options on boot pool..." 1048 for option in checksum=fletcher4 atime=off; do 1049 f_dprintf "$funcname: option=[%s]" "$option" 1050 f_eval_catch $funcname zfs "$ZFS_SET" \$option \$poolname || 1051 return $FAILURE 1052 done |
733 734 # 735 # Create ZFS dataset layout within the new boot pool 736 # | 1053 1054 # 1055 # Create ZFS dataset layout within the new boot pool 1056 # |
1057 f_dprintf "$funcname: Creating ZFS datasets..." |
|
737 echo "$ZFSBOOT_DATASETS" | while read dataset options; do 738 # Skip blank lines and comments 739 case "$dataset" in "#"*|"") continue; esac 740 # Remove potential inline comments in options 741 options="${options%%#*}" 742 # Replace tabs with spaces 743 f_replaceall "$options" " " " " options 744 # Reduce contiguous runs of space to one single space 745 oldoptions= 746 while [ "$oldoptions" != "$options" ]; do 747 oldoptions="$options" 748 f_replaceall "$options" " " " " options 749 done 750 # Replace both commas and spaces with ` -o ' 751 f_replaceall "$options" "[ ,]" " -o " options 752 # Create the dataset with desired options | 1058 echo "$ZFSBOOT_DATASETS" | while read dataset options; do 1059 # Skip blank lines and comments 1060 case "$dataset" in "#"*|"") continue; esac 1061 # Remove potential inline comments in options 1062 options="${options%%#*}" 1063 # Replace tabs with spaces 1064 f_replaceall "$options" " " " " options 1065 # Reduce contiguous runs of space to one single space 1066 oldoptions= 1067 while [ "$oldoptions" != "$options" ]; do 1068 oldoptions="$options" 1069 f_replaceall "$options" " " " " options 1070 done 1071 # Replace both commas and spaces with ` -o ' 1072 f_replaceall "$options" "[ ,]" " -o " options 1073 # Create the dataset with desired options |
753 zfs create ${options:+-o $options} "$poolname$dataset" || 754 return $FAILURE | 1074 f_dprintf "$funcname: dataset=[%s] options=[%s]" \ 1075 "$dataset" "$options" 1076 f_eval_catch $funcname zfs "$ZFS_CREATE_WITH_OPTIONS" \ 1077 "\${options:+-o \$options}" \$poolname\$dataset || 1078 return $FAILURE |
755 done 756 757 # Touch up permissions on the tmp directories | 1079 done 1080 1081 # Touch up permissions on the tmp directories |
758 chmod 1777 $BSDINSTALL_CHROOT/tmp || return $FAILURE 759 chmod 1777 $BSDINSTALL_CHROOT/var/tmp || return $FAILURE | 1082 f_dprintf "$funcname: Modifying directory permissions..." 1083 local dir 1084 for dir in /tmp /var/tmp; do 1085 f_dprintf "$funcname: dir=[%s]" "$dir" 1086 f_eval_catch $funcname chmod "$CHMOD_MODE" 1777 \ 1087 \$BSDINSTALL_CHROOTDIR\$dir || return $FAILURE 1088 done |
760 761 # Create symlink(s) | 1089 1090 # Create symlink(s) |
762 [ "$ZFSBOOT_GELI_ENCRYPTION" ] && 763 { ln -s $ZFSBOOT_GELI_POOL_NAME/boot $BSDINSTALL_CHROOT/boot || 764 return $FAILURE; } | 1091 if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then 1092 f_dprintf "$funcname: Creating /boot symlink for GELI..." 1093 f_eval_catch $funcname ln "$LN_SF" \ 1094 \$ZFSBOOT_GELI_POOL_NAME/boot \ 1095 \$BSDINSTALL_CHROOT/boot || return $FAILURE 1096 fi |
765 766 # Set bootfs property | 1097 1098 # Set bootfs property |
767 zpool set bootfs="$poolname/$ZFSBOOT_BEROOT_NAME/$ZFSBOOT_BOOTFS_NAME" \ 768 "$poolname" || return $FAILURE | 1099 f_dprintf "$funcname: Setting bootfs property..." 1100 f_dprintf "$funcname: %s %s" \ 1101 "ZFSBOOT_BEROOT_NAME=[$ZFSBOOT_BEROOT_NAME]" \ 1102 "ZFSBOOT_BOOTFS_NAME=[$ZFSBOOT_BOOTFS_NAME]" 1103 f_eval_catch $funcname zpool "$ZPOOL_SET" \ 1104 bootfs=\"\$poolname/\$ZFSBOOT_BEROOT_NAME/\$ZFSBOOT_BOOTFS_NAME\" \ 1105 \$poolname || return $FAILURE |
769 770 # Export the pool(s) | 1106 1107 # Export the pool(s) |
771 zpool export "$poolname" || return $FAILURE 772 [ "$ZFSBOOT_GELI_ENCRYPTION" ] && 773 { zpool export "$ZFSBOOT_GELI_POOL_NAME" || return $FAILURE; } | 1108 f_dprintf "$funcname: Temporarily exporting ZFS pool(s)..." 1109 f_eval_catch $funcname zpool "$ZPOOL_EXPORT" \$poolname || 1110 return $FAILURE 1111 if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then 1112 f_eval_catch $funcname zpool "$ZPOOL_EXPORT" \ 1113 \$ZFSBOOT_GELI_POOL_NAME || return $FAILURE 1114 fi |
774 775 # Destroy the gnop devices (if enabled) | 1115 1116 # Destroy the gnop devices (if enabled) |
776 for disk in ${ZFSBOOT_GNOP_4K_FORCE_ALIGN:+$realdisks}; do | 1117 for disk in ${ZFSBOOT_GNOP_4K_FORCE_ALIGN:+$disks}; do |
777 if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then 778 f_quietly gnop destroy $disk$bootpart.nop 779 else 780 f_quietly gnop destroy $disk$targetpart.nop 781 fi 782 done 783 784 # MBR boot loader hack part 2 785 if [ "$ZFSBOOT_PARTITION_SCHEME" = "MBR" ]; then | 1118 if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then 1119 f_quietly gnop destroy $disk$bootpart.nop 1120 else 1121 f_quietly gnop destroy $disk$targetpart.nop 1122 fi 1123 done 1124 1125 # MBR boot loader hack part 2 1126 if [ "$ZFSBOOT_PARTITION_SCHEME" = "MBR" ]; then |
1127 f_dprintf "$funcname: Updating MBR boot loader on disks..." 1128 f_dprintf "$funcname: disks=[%s]" |
|
786 # Stick the ZFS boot loader in the "convienient hole" after 787 # the ZFS internal metadata | 1129 # Stick the ZFS boot loader in the "convienient hole" after 1130 # the ZFS internal metadata |
788 for disk in $realdisks; do 789 dd if=/boot/zfsboot of=/dev/$disk$bootpart \ 790 skip=1 seek=1024 || return $FAILURE | 1131 for disk in $disks; do 1132 f_dprintf "$funcname: disk=[%s] bootpart=[%s]" \ 1133 "$disk" "$bootpart" 1134 f_eval_catch $funcname dd "$DD_WITH_OPTIONS" \ 1135 /boot/zfsboot /dev/\$disk\$bootpart \ 1136 "skip=1 seek=1024" || return $FAILURE |
791 done 792 fi 793 794 # Re-import the ZFS pool(s) | 1137 done 1138 fi 1139 1140 # Re-import the ZFS pool(s) |
795 zpool import -o altroot=$BSDINSTALL_CHROOT $poolname || return $FAILURE 796 [ "$ZFSBOOT_GELI_ENCRYPTION" ] && 797 { zpool import -o altroot=$BSDINSTALL_CHROOT \ 798 "$ZFSBOOT_GELI_POOL_NAME" || return $FAILURE; } | 1141 f_dprintf "$funcname: Re-importing ZFS pool(s)..." 1142 f_eval_catch $funcname zpool "$ZPOOL_IMPORT_WITH_OPTIONS" \ 1143 "-o altroot=\"\$BSDINSTALL_CHROOT\"" \$poolname || 1144 return $FAILURE 1145 if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then 1146 f_eval_catch $funcname zpool "$ZPOOL_IMPORT_WITH_OPTIONS" \ 1147 "-o altroot=\"\$BSDINSTALL_CHROOT\"" \ 1148 \$ZFSBOOT_GELI_POOL_NAME || return $FAILURE 1149 fi |
799 800 # While this is apparently not needed, it seems to help MBR | 1150 1151 # While this is apparently not needed, it seems to help MBR |
801 mkdir -p $BSDINSTALL_CHROOT/boot/zfs || return $FAILURE 802 zpool set cachefile=$BSDINSTALL_CHROOT/boot/zfs/zpool.cache \ 803 "$poolname" || return $FAILURE | 1152 f_dprintf "$funcname: Configuring zpool.cache..." 1153 f_eval_catch $funcname mkdir "$MKDIR_P" \$BSDINSTALL_CHROOT/boot/zfs || 1154 return $FAILURE 1155 f_eval_catch $funcname zpool "$ZPOOL_SET" \ 1156 cachefile=\"\$BSDINSTALL_CHROOT/boot/zfs/zpool.cache\" \ 1157 \$poolname || return $FAILURE |
804 805 # Last, but not least... required lines for rc.conf(5)/loader.conf(5) 806 # NOTE: We later concatenate these into their destination | 1158 1159 # Last, but not least... required lines for rc.conf(5)/loader.conf(5) 1160 # NOTE: We later concatenate these into their destination |
807 echo 'zfs_enable="YES"' > $BSDINSTALL_TMPETC/rc.conf.zfs || 808 return $FAILURE 809 echo 'zfs_load="YES"' > $BSDINSTALL_TMPBOOT/loader.conf.zfs || 810 return $FAILURE | 1161 f_dprintf "%s: Configuring rc.conf(5)/loader.conf(5) additions..." \ 1162 "$funcname" 1163 f_eval_catch $funcname echo "$ECHO_APPEND" 'zfs_enable=\"YES\"' \ 1164 \$BSDINSTALL_TMPETC/rc.conf.zfs || return $FAILURE 1165 f_eval_catch $funcname echo "$ECHO_APPEND" 'zfs_load=\"YES\"' \ 1166 \$BSDINSTALL_TMPBOOT/loader.conf.zfs || return $FAILURE |
811 812 # We're all done unless we should go on to do encryption 813 [ "$ZFSBOOT_GELI_ENCRYPTION" ] || return $SUCCESS 814 | 1167 1168 # We're all done unless we should go on to do encryption 1169 [ "$ZFSBOOT_GELI_ENCRYPTION" ] || return $SUCCESS 1170 |
815 # Some additional GELI requirements for loader.conf(5) 816 echo 'zpool_cache_load="YES"' \ 817 >> $BSDINSTALL_TMPBOOT/loader.conf.zfs || return $FAILURE 818 echo 'zpool_cache_type="/boot/zfs/zpool.cache"' \ 819 >> $BSDINSTALL_TMPBOOT/loader.conf.zfs || return $FAILURE 820 echo 'zpool_cache_name="/boot/zfs/zpool.cache"' \ 821 >> $BSDINSTALL_TMPBOOT/loader.conf.zfs || return $FAILURE | 1171 # Some additional geli(8) requirements for loader.conf(5) 1172 for option in \ 1173 zpool_cache_load=\"YES\" \ 1174 zpool_cache_type=\"/boot/zfs/zpool.cache\" \ 1175 zpool_cache_name=\"/boot/zfs/zpool.cache\" \ 1176 ; do 1177 f_eval_catch $funcname echo "$ECHO_APPEND" \$option \ 1178 \$BSDINSTALL_TMPBOOT/loader.conf.zfs || 1179 return $FAILURE 1180 done |
822 823 # 824 # Configure geli(8)-based encryption 825 # | 1181 1182 # 1183 # Configure geli(8)-based encryption 1184 # |
826 echo 'aesni_load="YES"' \ 827 > $BSDINSTALL_TMPBOOT/loader.conf.aesni || return $FAILURE 828 echo 'geom_eli_load="YES"' \ 829 > $BSDINSTALL_TMPBOOT/loader.conf.geli || return $FAILURE 830 printf 'vfs.root.mountfrom="zfs:%s/%s/%s"\n' "$poolname" \ 831 "$ZFSBOOT_BEROOT_NAME" "$ZFSBOOT_BOOTFS_NAME" \ 832 > $BSDINSTALL_TMPBOOT/loader.conf.root || return $FAILURE 833 for disk in $realdisks; do 834 printf 'geli_%s_keyfile0_load="YES"\n' \ 835 "$disk$targetpart" \ 836 > $BSDINSTALL_TMPBOOT/loader.conf.$disk$targetpart || | 1185 f_dprintf "$funcname: Configuring disk encryption..." 1186 f_eval_catch $funcname echo "$ECHO_APPEND" 'aesni_load=\"YES\"' \ 1187 \$BSDINSTALL_TMPBOOT/loader.conf.aesni || return $FAILURE 1188 f_eval_catch $funcname echo "$ECHO_APPEND" 'geom_eli_load=\"YES\"' \ 1189 \$BSDINSTALL_TMPBOOT/loader.conf.geli || return $FAILURE 1190 f_eval_catch $funcname printf "$PRINTF_CONF" vfs.root.mountfrom \ 1191 '"zfs:$poolname/$ZFSBOOT_BEROOT_NAME/$ZFSBOOT_BOOT_FSNAME"' \ 1192 \$BSDINSTALL_TMPBOOT/loader.conf.root || return $FAILURE 1193 f_dprintf "$funcname: disks=[%s]" "$disks" 1194 for disk in $disks; do 1195 f_dprintf "$funcname: %s %s %s" \ 1196 "disk=[$disk]" "targetpart=[$targetpart]" \ 1197 "ZFSBOOT_GELI_KEY_FILE=[$ZFSBOOT_GELI_KEY_FILE]" 1198 f_eval_catch $funcname printf "$PRINTF_CONF" \ 1199 geli_%s_keyfile0_load '"$disk$targetpart" YES' \ 1200 \$BSDINSTALL_TMPBOOT/loader.conf.\$disk\$targetpart || |
837 return $FAILURE | 1201 return $FAILURE |
838 printf 'geli_%s_keyfile0_type="%s:geli_keyfile0"\n' \ 839 "$disk$targetpart" "$disk$targetpart" \ 840 >> $BSDINSTALL_TMPBOOT/loader.conf.$disk$targetpart || | 1202 f_eval_catch $funcname printf "$PRINTF_CONF" \ 1203 geli_%s_keyfile0_type \ 1204 '"$disk$targetpart" "$disk$targetpart"' \ 1205 \$BSDINSTALL_TMPBOOT/loader.conf.\$disk\$targetpart || |
841 return $FAILURE | 1206 return $FAILURE |
842 printf 'geli_%s_keyfile0_name="%s"\n' \ 843 "$disk$targetpart" "$ZFSBOOT_GELI_KEY_FILE" \ 844 >> $BSDINSTALL_TMPBOOT/loader.conf.$disk$targetpart || | 1207 f_eval_catch $funcname printf "$PRINTF_CONF" \ 1208 geli_%s_keyfile0_name \ 1209 '"$disk$targetpart" "$ZFSBOOT_GELI_KEY_FILE"' \ 1210 \$BSDINSTALL_TMPBOOT/loader.conf.\$disk\$targetpart || |
845 return $FAILURE 846 done 847 848 return $SUCCESS 849} 850 851# dialog_menu_diskinfo 852# --- 28 unchanged lines hidden (view full) --- 881# 882f_dialog_title "$msg_zfs_configuration" 883f_dialog_backtitle "$msg_freebsd_installer" 884 885# User may have specifically requested ZFS-related operations be interactive 886! f_interactive && f_zfsinteractive && unset $VAR_NONINTERACTIVE 887 888# | 1211 return $FAILURE 1212 done 1213 1214 return $SUCCESS 1215} 1216 1217# dialog_menu_diskinfo 1218# --- 28 unchanged lines hidden (view full) --- 1247# 1248f_dialog_title "$msg_zfs_configuration" 1249f_dialog_backtitle "$msg_freebsd_installer" 1250 1251# User may have specifically requested ZFS-related operations be interactive 1252! f_interactive && f_zfsinteractive && unset $VAR_NONINTERACTIVE 1253 1254# |
1255# Debugging 1256# 1257f_dprintf "BSDINSTALL_CHROOT=[%s]" "$BSDINSTALL_CHROOT" 1258f_dprintf "BSDINSTALL_TMPETC=[%s]" "$BSDINSTALL_TMPETC" 1259f_dprintf "PRINTF_FSTAB=[%s]" "$PRINTF_FSTAB" 1260 1261# |
|
889# Loop over the main menu until we've accomplished what we came here to do 890# 891while :; do 892 if ! f_interactive; then 893 retval=$DIALOG_OK | 1262# Loop over the main menu until we've accomplished what we came here to do 1263# 1264while :; do 1265 if ! f_interactive; then 1266 retval=$DIALOG_OK |
894 mtag=">>> $msg_create" | 1267 mtag=">>> $msg_install" |
895 else 896 dialog_menu_main 897 retval=$? 898 f_dialog_menutag_fetch mtag 899 fi 900 | 1268 else 1269 dialog_menu_main 1270 retval=$? 1271 f_dialog_menutag_fetch mtag 1272 fi 1273 |
901 f_dprintf "retval=%u mtag=[%s]" $reval "$mtag" | 1274 f_dprintf "retval=%u mtag=[%s]" $retval "$mtag" |
902 [ $retval -eq $DIALOG_OK ] || f_die 903 904 case "$mtag" in | 1275 [ $retval -eq $DIALOG_OK ] || f_die 1276 1277 case "$mtag" in |
905 ">>> $msg_create") | 1278 ">>> $msg_install") |
906 # 907 # First, validate the user's selections 908 # 909 910 # Make sure they gave us a name for the pool 911 if [ ! "$ZFSBOOT_POOL_NAME" ]; then | 1279 # 1280 # First, validate the user's selections 1281 # 1282 1283 # Make sure they gave us a name for the pool 1284 if [ ! "$ZFSBOOT_POOL_NAME" ]; then |
912 f_show_msg "$msg_pool_name_cannot_be_empty" 913 f_interactive || f_die | 1285 f_dprintf "Pool name cannot be empty." 1286 f_show_err "$msg_pool_name_cannot_be_empty" |
914 continue 915 fi | 1287 continue 1288 fi |
916 # Make sure [potentially scripted] selections are real 917 real_disks= 918 for disk in $ZFSBOOT_DISKS; do 919 f_struct device_$disk && real_disks="$real_disks $disk" 920 done 921 # Make sure we have at least one real disk selected 922 ndisks=$( set -- $real_disks; echo $# ) 923 if [ $ndisks -lt 1 ]; then 924 f_show_msg "$msg_no_disks_selected" 925 f_interactive || f_die 926 continue 927 fi 928 # Make sure we have enough disks for the desired vdev type 929 case "$ZFSBOOT_VDEV_TYPE" in 930 stripe) want_disks=1 ;; 931 mirror) want_disks=2 ;; 932 raidz1) want_disks=3 ;; 933 raidz2) want_disks=4 ;; 934 raidz3) want_disks=5 ;; 935 *) 936 f_show_msg "$msg_invalid_virtual_device_type" \ 937 "$ZFSBOOT_VDEV_TYPE" 938 f_interactive || f_die 939 continue 940 esac 941 if [ $ndisks -lt $want_disks ]; then 942 f_show_msg "%s: $msg_not_enough_disks_selected" \ 943 "$ZFSBOOT_VDEV_TYPE" "$want_disks" 944 f_interactive || f_die 945 continue 946 fi | 1289 1290 # Validate vdev type against number of disks selected/scripted 1291 # (also validates that ZFSBOOT_DISKS are real [probed] disks) 1292 # NB: dialog_menu_layout supports running non-interactively 1293 dialog_menu_layout || continue 1294 |
947 # Make sure each disk will be at least 50% ZFS 948 if f_expand_number "$ZFSBOOT_SWAP_SIZE" swapsize && 949 f_expand_number "$ZFSBOOT_GELI_BOOT_SIZE" gelisize 950 then 951 minsize=$swapsize teeny_disks= 952 [ "$ZFSBOOT_GELI_ENCRYPTION" ] && 953 minsize=$(( $minsize + $gelisize )) | 1295 # Make sure each disk will be at least 50% ZFS 1296 if f_expand_number "$ZFSBOOT_SWAP_SIZE" swapsize && 1297 f_expand_number "$ZFSBOOT_GELI_BOOT_SIZE" gelisize 1298 then 1299 minsize=$swapsize teeny_disks= 1300 [ "$ZFSBOOT_GELI_ENCRYPTION" ] && 1301 minsize=$(( $minsize + $gelisize )) |
954 for disk in $real_disks; do | 1302 for disk in $ZFSBOOT_DISKS; do |
955 device_$disk get capacity disksize || continue 956 disksize=$(( $disksize - $minsize )) 957 [ $disksize -lt $minsize ] && 958 teeny_disks="$teeny_disks $disk" 959 done 960 if [ "$teeny_disks" ]; then | 1303 device_$disk get capacity disksize || continue 1304 disksize=$(( $disksize - $minsize )) 1305 [ $disksize -lt $minsize ] && 1306 teeny_disks="$teeny_disks $disk" 1307 done 1308 if [ "$teeny_disks" ]; then |
961 f_show_msg "$msg_these_disks_are_too_small" \ | 1309 f_dprintf "swapsize=[%s] gelisize[%s]" \ 1310 "$ZFSBOOT_SWAP_SIZE" \ 1311 "$ZFSBOOT_GELI_BOOT_SIZE" 1312 f_dprintf "These disks are too small: %s" \ 1313 "$teeny_disks" 1314 f_show_err "$msg_these_disks_are_too_small" \ |
962 "$ZFSBOOT_SWAP_SIZE" \ 963 "$ZFSBOOT_GELI_BOOT_SIZE" \ 964 "$teeny_disks" | 1315 "$ZFSBOOT_SWAP_SIZE" \ 1316 "$ZFSBOOT_GELI_BOOT_SIZE" \ 1317 "$teeny_disks" |
965 f_interactive || f_die | |
966 continue 967 fi 968 fi 969 970 # 971 # Last Chance! 972 # | 1318 continue 1319 fi 1320 fi 1321 1322 # 1323 # Last Chance! 1324 # |
973 if [ ! "$USE_XDIALOG" ]; then 974 f_interactive && DIALOG="$DIALOG --colors" f_noyes \ 975 "$msg_last_chance_are_you_sure_color" \ 976 "$ZFSBOOT_DISKS" || continue 977 else 978 f_interactive && f_noyes \ 979 "$msg_last_chance_are_you_sure" \ 980 "$ZFSBOOT_DISKS" || continue | 1325 if f_interactive; then 1326 dialog_last_chance $ZFSBOOT_DISKS || continue |
981 fi 982 983 # 984 # Let's do this 985 # 986 987 vdev_type="$ZFSBOOT_VDEV_TYPE" 988 989 # Blank the vdev type for the default layout 990 [ "$vdev_type" = "stripe" ] && vdev_type= 991 | 1327 fi 1328 1329 # 1330 # Let's do this 1331 # 1332 1333 vdev_type="$ZFSBOOT_VDEV_TYPE" 1334 1335 # Blank the vdev type for the default layout 1336 [ "$vdev_type" = "stripe" ] && vdev_type= 1337 |
992 if ! error=$( zfs_create_boot "$ZFSBOOT_POOL_NAME" \ 993 "$vdev_type" $real_disks 2>&1 ) 994 then 995 f_dialog_msgbox "$error" 996 f_interactive || f_die 997 continue 998 fi | 1338 zfs_create_boot "$ZFSBOOT_POOL_NAME" \ 1339 "$vdev_type" $ZFSBOOT_DISKS || continue |
999 1000 break # to success 1001 ;; | 1340 1341 break # to success 1342 ;; |
1343 ?" $msg_pool_type_disks") 1344 ZFSBOOT_CONFIRM_LAYOUT=1 1345 dialog_menu_layout 1346 # User has poked settings, disable later confirmation 1347 ZFSBOOT_CONFIRM_LAYOUT= 1348 ;; |
|
1002 "- $msg_rescan_devices") f_device_rescan ;; 1003 "- $msg_disk_info") dialog_menu_diskinfo ;; 1004 ?" $msg_pool_name") 1005 # Prompt the user to input/change the name for the new pool 1006 f_dialog_input input \ 1007 "$msg_please_enter_a_name_for_your_zpool" \ 1008 "$ZFSBOOT_POOL_NAME" && 1009 ZFSBOOT_POOL_NAME="$input" 1010 ;; | 1349 "- $msg_rescan_devices") f_device_rescan ;; 1350 "- $msg_disk_info") dialog_menu_diskinfo ;; 1351 ?" $msg_pool_name") 1352 # Prompt the user to input/change the name for the new pool 1353 f_dialog_input input \ 1354 "$msg_please_enter_a_name_for_your_zpool" \ 1355 "$ZFSBOOT_POOL_NAME" && 1356 ZFSBOOT_POOL_NAME="$input" 1357 ;; |
1011 ?" $msg_disks_to_use") dialog_edit_disks ;; 1012 ?" $msg_zfs_vdev_type") dialog_menu_vdev ;; | |
1013 ?" $msg_force_4k_sectors") 1014 # Toggle the variable referenced both by the menu and later 1015 if [ "$ZFSBOOT_GNOP_4K_FORCE_ALIGN" ]; then 1016 ZFSBOOT_GNOP_4K_FORCE_ALIGN= 1017 else 1018 ZFSBOOT_GNOP_4K_FORCE_ALIGN=1 1019 fi 1020 ;; | 1358 ?" $msg_force_4k_sectors") 1359 # Toggle the variable referenced both by the menu and later 1360 if [ "$ZFSBOOT_GNOP_4K_FORCE_ALIGN" ]; then 1361 ZFSBOOT_GNOP_4K_FORCE_ALIGN= 1362 else 1363 ZFSBOOT_GNOP_4K_FORCE_ALIGN=1 1364 fi 1365 ;; |
1021 ?" $msg_geli_encryption") | 1366 ?" $msg_encrypt_disks") |
1022 # Toggle the variable referenced both by the menu and later 1023 if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then 1024 ZFSBOOT_GELI_ENCRYPTION= 1025 else 1026 ZFSBOOT_GELI_ENCRYPTION=1 1027 fi 1028 ;; 1029 ?" $msg_partition_scheme") --- 22 unchanged lines hidden --- | 1367 # Toggle the variable referenced both by the menu and later 1368 if [ "$ZFSBOOT_GELI_ENCRYPTION" ]; then 1369 ZFSBOOT_GELI_ENCRYPTION= 1370 else 1371 ZFSBOOT_GELI_ENCRYPTION=1 1372 fi 1373 ;; 1374 ?" $msg_partition_scheme") --- 22 unchanged lines hidden --- |