Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I have installed a Unbuntu 12.04 and want to increase my swap size from 1Gb to 4Gb can anyone tell how to do this?

/dev/sda5 partition 1046524 568284 -1

share|improve this question

marked as duplicate by Alvar, James Jan 4 '14 at 23:32

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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
share|improve this answer
Even if the need for >1GB swap is constant, why not use this method? These days, swap files perform just as well as swap partitions. +1 – Eliah Kagan Jan 9 '13 at 11:46
+1 Great method. Worked for me, no more "Out of RAM" errors. – Kaz Wolfe Dec 29 '13 at 18:32
This is amazing! – tunnuz Aug 25 '14 at 5:11

Here is it

You will need a Ubuntu LiveCD for this

share|improve this answer

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.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.