To check if there are any SWAP files configured run the following command:
sudo swapon -s
It will list all swaps if any.
Ensure there is enough space on the root partition to create the swap:
df -h
Create the partition and replace count with the size of the partition in bytes:
dd if=/dev/zero of=/swap bs=1024 count=2097152
Set the Swap area with the correct settings / permissions:
mkswap /swap && chown root. /swap && chmod 0600 /swap && swapon /swap
Add new swap drive to file system table:
echo /swap swap swap defaults 0 0 >> /etc/fstab
Set the “swappiness” to 0 meaning only use at the very last resort:
echo vm.swappiness = 0 >> /etc/sysctl.conf && sysctl -p
How To Install Nagios On Ubuntu 12.10