Earlier quoted context omitted.
This comes up every time swap is mentioned. Even if you have plenty of ram, having swap can help with performance. Why? Because the OS can page rarely used or seemingly downright unused dirty pages to swap, freeing up precious RAM for caches. I'd hazard a guess that especially if you run a ton of containers this can help, as there's probably a lot of memory getting dirtied on initialization of containers and their pr…
Something I've never understood is why, say, 60GB RAM + 4GB swap is supposed to be faster than 64GB RAM + no swap. Or why 64GB RAM + 4GB swap is supposed to be faster than 68GB RAM. I get the hibernation argument, but not the arguments implying swap is always better. Actively using 60GB RAM and moving 4GB of unused pages to swap (60+4), is somehow faster than actively using 60GB RAM and keeping unused pages in the re…
Stop making swap partitions—use swap files instead
221–230 of 256 posts
Re: Stop making swap partitions—use swap files instead
#222Earlier quoted context omitted.
Any tips on measuring the impact of not having swap? I never use it on my machines for similar reasons.
Worst thing that's ever happened to me is having processes randomly killed by the OOM killer. Could be unpleasant if you're writing an email or document that suddenly disappears because your app got killed.
If it's killing your email editor then your email editor is bloated or you just need more RAM - or swap.
Re: Stop making swap partitions—use swap files instead
#223Tangential, but does anyone know why in 2026 and on Debian 13, my machine still hangs when some process exhausts RAM? Is there really no higher-priority kernel process to prevent total freeze of the system and send a SIGKILL to the culprit process when such a scenario happens?
This has finally been fixed in the latest Ubuntu version (26), it now force closes the culprit.
Re: Stop making swap partitions—use swap files instead
#224Couple of things this didn't consider. * If you have a small root partition, the default config puts the swap file on there, wasting precious space. * With a partition, it's easier to put swap on a separate physical device, which is good for performance. * If you dual boot 2+ Linux distributions or installations on a single machine, as I do routinely, you can share a single swap partition between distros no problem.…
> If you have a small root partition, the default config Of what distro? If you mean that the example code shows the swapfile directly under / , well of course you don't have to do it that way. > With a partition, it's easier to put swap on a separate physical device, which is good for performance. I think this is untrue on both counts. First, nobody is going to dedicate an entire physical device to swap, because the…
> Of what distro?
Of any distro. I have done such configs with Ubuntu, Debian, openSUSE, SLE, Fedora, CentOS, RHEL, Alpine, Arch, you name it.
> If you mean that the example code shows the swapfile directly under / , well of course you don't have to do it that way.
Point missed. If you have a swap file created by the installer then you do not get to specify where that swapfile is, in any distro I have seen in my 30 years of working with Linux and 38 years of Unix. (Not that swap files were common on Unix in the 20th century.)
If you specify a swap partition then you choose where it is.
> I think this is untrue on both counts. First, nobody is going to dedicate an entire physical device to swap,
Incorrect assumption. You inserted "entire device" but I did not say that. A swap partition is part of a device. The clue is there in the name.
All my Thinkpads, for example, have 2 SSDs and typically I put root on the faster SSD and /home and swap on the slower SSD (or HDD). I typically configure 4-8GB of swap even if the machine has 32GB or more of RAM -- I rarely hibernate these boxes, TBH. That is plenty. If you hibernate, swap should be at least as big as RAM, or maybe 10-20% bigger in case it's already swapping when you hibernate.
> If the device is "separate" (from what, / ?)
Yes. More or less all typical Unix-like OSes read and write a lot to and from root in use, and under load, from swap. So, put them on different physical drives and spread the load.
This has been standard practice since the 1960s!
> But also it's trivial to put a swapfile on whatever device you want. It can be anywhere reasonably sane in the filesystem, you just give it a path.
It's extra manual config. A partition is one box in the installer and done. Zero manual config.
> The file could go on whatever partition the distros can share.
Again, you miss the point.
1. Distros do not by default mount one another's partitions.
> Maybe put it under /home or something.
You can but suddenly permissions and ownership become issues.
> It's your system, the FHS is up to your own interpretation.
It is preferable to do this in the installer and not worry about interpreting anything.
> Why would that matter? You're expecting a file not to survive the low-power state?
Have you read the other comments?
Re: Stop making swap partitions—use swap files instead
#225Earlier quoted context omitted.
Something I've never understood is why, say, 60GB RAM + 4GB swap is supposed to be faster than 64GB RAM + no swap. Or why 64GB RAM + 4GB swap is supposed to be faster than 68GB RAM. I get the hibernation argument, but not the arguments implying swap is always better. Actively using 60GB RAM and moving 4GB of unused pages to swap (60+4), is somehow faster than actively using 60GB RAM and keeping unused pages in the re…
I’m not sure I understand. In your equations, why is swap taking away from RAM? It’s purely additive. Say you have 64GB of RAM, of which 4GB are dirty pages that are never, or at least very rarely, accessed. With 64GB RAM + 4GB swap, you filled up your swap with them and have 64GB RAM left to use actively. With 64GB RAM + 0GB swap, you only have 60GB RAM left to use actively.
Use the 32+32 numbers if you're more comfortable with those round numbers.
If I have a system running comfortably with 32GB RAM + 32GB swap (no OOM, no swap thrashing), and I upgrade to 64GB RAM + 0 swap, what actual negative effects would I be getting for the lack of swap?
That's my question, to know if swap has any benefits other than being additional slow RAM.
Re: Stop making swap partitions—use swap files instead
#226Couple of things this didn't consider. * If you have a small root partition, the default config puts the swap file on there, wasting precious space. * With a partition, it's easier to put swap on a separate physical device, which is good for performance. * If you dual boot 2+ Linux distributions or installations on a single machine, as I do routinely, you can share a single swap partition between distros no problem.…
There are lots of very good reasons why running small root partitions on Linux desktops is a very bad idea. The smart money is on a single large partition for home and root and everything else. This way you get 100% disk availability with zero extra effort and you get maximum performance. No need to shuffle disk space around with resizing partitions or thing volumes or anything like that. Unless you have some sort of…
Re: Stop making swap partitions—use swap files instead
#227Earlier quoted context omitted.
Something I've never understood is why, say, 60GB RAM + 4GB swap is supposed to be faster than 64GB RAM + no swap. Or why 64GB RAM + 4GB swap is supposed to be faster than 68GB RAM. I get the hibernation argument, but not the arguments implying swap is always better. Actively using 60GB RAM and moving 4GB of unused pages to swap (60+4), is somehow faster than actively using 60GB RAM and keeping unused pages in the re…
The actual choice is 32GB RAM + 32GB swap or 32GB RAM + no swap. This is because people already bought their RAM and disks by the time they make the decision, and aren't using the whole disk.
What does the OS do differently with swap vs RAM? What can I do with swap that I cannot do with RAM? Things like that.
Re: Stop making swap partitions—use swap files instead
#228Earlier quoted context omitted.
The actual choice is 32GB RAM + 32GB swap or 32GB RAM + no swap. This is because people already bought their RAM and disks by the time they make the decision, and aren't using the whole disk.
I mentioned this in a response[1] to a sibling comment, but my question is more about learning what are the advantages of swap itself, other than just cheaper slow RAM. What does the OS do differently with swap vs RAM? What can I do with swap that I cannot do with RAM? Things like that. [1]: https://news.ycombinator.com/item?id=49670574
Re: Stop making swap partitions—use swap files instead
#229Earlier quoted context omitted.
I'm not saying to avoid swap. It is great at what it was designed to do. I only take issue with optimizing swap for bandwidth when it will never be able to keep up with RAM bandwidth. The MacBook Neo for example has 60 GB/s of RAM bandwidth but only 1.5 GB/s SSD bandwidth.
Obviously, running out of memory and resorting to swap (or other safety nets) is less than ideal. But why reject taking apparently-free steps to soften the blow? Is there some advantage in making sure that when the wall is hit, it is hit as hard as it possibly can be?
Re: Stop making swap partitions—use swap files instead
#230Earlier quoted context omitted.
Also, this seems to be based on a email from 2005, about kernel version 2.4 and 2.6, and their differences. Things might have changed since then, and also depends on a lot of factors, not the least what filesystem you use. I'm not sure people should seriously follow advice that basically boils down to "do this always it's best". Better instead to make yourself informed about the tradeoffs, then make your own choice,…
This recommendation is based off the current implementation. See: https://github.com/torvalds/linux/blob/827751b699b79a6e56998... https://github.com/torvalds/linux/blob/827751b699b79a6e56998... The thread is quoted to show that they have been functionally equivalent for several decades and yet distros continue to push outdated recommendations.
Is it possible perhaps that this advice doesn't apply equally to all situations? Is it the best for people on ZFS? Is it the best for distributions that have their own kernels builds?
I'm not saying it's a bad default, or that people should avoid it, just that it's likely not "the absolute best no questions asked" regardless of the situation, that was what I was trying to point out with my previous comment.