Ubuntu 12.04 increase swap

12,185

Solution 1

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

Solution 2

Here is it

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

You will need a Ubuntu LiveCD for this

Solution 3

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:
12,185

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin almost 2 years

    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
    
  • Eliah Kagan
    Eliah Kagan over 11 years
    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
  • Kaz Wolfe
    Kaz Wolfe over 10 years
    +1 Great method. Worked for me, no more "Out of RAM" errors.
  • Rachid
    Rachid almost 10 years
    This is amazing!