Howto expand swap space by adding a swap file in Ubuntu

This post was written by admin on December 26, 2009
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:

  1. Optimize the Usage of Swap to Speed up Response for Ubuntu
  2. Clean up cache,useless file/kernel to free disk space by Ubuntu-Tweak
  3. Ubuntu using Ramdisk for better performance and fast response
  4. PySdm – Simple GUI tool Auto-Mounting hard disks at startup
  5. Manually adding/removing entries to Grub 2 Menu

    Reader Comments

    This is real simple. Thanks a lot for the post , it really helped me.

    [Reply]

    #1 
    Written By vipul on January 19th, 2010 @ 7:47 pm

    Thanks a lot !

    [Reply]

    #2 
    Written By Ricardo on October 17th, 2011 @ 8:17 am

    Add a Comment

    required, use real name
    required, will not be published
    optional, your blog address