How much swap space for a 32 GB RAM system?

Polytropon freebsd at
Wed Jul 23 01:20:08 UTC 2014

On Tue, 22 Jul 2014 11:22:07 -0600 (MDT), Warren Block wrote:
> On Tue, 22 Jul 2014, Polytropon wrote:
> > On Tue, 22 Jul 2014 17:05:12 +0100, Arthur Chance wrote:
> >> I'm getting a new machine with 32 GB of memory. The old "twice physical
> >> memory" sizing seems ridiculous, so how big should I make swap? Do I
> >> even need swap with this much memory?
> >
> > Need? Probably not, but you _never_ know... So preparing
> > a file-backed swap could be a nice solution: you do not
> > have to dedicate a fixed size partition for swap, and
> > depending on your disk setup (maybe SSD?) the speed (_if_
> > it gets in use) will be good enough. In order to do this,
> > you use dd to create a sparse file,
> File yes, sparse file no.  Bad Things(TM) may happen with a sparse file.

Okay, probably wrong terminology here. :-)

This is how I did it: In order to keep things simple, I added
the following to /etc/rc.local:

	/bin/rm -f $SWAP
	/bin/dd if=/dev/zero of=$SWAP bs=16m seek=1k count=0
	/sbin/mdconfig -a -t vnode -u 0 -f $SWAP || /bin/sh
	/bin/chflags nodump $SWAP
	/sbin/swapctl -a $SWAP

And /etc/rc.shutdown.local cleans it up:

	/sbin/swapctl -d /dev/md0
	/sbin/mdconfig -d -u 0

Suggestions for improvement?

> > configure it as a
> > memory disk, and enable it with swapctl.
> In 10.x, this can be done in /etc/fstab.

This is on (or for) 10.0, how exactly does it work, which options
are involved? Note that the above method has been "invented" for
the use with SSDs in FreeBSD 8 and 9, so possibly it's easier to
do something similar in FreeBSD 10...

Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...

More information about the freebsd-questions mailing list