zfsboot (259396) | zfsboot (259621) |
---|---|
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 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 --- 24 unchanged lines hidden (view full) --- 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 --- 24 unchanged lines hidden (view full) --- 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} --- 31 unchanged lines hidden (view full) --- 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} --- 31 unchanged lines hidden (view full) --- 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} --- 7 unchanged lines hidden (view full) --- 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} --- 7 unchanged lines hidden (view full) --- 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" --- 7 unchanged lines hidden (view full) --- 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" --- 7 unchanged lines hidden (view full) --- 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" --- 387 unchanged lines hidden (view full) --- 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" --- 387 unchanged lines hidden (view full) --- 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 --- 30 unchanged lines hidden (view full) --- 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 --- 30 unchanged lines hidden (view full) --- 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# --- 32 unchanged lines hidden (view full) --- 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# --- 32 unchanged lines hidden (view full) --- 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" --- 21 unchanged lines hidden (view full) --- 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" --- 21 unchanged lines hidden (view full) --- 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 # --- 38 unchanged lines hidden (view full) --- 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 # --- 38 unchanged lines hidden (view full) --- 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################################################################################ |