Add temporary swap

While it would be ideal if every server had plenty of RAM, in the real world that does not happen. If for some reason you have a server with too little SWAP or you are hitting the max of the swap here is a quick hack which will create a 2Gb container file then use it for additional swap space on the server. To check the swap space used you can use free -m
Run the following from the command line to create the swap file

# dd if=/dev/zero of=/usr/swap-file bs=1024 count=2048000
# mkswap /usr/swap-file
# swapon /usr/swap-file
# swapon -s

Now add the following to the /etc/fstab file and you are done.


/usr/swap-file swap swap defaults 0 0

g33kadmin

I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.