8G RAM and SSD – how big should the swap be?

I have a computer with 8G RAM and a 128G SSD. I don’t plan hibernating. What swap size would you recommend? Would you change any swappiness?

In the nearest future I’ll compile programs (or even kernels), run some virtual machines (leaving at least 5G free for the system), maybe occasionally play some game.

Asked By: marmistrz


There are many recommendations about the swap size i think.

One requirement i collected in the past is: if you plan to use oracle databases, the swap size needs to be twice the physical memory, or oracle cannot be installed.

Besides that, it totally depends on your needs. If you do lots of Graphical editing/ Photoshopping, then you will need lots of RAM, backed up by lots of swap Space.

For a normal user, a swap space in the size of the physical ram should be sufficient.

Have fun,

Answered By: gerhard d.

You should be fine with just 2 or 4 Gb of swap size, or none at all (since you don’t plan hibernating).

An often-quoted rule of thumb says that the swap partition should be twice the size of the RAM. This rule made sense on older systems to cope with the limited amount of RAM; nowadays your system, unless on heavy load, won’t swap at all.

It mostly depends whether you’re going to do a memory-intensive use of your machine; if this is the case, you might want to increase the amount of RAM instead.

Note that a SSD is subject to more wear and tear than a hard disk, and is limited by a number of rewrite cycles. This makes it not optimal to host a swap partition.

Edit: Also see this question: Linux, SSD and swap

Answered By: dr_

Assuming we are not rehashing Is swap an anachronism? conversations/debates, I would suggest you take a look at the archlinux wiki on the topic. As always it is a great resource for any distro and covers the basics as well as suggested performance tuning for ssd’s.

The tldr; according the the arch wiki:

Swap space is generally recommended for users with less than 1 GB of RAM, but becomes more a matter of personal preference on systems with gratuitous amounts of physical RAM (though it is required for suspend-to-disk support).

Answered By: sam

It’s fairly easy to have 8GB of RAM on a desktop, and old rules of thumb on swap partition size will give you a huge amount of virtual RAM, but it does depend on the software you are running.

So check what your computer is doing. There are graphical programs such as Task Manager and command-line programs such as free -h (I use that form of the command because it’s easier for a human).

There are programs which struggle in 4GB of RAM. It isn’t just the particular program, there is a lot of OS code that has to be there, and when you go to 8GB, you can get a little careless about what’s running. If you don’t need to swap, use the RAM.

I have noticed the 4GB struggle with Kerbal Space Program and the Firestorm viewer for Second Life. There are alternatives to Firestorm which don’t need so much RAM. Same task, different demands, that’s why you have to measure.

Answered By: Wolf Baginski

Traditionally there’s been a lot of stuff about choosing a swap partition size dependent on your RAM size, but I think that’s always been a bit of fluff. I don’t see the point – apart from Hibernation which I’ll get to. It seems to have been based on some misguided notation that your RAM usage scales with your RAM size, and that, for some reason, if you increase your RAM you’ll need to swap more.

Think about that. If you increase RAM you won’t need to swap more – logically, you should need less. Or at least, need it less often. In reality, we do a lot and have a lot of processes running all the time, and it still makes sense to have some token amount of swap to protect our system from out of memory situations and to ensure a well-running cache. More RAM is always better than more swap, but some swap is still a nice buffer even if you never end up using it in normal situations.

My firm feeling is that 2 to 4GB for swap partition is suitable for general use – whether your RAM is 2GB or 64GB.

But, if you have a specialist need, ie your system is not for "general use" – then that may have other implications, like the other answer which talks about a dedicated oracle database server.

Now, about hibernation. Using swap space for hibernation is not the best idea, though I concede it made more sense back when disks were small and RAM was usually much smaller than swap. If you have data in swap, and then you hibernate, you need to hibernate both what’s swapped and what’s in RAM anyway, so you need quite a large space – essentially your swap needs to be approximately current RAM size + maximum amount you expect to be resident in swap, though not everything in RAM needs to be swapped eg disk caches.

I’m perfectly happy to forego hibernation completely these days. It’s much slower than suspend to RAM, and depending on your disk drive and RAM size is often slower than a cold boot these days, too.

Answered By: trr
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.