The swap partition is one of those classic features that’s been part of Linux for ages. Almost every Linux installation guide includes a step where you’re told to create one. And let’s be honest—most of us go ahead and do it simply out of habit, not because we’ve actually thought about whether we need it.
Back in the early 2000s, things were different. We were working with systems that had 64 or 128 MB of RAM (maybe 256 MB if you had a high-end setup) running at 133 MHz and spinning SATA drives at 5400 RPM. In those days, having a swap partition wasn’t optional—it was essential.
But fast-forward 20+ years, and the landscape has completely changed. Today, even average laptops and desktops have 16 or 32 GB of RAM running at 3200 MHz or higher. And for the hardware enthusiasts out there, they’re rocking setups with 64 or even 128 GB of RAM, often overclocked to ridiculous speeds.
Storage has evolved too—NVMe drives have largely replaced old-school hard drives in desktop systems, offering blazing-fast read and write speeds in the thousands of megabytes per second.
So why bring all this up? Because it directly affects whether you actually need a swap partition on a modern Linux system. Or, going one step further—could it actually be hurting system performance instead of helping?
That’s exactly what I want to explore in this article. While covering all the important details, I’ll try to break it down clearly and approachable—especially for those who might not be super technical. We’ll look at what a swap partition is, what it’s good for, and where it might fall short. Stick with me—it’s going to be a worthwhile read.
What Is Linux Swap?
Swap is a special area on your storage device—commonly a partition or a file—that the Linux kernel uses as virtual memory when the system’s RAM is full. You can think of it as an “emergency overflow” for memory. Whenever the operating system’s real (physical) memory is in high demand, data can be temporarily shifted out of RAM and into a swap.
The goal is to free up space in RAM for active processes. However, this has a price, and in this case, swap is much slower than system memory because it resides on disk. Unlike operations on RAM, which are pretty much instant, anything involving swap is slower—after all, it involves reading from and writing to the disk. And to make it even clearer, I will present things like this:
Medium | Speed |
---|---|
RAM | ~10–100 nanoseconds |
SSD | ~50–100 microseconds |
HDD | ~5–15 milliseconds |
In other words, swap is thousands of times slower than RAM, especially on HDDs. On SSDs, it’s better, but it’s still noticeably slower than RAM.
Now, here’s another interesting point: how does the kernel decide which processes to move from system memory to swap? Well, first off, it makes that decision dynamically using a complex page replacement algorithm. If there are portions of memory that a process allocates but barely touches, the kernel can “swap out” that memory to free up space for more frequently accessed data.
Moreover, it is important to understand that it doesn’t swap entire processes but instead moves only less frequently accessed data (pages). Can you control this? Sure, it’s Linux.
The kernel’s swappiness
option (a sysctl parameter ranging from 0 to 100) controls how aggressively the kernel prefers to swap out pages. A lower value tells the kernel to avoid swapping whenever possible, while a higher value allows more proactive swapping. The default value is 60, and you can check it using:
cat /proc/sys/vm/swappiness
Code language: Bash (bash)
In other words, a low value (e.g., 10) means that the system prefers to keep things in RAM as long as possible. On the contrary, a high value (e.g., 80 or 100) tells the kernel to start swapping earlier to free up more cache.
Of course, you can change this behavior temporarily by running sudo sysctl -w vm.swappiness=X
, or make it permanent by editing the “sysctl.conf” file to include “vm.swappiness=X” and then reloading it with sudo sysctl -p
.
Setting “swappiness=0” effectively tells the system not to swap application memory to disk, helping keep everything running in RAM instead. In any other situation, even when there’s still RAM available, the Linux kernel will continue to move infrequently used memory pages into swap space.
However, I’d recommend not making any changes unless you’re absolutely sure about what you’re doing.
What happens if a process suddenly starts gobbling up all your system’s memory (and you don’t use swap, or it’s already all filled up)? Well, that’s when things can get a little ugly.
In that situation, the Linux kernel steps in like a watchdog—it doesn’t hesitate to kill the process immediately by sending it a SIGKILL signal. It doesn’t matter how important the process is to you or the system—the kernel will do whatever it takes to prevent a complete system freeze.
Finally, very briefly, something very important – the types of swap. In Linux, there are two kinds you can use:
- Swap Partition: Historically, the common method. Represent a separate dedicated partition on the disk set aside solely for swap.
- Swap File: A normal file on an existing partition, configured so the kernel treats it as a swap space. Easier to resize if you need more (or less) swap in the future. It is often used in modern systems, especially those installed on SSDs or in virtual machines.
Now that you’ve a good understanding of what swap does in Linux and how the kernel manages it, let’s move on to the article’s main topic.
Do You Really Need Swap on Linux?
The answer depends on a few key things. First and foremost, how much RAM does your system have? Then, would you be willing to give up the “safety net” that swap provides in exchange for a slightly better performance? And finally, are you okay with giving up the option to hibernate your computer? Let’s break that down a bit more.
If you’re running a Linux system with ample memory—say 32, 64, or even 128 GB—and you’re looking for a brief answer, then yes, you can skip using swap. This means your system might run a bit faster because the kernel works entirely in RAM instead of writing data out to disk.
Of course, there are a few things to keep in mind before going this route. The biggest one is knowing how much memory your system usually uses. For example, if you’ve got 32 GB of RAM but more than 20 GB is often in use—maybe because you’re running virtual machines, using memory-hungry software, or something similar—then skipping swap might not be the best idea.
I mean, if your system often looks like the one in the screenshot below, then having swap enabled is a must.

But if this is how things usually look, you can safely skip using swap to get better performance.

You can also consider that Linux allows memory overcommit, a memory management policy that allows the system to allocate more memory to applications than is physically available. Usually, this is fine because not all processes use all of their allocated memory at once. However, in extreme cases, if real usage exceeds physical RAM, the system can face an out-of-memory (OOM) situation.
The next thing is hibernation. This feature typically won’t work without a swap configured. Why? Because when a system hibernates, the entire state of the RAM is copied to swap. Think of it like taking a snapshot of your RAM—it captures all the processes your Linux system is currently running.
However, the following should also be considered: if you intend to use hibernation on systems with large RAM, you need a swap partition or file at least as large as your RAM. In other words, if you have 64 GB of RAM, you’ll also need at least 64 GB of swap space (either a partition or a file) for hibernation to work. That’s a pretty significant chunk of disk space to give up. So, whether or not hibernation is worth it depends on your needs—it’s totally up to you.
Wear on SSDs is another factor that can be taken into account. Although modern SSDs (especially NVMe) have fairly high endurance, constant swapping could, in theory, add unnecessary write cycles to the drive. This isn’t usually a critical problem with average usage, but it is a factor to keep in mind.
Moreover, certain latency-sensitive or real-time workloads (high-frequency trading, real-time audio/video processing/streaming, gaming systems, etc.) can be penalized if the kernel decides to swap out any part of these processes to disk. While Linux tries to keep “hot” memory in RAM, in some edge cases (especially with overcommit or incorrectly tuned “swappiness”), performance dips could occur.
Conclusion and Practical Recommendations
Yeah, I know—there’s a lot to think about when deciding whether to swap or skip it altogether. Like with so many things, the best solution usually comes down to finding a good balance. So, here are my recommendations.
If your system has a smaller amount of memory—like 8 or 16 GB—I strongly advise you to keep swap enabled.
However, if your system has 32 GB of RAM or more, a setup I really like—and regularly use—is to go for a 4 GB swap file instead of a dedicated swap partition and set the swappiness value pretty low—around 10 or 20 max. This approach comes with a handful of solid benefits.
First off, using a swap file is way more flexible. With a couple of commands, you can resize it on the fly in just a few seconds. Compare that to resizing a swap partition—it’s not only a lot more time-consuming, but even a small mistake can mess up your entire system.
Furthermore, pairing a swap file with a low swappiness setting gives you the best of both worlds: you get a safety net that helps prevent out-of-memory issues, and at the same time, your system performs better because the Linux kernel won’t jump to using swap as quickly as it normally would.
And finally, if you’re working with a system that handles latency-sensitive or real-time workloads—where even losing a microsecond isn’t an option—go ahead and disable swap entirely. Just be aware of the risks of that choice, and then enjoy the high-speed lane with nothing slowing you down.
I hope you found this article helpful. I’m curious to hear your thoughts on the topic, so feel free to share them in the comments. Until next time, friends!