I'm using 2 GB RAM I've installed Ubuntu 14.04 LTS how much swap do I need to create?
4 Answers
There is varying opinion on what the size of the swap should be - here are the Example Scenarios provided in the Ubuntu wiki:
RAM(MB) No hibernation With Hibernation Absolute maximum
256 256 512 512
512 512 1024 1024
1024 1024 2048 2048
RAM(GB) No hibernation With Hibernation Absolute maximum
1 1 2 2
2 1 3 4
3 2 5 6
4 2 6 8
5 2 7 10
6 2 8 12
8 3 11 16
12 3 15 24
16 4 20 32
24 5 29 48
32 6 38 64
64 8 72 128
128 11 139 256
Here also a table from the Fedora 64bit docs:
This mainly depends if you need want to hibernate or not - you need more as it saves the state of the system from the RAM to the swap.
Note swap may slow things down if swappiness is not configured correctly - you can read this question to find out how to do it.
If you need to increase the size of (or create) swap space, there are a few nice answers here.
-
1The Ubuntu one is here: https://help.ubuntu.com/community/SwapFaq - it doesn't have a neat table, but then again, I prefer text to images. – muru Jul 11 '14 at 21:55
For small RAM sizes like 1 or 2 or 3 GB its better to create a swap partition with double the size of RAM. eg: 4GB in your case. For rams higher like 8 GB swap partition of 2 GB will be sufficient.

- 5,113
- 4
- 24
- 27
-
1Please see: http://askubuntu.com/questions/49109/i-have-16gb-ram-do-i-need-32gb-swap Personally i HAVE 2gb OF ram in this machine and 1GB of swap and have never run out. The double RAM Swap idea is a myth perpetuated by windows due to it's poor memory management. 'nix systems are much more RAM efficient. That being said a lot depends on what you are doing with the system. Video editing requires more ram than browsing the web, playing youtube videos and checking your email. – Elder Geek Jul 10 '14 at 14:41
-
@Elder Geek- yes seems true but hibernation do requires high swap space. – Sudheer Jul 10 '14 at 14:50
-
That's a good point. I never use it. I turn things off when I'm not using them. – Elder Geek Jul 10 '14 at 14:58
-
-
-
@Sudheer As I never use it, My best guess in this instance would be 3GB – Elder Geek Jul 10 '14 at 15:01
-
-
@Elder Geek- I never used it but, want to try it sometime. Thank you for your replies. – Sudheer Jul 10 '14 at 15:02
-
1@Sudheer Not true, you can create a swap file on an existing partition. – fkraiem Jul 10 '14 at 15:03
-
@user73898 That's a different question. Look here: https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04 – Elder Geek Jul 10 '14 at 15:05
-
I have 12 Gb RAM - and I don't have any swap. I think of my RAM as if I had 8 Gb RAM and 4 Gb of fast swap :) In fact required swap depends on the computer usage. I don't think that having swap is really good idea in era when memory is one of the most cheepest pc components. – Sergey P. aka azure Jul 10 '14 at 20:20
Personally I always make my swap 512 MB, just to have some wiggle room. If the OS starts using a lot of swap, you really need more RAM. (And if getting more RAM is not an option, then you can consider having more swap, it's better than nothing.)

- 12,555
- 4
- 35
- 40
4GB.
Without additional information we can't be specific, so I'm erring on the larger side: 4GB is probably more than you need, and disk space is cheap.

- 36,774