Index: usr.sbin/bsdinstall/bsdinstall.8 =================================================================== --- usr.sbin/bsdinstall/bsdinstall.8 +++ usr.sbin/bsdinstall/bsdinstall.8 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 21, 2019 +.Dd December 30, 2019 .Dt BSDINSTALL 8 .Os .Sh NAME @@ -314,6 +314,12 @@ Name for the pool containing the base system. Default: .Dq zroot +.It Ev ZFSBOOT_ZROOT_POOL_NAME +Size for the pool containing the base system. +If set to anything else then MAX or an empty string, this value is passed +to gpart as partition size. +Default: +.Dq MAX .It Ev ZFSBOOT_POOL_CREATE_OPTIONS Options to be used when creating the base system's pool. Each option must be followed by the -O flag to be taken into consideration Index: usr.sbin/bsdinstall/scripts/zfsboot =================================================================== --- usr.sbin/bsdinstall/scripts/zfsboot +++ usr.sbin/bsdinstall/scripts/zfsboot @@ -45,6 +45,13 @@ : ${ZFSBOOT_POOL_NAME:=zroot} # +# How much space to allocate for the zroot partition +# MAX means use all the leftover space +# NOTE: Value passed to gpart(8); which supports SI unit suffixes. +# +: ${ZFSBOOT_ZROOT_POOL_SIZE:=MAX} + +# # Default options to use when creating zroot pool # : ${ZFSBOOT_POOL_CREATE_OPTIONS:=-O compress=lz4 -O atime=off} @@ -262,6 +269,7 @@ msg_invalid_disk_argument="Invalid disk argument \`%s'" msg_invalid_index_argument="Invalid index argument \`%s'" msg_invalid_swap_size="Invalid swap size \`%s'" +msg_invalid_zroot_pool_size="Invalid zroot pool size \`%s'" msg_invalid_virtual_device_type="Invalid Virtual Device type \`%s'" msg_last_chance_are_you_sure="Last Chance! Are you sure you want to destroy\nthe current contents of the following disks:\n\n %s" msg_last_chance_are_you_sure_color='\\ZrLast Chance!\\ZR Are you \\Z1sure\\Zn you want to \\Zr\\Z1destroy\\Zn\nthe current contents of the following disks:\n\n %s' @@ -281,11 +289,15 @@ msg_partition_scheme="Partition Scheme" msg_partition_scheme_help="Select partitioning scheme. GPT is recommended." msg_please_enter_a_name_for_your_zpool="Please enter a name for your zpool:" +msg_please_enter_amount_of_zroot_pool_space="Please enter amount of zroot pool space (SI-Unit suffixes\nrecommended; e.g., \`2g' for 2 Gigabytes):" msg_please_enter_amount_of_swap_space="Please enter amount of swap space (SI-Unit suffixes\nrecommended; e.g., \`2g' for 2 Gigabytes):" msg_please_select_one_or_more_disks="Please select one or more disks to create a zpool:" msg_pool_name="Pool Name" msg_pool_name_cannot_be_empty="Pool name cannot be empty." msg_pool_name_help="Customize the name of the zpool to be created (Required)" +msg_zroot_pool_size="ZROOT pool Size" +msg_zroot_pool_size_help="Customize how much space is allocated for the zroot pool" +msg_zroot_pool_toosmall="The selected pool size (%s) is to small. Please enter a value greater than 100MB or enter MAX for using full remainder" msg_pool_type_disks="Pool Type/Disks:" msg_pool_type_disks_help="Choose type of ZFS Virtual Device and disks to use (Required)" msg_processing_selection="Processing selection..." @@ -354,6 +366,9 @@ '$msg_disk_info_help' 'N $msg_pool_name' '$ZFSBOOT_POOL_NAME' '$msg_pool_name_help' + 'Z $msg_zroot_pool_size' + '$ZFSBOOT_ZROOT_POOL_SIZE' + '$msg_zroot_pool_size_help' '4 $msg_force_4k_sectors' '$force4k' '$msg_force_4k_sectors_help' @@ -734,7 +749,8 @@ # so we can have some real swap. This also provides wiggle room incase your # replacement drivers do not have the exact same sector counts. # -# NOTE: $swapsize and $bootsize should be defined by the calling function. +# NOTE: $swapsize and $zrootsize, $bootsize should be defined by the calling +# function. # NOTE: Sets $bootpart and $targetpart for the calling function. # zfs_create_diskpart() @@ -929,12 +945,20 @@ # # 4. Add freebsd-zfs partition labeled `zfs#' for zroot # - f_eval_catch $funcname gpart "$GPART_ADD_ALIGN_LABEL" \ - "$align_big" zfs$index freebsd-zfs $disk || - return $FAILURE + if [ x"$zrootsize"x = xx -o x"$zrootsize"x = x"MAX"x]; then + f_eval_catch $funcname gpart "$GPART_ADD_ALIGN_LABEL" \ + "$align_big" zfstest$index freebsd-zfs $disk || + return $FAILURE + else + f_eval_catch $funcname gpart \ + "$GPART_ADD_ALIGN_LABEL_WITH_SIZE" \ + "$align_big" zfstest$index freebsd-zfs \ + ${zrootsize}b $disk || + return $FAILURE + fi f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ /dev/$disk$targetpart - ;; + ;; # END GPT MBR) f_dprintf "$funcname: Creating MBR layout..." # @@ -1014,7 +1038,7 @@ f_eval_catch $funcname dd "$DD_WITH_OPTIONS" \ /boot/zfsboot /dev/${disk}s1 count=1 || return $FAILURE - ;; + ;; # END MBR esac # $ZFSBOOT_PARTITION_SCHEME @@ -1675,6 +1699,33 @@ "$msg_please_enter_a_name_for_your_zpool" \ "$ZFSBOOT_POOL_NAME" && ZFSBOOT_POOL_NAME="$input" + ;; + ?" $msg_zroot_pool_size") + # Prompt the user to input/change the zroot pool size + while :; do + f_dialog_input input \ + "$msg_please_enter_amount_of_zroot_space" \ + "$ZFSBOOT_ZROOT_POOL_SIZE" && + ZFSBOOT_ZROOT_POOL_SIZE="$input" + if [ $ZFSBOOT_ZROOT_POOL_SIZE = "MAX" ]; then + zrootsize = "MAX" + break; + fi + if f_expand_number "$ZFSBOOT_ZROOT_POOL_SIZE" zrootsize + then + if [ $zrootsize -ne 0 -a $zrootsize -lt 104857600 ]; then + f_show_err "$msg_zroot_pool_toosmall" \ + "$ZFSBOOT_ZROOT_POOL_SIZE" + continue; + else + break; + fi + else + f_show_err "$msg_zroot_pool_invalid" \ + "$ZFSBOOT_ZROOT_POOL_SIZE" + continue; + fi + done ;; ?" $msg_force_4k_sectors") # Toggle the variable referenced both by the menu and later