I have read this question, but it was asked in the context of servers not desktops or notebooks.
If a good amount of RAM is installed on a notebook, say 8 GB, do we still need a swap space?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
There is a common misconception that having a swap space is negatively affecting system performance. This is incorrect. As long as you have enough RAM, having a swap area whatever its size doesn't hurt performance at all. What affects performance is being short in RAM and effectively using the swap space.
If you have no swap space and happen to be out of RAM, the kernel will pick one or more processes which it thinks are good candidates (although you might give it some hints though) and kill them.
If you have a swap space and are out of RAM, the kernel will pick less used memory pages and put them on the swap area to free RAM. This will slow down the system but your applications won't be affected otherwise.
I always prefer case 2. as I feel uncomfortable loosing parts or all of my work because the kernel thinks my applications are worth killing. Moreover, with the current size of an average disk being in the TB range, reserving a few percent for swap is usually not an issue.
If you have a RAM of 3GB or higher, Ubuntu will automatically NOT USE the Swap space since it's more than enough for the OS.
Now do you really need a swap partition?
The answer in my opinion is yes. Because you don't know what will you be installing or doing in the future that might require the need of swap space. Also if you're planning to use hibernation, you might want to have some swap space. You actually don't have to have swap partition, but it is recommended in case you do use up that much memory in normal operation.
For the last 6 years or so I have used desktop systems with at least 8GB RAM. I don't remember a case when the system swapped out memory under normal usage - and I monitor resource usage quite often with htop. Not even in cases when I ran 4 virtual machines (servers) simultaneously for development purposes did swapping occur.
Having said that, if the applications you are running are memory intensive (eg video editing, image editing, large database table manipulation, etc) you may face a situation where your system might run out of memory. In that case it may be desirable to have a swap space. Think of it as a last resort safety net. And considering the multi-terrabyte capacity of today's systems, what's a couple of gigabytes in a swap partition worth? Better be safe than sorry :-)
Having swap space is always a good thing.
Here I'm quoting Michael Jang's RHCSA/RHCE Certification Study Guide
Linux Swap Space
Such space is used to extend the amount of effective RAM on a system, as virtual memory for currently running programs. But you can’t just buy extra RAM and eliminate swap space. Linux moves infrequently used programs and data to swap space even if you have gigabytes of RAM..
For systems of up to 2GB, the default swap space size is twice the amount of installed RAM. Above 2GB, it’s the amount of RAM + 2GB. But those are not “hard and fast” rules. Workstations with several GB of RAM frequently use very little swap space.. but it may be used more frequently on systems that aren’t rebooted for months at a time or have heavy demand from certain services.
It depends on what you are running on your system.
If you are creating content, it is probably a good idea to still have swap space allocated, so if you do run out of RAM, your processes just get slow instead of being killed and potentially losing work.
If your machine is just running programs, then you don't need or even want swap space. I design and build many kiosk-like display systems that fit this usage exactly. I'd rather a process die suddenly than be slow, because then I can detect that condition and correct it.
If you ever need swap or more swap space you can create swap files on your file system. Of course, they will not support hibernation but it is a reasonable approach for a laptop with SSD drive and a lot of RAM.