# Swap "kern.maxswzone" Help



## markbsd (Nov 9, 2013)

Not sure where to post this; if in the wrong section, please move to where appropriate.


```
# dmesg
warning: total configured swap (1116672 pages) exceeds maximum recommended amount (855904 pages).
warning: increase kern.maxswzone or reduce amount of swap.
```

I've been googling for a while now, and have yet to find exactly where I configure kern.maxswzone, or exactly how much to set for it.

I think, /boot/loader.conf is where I set the option, but I don't even have a loader.conf file (I suppose I just `cp` /boot/defaults/loader.conf to /boot/loader.conf). But, I really have no idea how much to set it to, or what other options I should also change as the default file has everything commented out.

`man loader` doesn't really clear anything up for me either.


```
% sysctl kern.maxswzone
kern.maxswzone: 36175872
```

So, how much do I increase it to, and where do I set this increase?


----------



## markbsd (Nov 9, 2013)

Okay -- I think I just create a new file (/boot/loader.conf) and need to add just one line:


```
kern.maxswzone=[multiple of 32]
```

My current kern.maxswzone (according to sysctl) is 36175872. My current total configured swap (pages) is 1116672 pages (4 GB).

I don't know why it needs to be multiples of 32, or if it has to be at all. My current kern.maxswzone (36175872), however, is 32.3x times my swap pages. And google has all this talk about 32MiB, so I guess it means something. Still, I'm not sure exactly what I should increase it to. Any ideas?


----------



## xtaz (Nov 9, 2013)

Is this by any chance an amd64 architecture using a version of FreeBSD somewhere between 9.1 and 9.2? I had this problem myself after a commit to the 9.x branch once. It turned out that the limit was being set based on outdated rules assuming you were using the i386 architecture. They recommended setting it to 0 to let it choose it's own amount automatically. And this change was made the default shortly afterwards, which should have been the case in 9.2.

Note that this is only if you were using amd64. If you are using i386 then I think it needs setting properly. With i386 I think it has issues using approx 4GB or more swap.


----------



## markbsd (Nov 9, 2013)

It's i386 (2GB RAM), running 4GB of swap. I think I'm right on the limit, but have no idea what to set kern.maxswzone in /boot/loader.conf to.


----------



## markbsd (Nov 12, 2013)

I could really do with some help on this one, please!


----------



## noodlefling (Nov 14, 2013)

I ran into this same thing on i386 machine running 9.2-RELEASE.  Googling led to lots of extremely technical talk, but no practical solutions.  One thread even suggested that it's not really a problem.

I tried changing `kern.maxswzone` in /boot/loader.conf and while it did seem to actually change the value, it didn't make the error message go away.

Any common sense tips would be terribly helpful.

It looks like this popped up somewhere in between the last 9.1 patch level and 9.2, although it is possible I didn't notice the error message for a patch level or two.


----------



## kpa (Nov 14, 2013)

It's probably not a real error but rather verbose informational message about some of the more troublesome limitations of the i386 architecture. The message you get when you boot an i386 system that memory above the 4GB limit is ignored is a similar "error message" that you can safely ignore.


----------



## Hornpipe2 (Jan 21, 2014)

FYI, this is not fixed in FreeBSD 10.0 (just upgraded yesterday), and after a reboot, I got:


```
warning: total configured swap (1048576 pages) exceeds maximum recommended amount (987392 pages).
warning: increase kern.maxswzone or reduce amount of swap.
```

Some more output.  BTW this is on an i386 system with 512MiB of RAM.


```
root@server:/ # sysctl kern.maxswzone
kern.maxswzone: 36175872
root@server:/ # swapctl -l
Device:       1024-blocks     Used:
/dev/ada0p3     4194304         0
```


----------



## afberendsen (Sep 6, 2014)

Same.


```
root@h0000003:~ # dmesg|grep max
warning: total configured swap (2621440 pages) exceeds maximum recommended amount (2097312 pages).
warning: increase kern.maxswzone or reduce amount of swap.
root@h0000003:~ # sysctl kern.maxswzone
kern.maxswzone: 36175872
root@h0000003:~ # swapctl -l
Device:       1024-blocks     Used:
/dev/ada0s3a   10485760         0
```

Machine is

```
root@h0000003:~ # dmesg|grep CPU
CPU: AMD Athlon(tm) XP 2000+ (1674.47-MHz 686-class CPU)
cpu0: <ACPI CPU> on acpi0
root@h0000003:~ # dmesg | grep memory
real memory  = 3221159936 (3071 MB)
avail memory = 3141300224 (2995 MB)
```


----------

