Live data from Hacker News

Stop making swap partitions—use swap files instead

gist.github.com

21–30 of 256 posts

Re: Stop making swap partitions—use swap files instead

#21

Tangential, 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?

Just mentioning this in case it's helpful:

If you know ahead of time which programs / processes are at risk of unacceptably high memory usage, check out "ulimit".

Re: Stop making swap partitions—use swap files instead

#22

Earlier quoted context omitted.

This is called an oomkiller. The kernel has one but it kicks in very late and the kernel prefers to do page trashing instead of killing processes. systemd-oomd should be integrated in systemd, you can configure it to your liking and see if it improves your problem.

I believe that you mean: https://en.wikipedia.org/wiki/Thrashing_(computer_science) Chris Siebenmann discusses when the OOM killer triggers: https://utcc.utoronto.ca/~cks/space/blog/linux/OOMKillerWhen Chris disables systemd-oomd after it obliterates his X session with no explanation: https://utcc.utoronto.ca/~cks/space/blog/linux/SystemdOomdNo...

> First off, this is exactly how systemd-oomd is supposed to behave under memory pressure. The documentation is specific on this; systemd-oomd itself says:

> > [...] If the configured limits are exceeded, systemd-oomd will select a cgroup to terminate, and send SIGKILL to all processes in it. [...]

> By having the user@.service template be enrolled in systemd-oomd, Fedora made the cgroup that systemd-oomd would select to be killed be all of your processes (across all of your sessions, if you have more than one). ...

Maybe *Fedora* has fixed or improved in the last 4 years. Or maybe they don't run Fedora.

Re: Stop making swap partitions—use swap files instead

#23

Tangential, 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?

Set `/sys/kernel/mm/lru_gen/min_ttl_ms` at boot (see https://docs.kernel.org/admin-guide/mm/multigen_lru.html).

User-space OOM killers never really worked for me and imo are not a proper solution anyway. This option instead lets you make the kernel OOM killer actually work for desktop use.

Currently have it set to `1000` and it works very well for me (don't remember the last time I had a full system freeze due to OOM).

Re: Stop making swap partitions—use swap files instead

#24

Tangential, 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?

not tangential at all...try setting up a swap partition

Re: Stop making swap partitions—use swap files instead

#25
post #18

Tangential, 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?

OS are designed to fully exploit available resources, Linux tries its best before triggering an OOM kill. I recommend using the earlyoom if you want more aggresive oom kill: https://github.com/rfjakob/earlyoom The README contains a lot of interesting information.

A strange behavior I sometimes run into with earlyoom is that I try to start up some buggy software of mine and it seemingly never starts.

It took a long evening to figure out that it gets earlyoom'd immediately because it tries to allocate too much. Previously the very familiar hitching and freezing was a very easy sign of what kind of issue I was dealing with

Re: Stop making swap partitions—use swap files instead

#26

Tangential, 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

#27

Every rule has an exception. Beware of this advice on zfs, for instance. Meanwhile zswap (of no relation with zfs) is free performance. Is it a rule that everything starting with a 'z' must be cool?

It also doesn't sound like a particularly good idea on BTRFS, judging by the linked documentation:

https://btrfs.readthedocs.io/en/latest/Swapfile.html

Re: Stop making swap partitions—use swap files instead

#28

Tangential, 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?

not tangential at all...try setting up a swap partition

[flagged]

Re: Stop making swap partitions—use swap files instead

#29

Tangential, 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?

> does anyone know why

In a nutshell, overcommit. It's more or less broken by design but it's also incredibly practical so pretty much everyone does it.

Couple that with the fact that it's difficult bordering on impossible to correctly determine the culprit. If you've got 16 GB RAM and the user launches 3 processes each of which attempts to use 8 GB who should you kill?

Re: Stop making swap partitions—use swap files instead

#30
post #15

swap files make setting up hibernation a bit more complicated - in most cases the file has to be contiguous, e.g. you have to defragment it once after allocating. Then, you need to tell the bootloader the byte offset of the file on the partition.

If you want to share step-by-step, I’ll update the gist.
Post reply on HN