Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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, jrg Jan 4 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.

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
share|improve this answer
2  
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. –  Whaaaaaat Dec 29 '13 at 18:32
    
This is amazing! –  tunnuz Aug 25 at 5:11

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

Here is it

https://help.ubuntu.com/community/SwapFaq#How_do_I_add_more_swap.3F

You will need a Ubuntu LiveCD for this

share|improve this answer

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