Howto expand swap space by adding a swap file in Ubuntu
This post was written by admin on December 26, 2009
Posted Under: General
Posted Under: General
This post shows how to supplement your swap partition with a swap file.Quote from a thread in Ubuntuforums post by jdong.
First, create a 1000M swap file:
sudo dd if=/dev/zero of=/swap_file bs=1M count=1000
recommend size of swap is half of RAM,so replace 1000 with the size of the swap file desired, in MB. You can also put the swap_file in a different location if desired.
Next, we’ll secure the swapspace, so ordinary users cannot read the contents:
sudo chown root:root /swap_file
sudo chmod 600 /swap_file
Then,turn it into swap space, and turn it on:
sudo mkswap /swap_file
sudo swapon /swap_file
Finally,make it turn on at every bootup, open up /etc/fstab:
sudo gedit /etc/fstab
add this line to the end of the file:
/swap_file none swap sw 0 0
Thanks,jdong from:http://ubuntuforums.org/showthread.php?t=89782
Related posts:
- Clean up cache,useless file/kernel to free disk space by Ubuntu-Tweak
- Manually adding/removing entries to Grub 2 Menu
- Fix system only boots into memtest after install Ubuntu 9.10(Karmic)
- Howto Change Plymouth themes (initial splash screen) in Ubuntu 10.04
- How to know last Accessed File Time in Ubuntu

Reader Comments
This is real simple. Thanks a lot for the post , it really helped me.
[Reply]