I installed FreeBSD 12.2 in a VMware virtual machine, and get the following console output on every boot: > warning: total configured swap (262134 pages) exceeds maximum recommended amount (215992 pages). > warning: increase kern.maxswzone or reduce amount of swap. I selected only the defaults going through the installer on the disc1 ISO. It seems like the installer would ideally not create more swap than the kernel supports, or might arrange for loader.conf to be suitably tuned if it were to do so. robert@freebsd-amd64:~/git % gpart list Geom name: da0 modified: false state: OK fwheads: 255 fwsectors: 63 last: 41942999 first: 40 entries: 128 scheme: GPT Providers: 1. Name: da0p1 Mediasize: 524288 (512K) Sectorsize: 512 Stripesize: 0 Stripeoffset: 20480 Mode: r0w0e0 efimedia: HD(1,GPT,11392b84-42b5-11eb-a6e4-000c29a7ef2d,0x28,0x400) rawuuid: 11392b84-42b5-11eb-a6e4-000c29a7ef2d rawtype: 83bd6b9d-7f41-11dc-be0b-001560b84f0f label: (null) length: 524288 offset: 20480 type: freebsd-boot index: 1 end: 1063 start: 40 2. Name: da0p2 Mediasize: 20400570368 (19G) Sectorsize: 512 Stripesize: 0 Stripeoffset: 544768 Mode: r1w1e1 efimedia: HD(2,GPT,11397edd-42b5-11eb-a6e4-000c29a7ef2d,0x428,0x25ffc00) rawuuid: 11397edd-42b5-11eb-a6e4-000c29a7ef2d rawtype: 516e7cb6-6ecf-11d6-8ff8-00022d09712b label: (null) length: 20400570368 offset: 544768 type: freebsd-ufs index: 2 end: 39845927 start: 1064 3. Name: da0p3 Mediasize: 1073700864 (1.0G) Sectorsize: 512 Stripesize: 0 Stripeoffset: 3221245952 Mode: r1w1e0 efimedia: HD(3,GPT,1139fcde-42b5-11eb-a6e4-000c29a7ef2d,0x2600028,0x1fffb0) rawuuid: 1139fcde-42b5-11eb-a6e4-000c29a7ef2d rawtype: 516e7cb5-6ecf-11d6-8ff8-00022d09712b label: (null) length: 1073700864 offset: 20401115136 type: freebsd-swap index: 3 end: 41942999 start: 39845928 Consumers: 1. Name: da0 Mediasize: 21474836480 (20G) Sectorsize: 512 Mode: r2w2e3
I should have included this further information: real memory = 268435456 (256 MB) avail memory = 218734592 (208 MB)
(In reply to Robert Watson from comment #1) You can just ignore this warning.
There's probably also an argument for always allocating enough state to support 1GB of swap, given that possibly that is what the installer thinks is the minimum?
(In reply to VVD from comment #2) I am happily ignoring the warning. But I guess the point I'm trying to make is: Our installer should not, by default, create configurations that require warnings. This might be fixed by changing the behaviour of the installer (set up less swap if we're going to create a configuration that will trigger a warning), or by changing the kernel (e.g., to to tune for at least 1GB of swap no matter the physical memory size, since we've decided in the installer that 1GB is a good minimum). Or maybe the warning is boring and we should suppress it.
Absolutely we should not have warnings that should be ignored or are unactionable after completing a default install. That said, for this specific case I think a warning for the relatively small amount of memory provisioned for the VM might be appropriate.
Or we can grab the maximum from sysctl: % sysctl -d vm.swap_maxpages vm.swap_maxpages: Maximum amount of swap pages supported % sysctl vm.swap_maxpages vm.swap_maxpages: 4019904
If bsdinstall warned that the VM might be under provisioned, and we expect that the VM might get resized as a result, we would likely want to the larger swap size. This suggests that the problem is too many warnings from the kernel, and not enough from the installer?
What might a suitable patch look like or do?
(In reply to Kubilay Kocak from comment #8) The warning was added in: commit 3ff863f1aa52963ea55487477573f70caa275a94 Author: Dag-Erling Smørgrav <des@FreeBSD.org> Date: Thu Aug 16 08:29:49 2012 +0000 - When running out of swzone, instead of spewing an error message every tick until the situation is resolved (if ever), just print a single message when running out and another when space becomes available. - When adding more swap, warn if the total amount exceeds half the theoretical maximum we can handle. Notes: svn path=/head/; revision=239327 I suspect the real issue is: > real memory = 268435456 (256 MB) Typical installations likely involve a minimum of 1GB of RAM, or maybe 512MB. The installer's swap size default is set by: #define SWAP_SIZE(available) MIN(available/20, 4*1024*1024*1024LL) > What might a suitable patch look like or do? Could be one or more of: - add another limit to the SWAP_SIZE MIN(), so that we'd choose less swap for this installation (either "real memory" or the vm.swap_maxpages sysctl) - have the installer produce a warning when run on a system with less than 512MB of RAM - instead of emitting a warning from the kernel, just ignore (do not use) provided swap space that's above what kern.maxswzone permits
^Triage: clear unneeded flags. Nothing has yet been committed to be merged.
I have submitted https://reviews.freebsd.org/D50942 to sync the UFS and ZFS swap defaults as a first step, and will later look at a possible maximum to avoid the maxswzone warning. We also use the swap partition for kernel dumps though and might want to make sure it is large enough to capture a dump. I'm not sure if the default of MIN(avail/20, 4GB) is suitable today but either way I suspect that a limit based on maxswzone will be too small on high-memory systems.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=eb5884c564ae0e37df1d8a3fc5704ab6b2fa07d0 commit eb5884c564ae0e37df1d8a3fc5704ab6b2fa07d0 Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2025-06-19 19:48:14 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2025-06-20 19:22:18 +0000 bsdinstall: Emit a warning if the system has too little memory PR: 251993 Reviewed by: adrian Event: Kitchener-Waterloo Hackathon 202506 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D50944 usr.sbin/bsdinstall/scripts/auto | 8 ++++++++ 1 file changed, 8 insertions(+)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=525795cde28bbbc0aba3e5f359dfc877b9f248d1 commit 525795cde28bbbc0aba3e5f359dfc877b9f248d1 Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2025-06-19 19:48:14 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2025-07-30 18:06:38 +0000 bsdinstall: Emit a warning if the system has too little memory PR: 251993 Reviewed by: adrian Event: Kitchener-Waterloo Hackathon 202506 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D50944 (cherry picked from commit eb5884c564ae0e37df1d8a3fc5704ab6b2fa07d0) usr.sbin/bsdinstall/scripts/auto | 8 ++++++++ 1 file changed, 8 insertions(+)
Not yet fixed
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=52f9722e6ffff6fee309e6040b7b5313499a03ef commit 52f9722e6ffff6fee309e6040b7b5313499a03ef Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2023-03-06 20:24:05 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2025-10-15 16:29:56 +0000 bsdinstall: Limit default swap to maximum supported by kernel PR: 251993 Reviewed by: cperciva Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D53106 usr.sbin/bsdinstall/partedit/part_wizard.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=8f84fdda4c788d63cf0bb0bb19962a0ebcf2e6a4 commit 8f84fdda4c788d63cf0bb0bb19962a0ebcf2e6a4 Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2023-03-06 20:24:05 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2025-12-16 15:40:40 +0000 bsdinstall: Limit default swap to maximum supported by kernel PR: 251993 Reviewed by: cperciva Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D53106 (cherry picked from commit 52f9722e6ffff6fee309e6040b7b5313499a03ef) usr.sbin/bsdinstall/partedit/part_wizard.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)