I recently installed and configured FreeBSD 10.0 on an old desktop so that I could learn the system. I have been surprised by how powerful it is, and I had assumed that since it was a Unix, that I would know everything about it having had a decade of experience with Linux, but I was wrong. It is still very different, and those differences are what make it a good OS. One thing that surprised me, was that you can use a Swap File (in /usr/swap0) instead of a swap partition.
When I installed I went with the ZFS system, and I had assumed that it would automatically configure a swap partition. It did not, and my system really started heating up under the heavy work load of compiling software, and the system fan ran so hard my computer literally started to sound like a blow dryer.
Once I realized the mistake, I followed the instructions from section 12.2 of the handbook...
this command creates the swap file, and writes zeroes to it, I made it 2 gigs, you can make it whatever you want by changing the "count=" flag, a good rule of thumb is swap should be twice system ram.
dd if=/dev/zero of=/usr/swap0 bs=1m count=2048
and then change permissions on the swap file ...
chmod 0600 /usr/swap0
then add the entry to the fstab file in /etc
md99 none swap sw,file=/usr/swap0 0 0
it is named md99, memory device 99 to leave smaller numbered md's (i.e. md01 md02 etc) available for you to use. The Handbook mentions that a kernel module must be pre-loaded or a custom kernel compiled to use this feature, but from 10.0 on the GENERIC kernel supports this out of box, so no worries there.
Reboot, or start swap with ...
swapon -aq
and your system should be running more smoothly. the command
mount -a
or
mount
will not list the swap file (because it is a file and not a partition), but you can see the added memory listed in the command
top
Now my system runs so much smoother I don't think I have heard the system fan even once, I even wondered if the fan had died, and had to check that it was still working, it was.
