I need additional swap space to improve my FreeBSD Unix server/desktop performance. How do I add a swap file to FreeBSD system using command line options without creating a new partitions? How do I encrypt swap space on a FreeBSD Unix server for security purpose?
[donotprint][/donotprint]A swap is nothing but space or file on a disk that can used as virtual memory. In FreeBSD and Unix-like operating systems, it is common to use a whole partition of a hard disk for swapping. When a FreeBSD based server runs out of memory, the kernel can move sleeping or inactive processes into swap area. A dedicated Swap partition goes a long way to avoid system freeze but if you notice you are running out of RAM or your applications are consuming too much of it then you may want to setup a swapfile. This guide helps you add a swap space on FreeBSD based Unix server.
How do I add swap on FreeBSD version 9 or older?
You will create the swap file by typing the following dd command as the root user:
You can also use pstat or swapinfo commands: # pstat -s OR # swapinfo -k You can also use vmstat/systat commands: # vmstat # systat swap See man pages for more info: $ man vmstat $ man systat $ man top $ man swapinfo $ man pstat
This entry is 2 of 2 in the Linux and UNIX Swap File Management Tutorial series. Keep reading the rest of the series:
The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.