diff --git a/usr.sbin/bsdinstall/scripts/zfsboot b/usr.sbin/bsdinstall/scripts/zfsboot --- a/usr.sbin/bsdinstall/scripts/zfsboot +++ b/usr.sbin/bsdinstall/scripts/zfsboot @@ -44,6 +44,11 @@ # : ${ZFSBOOT_POOL_NAME:=zroot} +# +# Default pool size is optional +# +: ${ZFSBOOT_POOL_SIZE=} + # # Default options to use when creating zroot pool # @@ -262,6 +267,7 @@ msg_invalid_boot_pool_size="Invalid boot pool size \`%s'" msg_invalid_disk_argument="Invalid disk argument \`%s'" msg_invalid_index_argument="Invalid index argument \`%s'" +msg_invalid_pool_size="Invalid pool size \`%s'" msg_invalid_swap_size="Invalid swap 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" @@ -943,9 +949,15 @@ # # 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 [ "$ZFSBOOT_POOL_SIZE" ]; then + f_eval_catch $funcname gpart "$GPART_ADD_ALIGN_LABEL_WITH_SIZE" \ + "$align_big" zfs$index freebsd-zfs $ZFSBOOT_POOL_SIZE $disk || + return $FAILURE + else + f_eval_catch $funcname gpart "$GPART_ADD_ALIGN_LABEL" \ + "$align_big" zfs$index freebsd-zfs $disk || + return $FAILURE + fi f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ /dev/$disk$targetpart ;; @@ -1020,9 +1032,13 @@ # # 5. Add freebsd-zfs partition for zroot # - f_eval_catch $funcname gpart "$GPART_ADD_ALIGN_INDEX" \ - "$align_small" $mbrindex freebsd-zfs ${disk}s1 || - return $FAILURE + if [ "$ZFSBOOT_POOL_SIZE" ]; then + f_eval_catch $funcname gpart "$GPART_ADD_ALIGN_INDEX_WITH_SIZE" \ + "$align_small" $mbrindex freebsd-zfs $ZFSBOOT_POOL_SIZE ${disk}s1 || return $FAILURE + else + f_eval_catch $funcname gpart "$GPART_ADD_ALIGN_INDEX" \ + "$align_small" $mbrindex freebsd-zfs ${disk}s1 || return $FAILURE + fi f_eval_catch -d $funcname zpool "$ZPOOL_LABELCLEAR_F" \ /dev/$disk$targetpart # Pedantic f_eval_catch $funcname dd "$DD_WITH_OPTIONS" \ @@ -1114,7 +1130,7 @@ # Expand SI units in desired sizes # f_dprintf "$funcname: Expanding supplied size values..." - local swapsize bootsize + local swapsize bootsize poolsize if ! f_expand_number "$ZFSBOOT_SWAP_SIZE" swapsize; then f_dprintf "$funcname: Invalid swap size \`%s'" \ "$ZFSBOOT_SWAP_SIZE" @@ -1128,6 +1144,16 @@ "$ZFSBOOT_BOOT_POOL_SIZE" return $FAILURE fi + if [ "$ZFSBOOT_POOL_SIZE" ]; then + if ! f_expand_number "$ZFSBOOT_POOL_SIZE" poolsize; then + f_dprintf "$funcname: Invalid pool size \`%s'" \ + "$ZFSBOOT_POOL_SIZE" + f_show_err "$msg_invalid_pool_size" \ + "$ZFSBOOT_POOL_SIZE" + fi + f_dprintf "$funcname: ZFSBOOT_POOL_SIZE=[%s] poolsize=[%s]" \ + "$ZFSBOOT_POOL_SIZE" "$poolsize" + fi f_dprintf "$funcname: ZFSBOOT_SWAP_SIZE=[%s] swapsize=[%s]" \ "$ZFSBOOT_SWAP_SIZE" "$swapsize" f_dprintf "$funcname: ZFSBOOT_BOOT_POOL_SIZE=[%s] bootsize=[%s]" \ @@ -1627,7 +1653,11 @@ f_expand_number "$ZFSBOOT_BOOT_POOL_SIZE" bootsize && f_expand_number "1g" zpoolmin then - minsize=$(( $swapsize + $zpoolmin )) teeny_disks= + minsize=$swapsize teeny_disks= + if [ "$ZFSBOOT_POOL_SIZE" ]; then + f_expand_number "$ZFSBOOT_POOL_SIZE" poolsize + minsize=$(( $minsize + $poolsize )) + fi [ "$ZFSBOOT_BOOT_POOL" ] && minsize=$(( $minsize + $bootsize )) for disk in $ZFSBOOT_DISKS; do