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 @@ -53,6 +53,11 @@ # : ${ZFSBOOT_POOL_CREATE_OPTIONS:=-O compress=lz4 -O atime=off} +# +# Default ZFS pool compatibility to use when creating zroot pool +# +: ${ZFSBOOT_POOL_COMPATIBILITY:=off} + # # Default name for the boot environment parent dataset # @@ -326,6 +331,8 @@ msg_please_enter_options_for_your_pool="Please enter options for your pool" msg_zfs_options_name="ZFS Pool Options" msg_zfs_options_name_help="Customize ZFS options for the pool to be created" +msg_zfs_compatibility="ZFS Compatibility" +msg_zfs_compatibility_help="Select template for ZFS pool compatibility (off enables all features)" ############################################################ FUNCTIONS @@ -378,6 +385,8 @@ '$msg_swap_encrypt_help' 'O $msg_zfs_options_name' '$ZFSBOOT_POOL_CREATE_OPTIONS' '$msg_zfs_options_name_help' + 'C $msg_zfs_compatibility' '$ZFSBOOT_POOL_COMPATIBILITY' + '$msg_zfs_compatibility_help' " # END-QUOTE local defaultitem= # Calculated below local hline="$hline_alnum_arrows_punc_tab_enter" @@ -1234,6 +1243,7 @@ [ $nvdevs -gt 1 ] && bootpool_vdevtype=mirror create_options="$ZFSBOOT_BOOT_POOL_CREATE_OPTIONS" + create_options="$create_options -o compatibility=$ZFSBOOT_POOL_COMPATIBILITY" bootpool_options="-o altroot=$BSDINSTALL_CHROOT" bootpool_options="$bootpool_options $create_options" bootpool_options="$bootpool_options -m \"/$bootpool_name\" -f" @@ -1346,6 +1356,7 @@ # f_dprintf "$funcname: Creating root pool..." create_options="$ZFSBOOT_POOL_CREATE_OPTIONS" + create_options="$create_options -o compatibility=$ZFSBOOT_POOL_COMPATIBILITY" if [ "$zroot_vdevtype" == "raid10" ]; then raid10_vdevs="" for vdev in $zroot_vdevs; do @@ -1616,6 +1627,40 @@ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD } +dialog_zfs_compatibility() +{ + local funcname=dialog_zfs_compatibility + local title="$msg_zfs_compatibility" + local hline= + + zfs_compat_list=" + $(echo off off && \ + find -s /etc/zfs/compatibility.d/ /usr/share/zfs/compatibility.d/ \ + -type f \ + -exec sh -c 'basename {}; basename {}' \; 2>/dev/null) + " + + local height width rows + eval f_dialog_menu_with_help_size height width rows \ + \"\$title\" \"\$btitle\" \"\$prompt\" \"\$hline\" \ + $zfs_compat_list + + local menu_choice + menu_choice=$($DIALOG \ + --title "$title" \ + --backtitle "$btitle" \ + --hline "$hline" \ + --ok-label "$msg_ok" \ + --no-tags \ + --cancel-label "$msg_cancel" \ + --menu "$prompt" \ + $height $width $rows \ + $zfs_compat_list \ + 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD) + + ZFSBOOT_POOL_COMPATIBILITY=$menu_choice +} + ############################################################ MAIN # @@ -1864,6 +1909,11 @@ "$ZFSBOOT_POOL_CREATE_OPTIONS" && ZFSBOOT_POOL_CREATE_OPTIONS="$input" ;; + ?" $msg_zfs_compatibility") + # Dialog prompt for ZFS compatibility template from /usr/share/zfs/compatibility.d/ + # and /etc/zfs/compatibility.d/ + dialog_zfs_compatibility + ;; esac done