Index: usr.sbin/bsdinstall/scripts/zfsboot =================================================================== --- usr.sbin/bsdinstall/scripts/zfsboot +++ usr.sbin/bsdinstall/scripts/zfsboot @@ -123,8 +123,22 @@ # # How much swap to put on each block device in the boot pool # NOTE: Value passed to gpart(8); which supports SI unit suffixes. -# -: ${ZFSBOOT_SWAP_SIZE:=2g} +# Keep algorithm in sync with SWAP_SIZE() in part_wizard.c. +if [ -z "${ZFSBOOT_SWAP_SIZE}" ]; then + case $(sysctl -n hw.pagesize) in + 65536) + pgs_per_gb=16384 ;; + 16384) + pgs_per_gb=65536 ;; + 4096|*) + pgs_per_gb=262144 ;; + esac + swap=$(($(sysctl -n hw.availpages) / $pg_per_gb / 20)) + if [ $swap -lt 4 ]; then + swap=4 + fi + ZFSBOOT_SWAP_SIZE=${swap}g +fi # # Should we use geli(8) to encrypt the swap?