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: help.ubuntu.com/community/SwapFaq - it doesn't have a neat table, but then again, I prefer text to images.– muruJul 11, 2014 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.
-
1Please see: askubuntu.com/questions/49109/… 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. Jul 10, 2014 at 14:41
-
@Elder Geek- yes seems true but hibernation do requires high swap space.– SudheerJul 10, 2014 at 14:50
-
That's a good point. I never use it. I turn things off when I'm not using them. Jul 10, 2014 at 14:58
-
-
1@Sudheer Not true, you can create a swap file on an existing partition.– fkraiemJul 10, 2014 at 15:03
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.)
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.