Benaiah\’s Computer Experiences

November 27, 2007

Adding a Swap Partion to an Existing System

Filed under: Linux, swap, ubuntu — Benaiah @ 12:38 am

When I first installed Ubuntu I did not make a swap partition. Today I decided to go back and do so. Here is how I did it.

Using GParted I created the new partition on my hard drive. GParted is not installed by default, you can find it by going to

Applications >> Add/Remove…

and searching for “gparted.” Once it is installed you will find it under

System >> Administration >> Partition Editor

From there you can easily resize your current partitions and add a new one for the swap file. When creating the new partition select “linux-swap” as the filesystem. A common recommendation for swap file size is to make your swap partition about the same size as the amount of RAM in your computer. So if you have 512 MB of RAM make your swap file 512 MB. If you have the hard drive space however, you may want to go ahead and give the swap partition a full 1GB of space.

Once your swap partition has been made you need to tell the operation system to use it.

Assuming that the new partition is /dev/hda3 ( you can find this information by opening GParted and looking in the left most column)

sudo mkswap /dev/hda3

sudo swapon /dev/hda3

Finally to make this change permenant you need to add it to your fstab. To open the file:

sudo nano /etc/fstab

Add the following entry:

/dev/hda3 none swap sw 0 0

the last two characters in the above being zeros.
You should now have a functioning swap partition!

Advertisements

Create a free website or blog at WordPress.com.