From owner-dev-commits-src-main@freebsd.org Wed Jun 2 17:13:20 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C84E7647A2C; Wed, 2 Jun 2021 17:13:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FwFwc5CNSz3wHH; Wed, 2 Jun 2021 17:13:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9AC001AB9D; Wed, 2 Jun 2021 17:13:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 152HDK8m007828; Wed, 2 Jun 2021 17:13:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 152HDKYY007827; Wed, 2 Jun 2021 17:13:20 GMT (envelope-from git) Date: Wed, 2 Jun 2021 17:13:20 GMT Message-Id: <202106021713.152HDKYY007827@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 7ef92163ab81 - main - Allows user to specify an optional ZFSBOOT_POOL_SIZE for their zroot MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7ef92163ab81b1b14f2a111d17baf2b352338577 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Jun 2021 17:13:20 -0000 The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=7ef92163ab81b1b14f2a111d17baf2b352338577 commit 7ef92163ab81b1b14f2a111d17baf2b352338577 Author: John Ko AuthorDate: 2021-06-02 17:12:14 +0000 Commit: Warner Losh CommitDate: 2021-06-02 17:12:14 +0000 Allows user to specify an optional ZFSBOOT_POOL_SIZE for their zroot The default is to create a zroot that consumes the whole disk because if used with geli(8) this makes sense. Without geli(8), I like to keep my data pool separate from my system pool. This is different than ZFSBOOT_BOOT_POOL_SIZE which is named bootpool. Reviewed by: allenjude Pull Request: https://github.com/freebsd/freebsd-src/pull/53 Differential Revision: https://reviews.freebsd.org/D30588 --- usr.sbin/bsdinstall/scripts/zfsboot | 46 ++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/usr.sbin/bsdinstall/scripts/zfsboot b/usr.sbin/bsdinstall/scripts/zfsboot index 3b673addb10a..45c8b001c393 100755 --- a/usr.sbin/bsdinstall/scripts/zfsboot +++ b/usr.sbin/bsdinstall/scripts/zfsboot @@ -44,6 +44,11 @@ f_include $BSDCFG_SHARE/variable.subr # : ${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_install_help="Create ZFS boot pool with displayed options" 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 @@ zfs_create_diskpart() # # 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 @@ zfs_create_diskpart() # # 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 @@ zfs_create_boot() # 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 @@ zfs_create_boot() "$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 @@ while :; do 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