How big should I make my swap partition?

See https://help.ubuntu.com/community/SwapFaq

Here is an excerpt:


How much swap do I need?

For less than 1GB of physical memory (RAM), it's highly recommended that the swap space should, as a base minimum, be equal to amount of RAM. Also, it's recommended that the swap space is maximum twice the amount of RAM depending upon the amount of hard disk space available for the system because of diminishing returns.

For more modern systems (>1GB), if you use hibernation, your swap space should minimum be equal to your physical memory (RAM) size, otherwise you need a minimum of round(sqrt(RAM)) and a maximum of twice the amount of RAM. The only downside to having more swap space than you will actually use is the disk space you will be reserving for it.

The "diminishing returns" means that if you need more swap space then twice your RAM size, you'd better add more RAM as Hard Disk Drive (HDD) access is about 10³ slower then RAM access, so something that would take 1 second, suddenly takes more than 15 minutes! And still more than a minute on a fast Solid State Drive (SSD).


For a netbook, you'll probably want to be able to hibernate the computer. The process of hibernation requires that all the data¹ in RAM be written out to the hard disc, in swap, which means that it's a good idea to have at least as much swap space as RAM. If you don't need to hibernate the computer you won't need that much swap.

Now, the trick is that this swap space doesn't actually have to be a dedicated swap partition. Like Windows, the kernel can use swap files on your regular filesystem², and they're just as fast as a swap partition. It's much easier to add more swap with a swap file than to re-partition, though. See the FAQ from this answer for instructions on how to add swap files.

So, in short, don't worry about how much swap you need; if you need more, you can easily add it.

¹: This is not quite true - before writing the data in RAM to swap, the kernel will remove from memory everything that it can. This will generally include a lot of program code (because the kernel can just read it back from the disc) and all the disc cache, etc.

²: This capability is actually filesystem-dependent. Most linux filesystems support having swap files on them - ext4, which is the default, certainly does. The new btrfs filesystem is an exception, so if you're playing with that you'll need a swap partition.


Usually it should be equal to your RAM which makes it 2GB which should be enough for day to day applications.