I have installed Ubuntu 12.04 and want to increase my swap size from 1Gb to 4Gb. how can I do this?

/dev/sda5                               partition       1046524 568284  -1

3 Answers 3


If you only have occasional need of >1GB of swap space, you may consider creating a swap file in addition to the dedicated swap partition, which will avoid having to dig up a live CD/USB and resize partitions.

Create a swap file:

sudo fallocate -l 3G /swapfile
sudo chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile

Add it to your /etc/fstab file so that you don't have to manually re-enable it each boot.

/swapfile none swap sw 0 0

You can set the priority of the two swap areas separately if you want the system to use the dedicated partition with higher priority. Add a pri=N option to the mount options in /etc/fstab, eg:

UUID=xxx...yyy none swap sw,pri=10 0 0
/swapfile none swap sw,pri=1 0 0

Here is it


You will need a Ubuntu LiveCD for this


GParted (available in the repositories) allows you to play with partitions, including resizing them without data loss, but you are strongly suggested to back up all your data before doing so...

RAM is really cheap these days (4GB module around 20$). You might want to consider just buying more RAM if you are making heavy use of your swap partition. It is faster and having more than one module is always good anyway.

Not the answer you're looking for? Browse other questions tagged .