Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Jul 2014 20:15:27 -0600 (MDT)
From:      Warren Block <wblock@wonkity.com>
To:        Polytropon <freebsd@edvax.de>
Cc:        FreeBSD-Questions <freebsd-questions@freebsd.org>
Subject:   Re: How much swap space for a 32 GB RAM system?
Message-ID:  <alpine.BSF.2.11.1407222007120.28002@wonkity.com>
In-Reply-To: <20140723032002.2a34a6b1.freebsd@edvax.de>
References:  <53CE8BB8.7030303@qeng-ho.org> <20140722191548.e3945a1e.freebsd@edvax.de> <alpine.BSF.2.11.1407221119110.80885@wonkity.com> <20140723032002.2a34a6b1.freebsd@edvax.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 23 Jul 2014, Polytropon wrote:

> This is how I did it: In order to keep things simple, I added
> the following to /etc/rc.local:
>
> 	SWAP="/swapfile.tmp"
> 	/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?

It's not necessary to recreate the swap file on every boot, or manually 
add it as swap or remove it as swap.  Although there were some bugs 
with the 9.X /etc/rc.d/swapfile, it normally just required some entries 
in /etc/rc.conf.  The swap file path, for example.

>>> 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...

In 10.0, Hiroki Sato set it up to do it all from /etc/fstab, and added a 
bunch of examples to fstab(5).  Here is my entry for a swap file:

md99	none	swap	sw,file=/usr/swap/swap  0	0

That's all.  Well, the swap file has to be created before the first use. 
md99 is used to avoid having md0 tied up for a swap file when I want to 
mount an ISO.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.11.1407222007120.28002>