0

I'm using 2 GB RAM I've installed Ubuntu 14.04 LTS how much swap do I need to create?

Braiam
  • 69,112
Swapnil
  • 873

4 Answers4

4

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:

For <2GB, it recommends  the swap should be '3 times the amount of RAM' in size.

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.

Wilf
  • 30,732
1

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.

Sudheer
  • 5,213
1

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.)

fkraiem
  • 12,813
0

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.

thomasrutter
  • 37,804