Create Swap for Ubuntu 14.04 LTS [closed]

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.


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.


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