This tutorial by user Rudraraj shows us how to get swap file added to FreeBSD 10.1.


In this post, we will see how to add swap file in FreeBSD 10.1. A swap area comes in handy if you are running a system with low memory. However, It is strongly recommended that you add up more physical memory (RAM) if possible. Because swapping degrades the system performance in the long run and also these days memory modules have become cheap so adding up memory should be the ideal choice.

1) Create the swap file:

dd if=/dev/zero of=/usr/swap0 bs=1m count=1024

Here we have created a swap file of 1 GB size. we have defined  block size (bs) as 1 MB, and count as 1024. So it is 1MBx1024 = 1024MB i.e; 1 GB

2) Set Correct Permission on the new swap file:

chmod 0600 /usr/swap0

3) Make the swap file availability persistent across reboots by adding the following information in ‘/etc/fstab‘:

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

The md(4) device md99 is used, leaving lower device numbers available for interactive use. Please note the option ‘late‘ defined in the above ‘/etc/fstab‘ entry. This is done as a workaround to do away with a bug as reported here (

4) Make the swap space available immediately:

swapon -aq

5) Check the swap Information:

# swapinfo -m
Device             1M-blocks    Used      Avail     Capacity
/dev/md99           1024         0        1024         0%

Thats It…!!! We are done…!!!!