Setting SWAP Memory under Linux
These are the steps to add swap space to your Linux system through the use of swap files.
This will list any swap partitions and swap files currently in use. Your swap space should be at least twice the amount of physical RAM installed for best results. For example, a system with 512MB of physical RAM should have at least 1GB of swap space.
To configure 2GB of swap, we can make one 2GB swap file or two 1GB swap files. We'll do two 1GB swap files because one 2GB swap file might not work depending on Linux kernel support for large files (file over 2GB).
cd /var/tmp dd if=/dev/zero of=swapfile1 bs=1024 count=1048576 dd if=/dev/zero of=swapfile2 bs=1024 count=1048576
This creates the files /var/tmp/swapfile1 and /var/tmp/swapfile2, each 1GB in size. Using the "dd" command ensures that the files have no holes.
/sbin/mkswap -c -v1 /var/tmp/swapfile1 /sbin/mkswap -c -v1 /var/tmp/swapfile2
This checks each file for bad blocks, then turns it into swap space.
/sbin/swapon /var/tmp/swapfile1 /sbin/swapon /var/tmp/swapfile2
You should see entries for /var/tmp/swapfile1 and swapfile2.
In /etc/rc.d/rc.sysinit, look for a line that contains: swapon -a Append this command to enable your swap files at startup: swapon /var/tmp/swapfile1
swapon /var/tmp/swapfile2 The line should now look something like this: action "Activating swap partitions" swapon -a