News for hackers. Stuff that matters.
Re:Stop making swap partitions–use swap files instead by lproven on Friday September 11, 2026 @05:38PM (#49665738)
Couple 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. This means it's more space efficient and keeps down partitioning complexity.

* And of course there's hibernation, as others have mentioned.

Conclusion: no, bad advice, except for very simplistic scenarios.

Re:Stop making swap partitions–use swap files instead by zahlman on Friday September 11, 2026 @07:06PM (#49666639)
> 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 smallest storage devices you can get are enormous compared to the RAM they're trying to support. If the device is "separate" (from what, / ?) but still has other things on it, it's even less clear why this would matter for performance. 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.

> you can share a single swap partition between distros no problem

The file could go on whatever partition the distros can share. Maybe put it under /home or something. It's your system, the FHS is up to your own interpretation.

> And of course there's hibernation, as others have mentioned.

Why would that matter? You're expecting a file not to survive the low-power state?

Re:Stop making swap partitions–use swap files instead by dwattttt on Friday September 11, 2026 @07:48PM (#49666997)
GP is not presenting these as evidence for an approach, just notable facts that weren't initially obvious.
Re:Stop making swap partitions–use swap files instead by zahlman on Saturday September 12, 2026 @03:46PM (#49676462)
The comment concludes with "Conclusion: no, bad advice, except for very simplistic scenarios.", so I don't think I can agree with you on this. My point was that these facts don't (in my analysis) support the conclusion, and suggest a contradictory stance (in particular: planning in advance to dual-boot multiple separate distros, but not being willing to adjust the configuration after installation).
Re:Stop making swap partitions–use swap files instead by lproven on Saturday September 12, 2026 @05:15AM (#49670528)
I think you're wrong on every single point you make.

> 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 by zahlman on Saturday September 12, 2026 @03:42PM (#49676419)
> If you have a swap file created by the installer then you do not get to specify

Why should we care about what the installer does when it's trivial to change later? You said this is "bad advice, except for very simplistic scenarios" but people not in "very simplistic scenarios" are perfectly capable of running a few shell commands.

Aside from which, typical home users are in very simplistic scenarios. The Mint installer defaults to a single partition aside from what's required for booting, and a swapfile at /swapfile. And tons of Mint users are doing just fine with that. They are not realistically going to distro-hop because it won't realistically solve any problems for them.

Your overall argument seems to depend on accommodating some hypothetical power users who nevertheless want the installer to get it right for them. But in this case, why not petition the distro to improve the installer instead?

> This has been standard practice since the 1960s!

And? the point here is to identify a benefit of putting swap on a carefully chosen partition that cannot be realized by putting swap on a file at a carefully chosen path (since that choice also implicitly puts it on a specific partition).

> You can but suddenly permissions and ownership become issues.

I can't fathom why. I said /home, not ~.

> Point missed. ... Incorrect assumption. ... Have you read the other comments?

I consider this sort of commentary incivil (and the commenting guidelines support me in this).

I also did not make an assumption at all; I considered one of two alternative meanings without introducing it with the word "if". That's why the second possibility does start with "if". This is just a rhetorical technique, dismissing the most absurd interpretations first exactly because they are easier to dismiss.

Re:Stop making swap partitions–use swap files instead by lproven on Monday September 14, 2026 @09:02AM (#49696149)
Again, no, on all points.

And you find my response "uncivil" but I find yours very much so as well. You won't even entertain my use cases, and my own direct personal experience, but your bad advice that would have repeatedly lost me all the data in my home directory on my work PC if I used your methods, for you trumps my 38 years of Unix experience.

No. You are being dogmatic, inconsiderate, not listening, responding with ridiculous strawman arguments ("keep swap in your home directory" as a response to "duplicate swap files waste space" -- that is ridiculous) and mockery.

You are rude, and you are arrogant, and you are wrong.

Re:Stop making swap partitions–use swap files instead by zahlman on Monday September 14, 2026 @11:14PM (#49707281)
> No. You are being dogmatic, inconsiderate, not listening, responding with ridiculous strawman arguments ("keep swap in your home directory" as a response to "duplicate swap files waste space" -- that is ridiculous) and mockery.

I am not being any more dogmatic or inconsiderate than you. I have listened to you quite carefully, and explained in good faith why I think you are wrong based on my best effort to understand you. But you have still not, as far as I can understand, identified a benefit of putting swap on a carefully chosen partition that cannot be realized by putting swap on a file at a carefully chosen path (since that choice also implicitly puts it on a specific partition).

In particular, you are the one who proposed that using swap files would require duplication, and I explained why I disagree. You claimed vaguely that there would be permission issues; when I expressed confusion, you did not elaborate. You have yet to give any concrete reason why there would be duplicate swap files, therefore the fact that duplication wastes space is moot.

My assumption was that you would be sharing /home between the two installations, because there is really nothing preventing you from doing that, and because making two separate /home partitions wastes much more space (because you don't know ahead of time how much space you'll use with each). Unless perhaps you do some bind-mounting trick that I would consider much trickier than setting up a swapfile at a custom path. (/home is owned by root, so there should not be any permission issue with a swapfile at /home/swapfile . If you disagree then you should explain why instead of being vague and dismissive.)

Nothing I said could reasonably be considered "mockery" in any way, shape or form. You are the one engaging in "mockery", by describing my proposal as "ridiculous" in italics without giving any reason as to why it wouldn't work.

Re:Stop making swap partitions–use swap files instead by lotharcable on Saturday September 12, 2026 @02:00AM (#49669335)
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 special use case were root partition can't be shared with root then on most desktop setups having a single large partition is the most straightforward way to do things.

Hibernation isn't really something really useful anymore. If people really really want it then I don't see why they shouldn't get it... but I really don't see the point.

Re:Stop making swap partitions–use swap files instead by lproven on Saturday September 12, 2026 @05:25AM (#49670585)
I disagree on every single point.

> There are lots of very good reasons why running small root partitions on Linux desktops is a very bad idea.

Go on then: name them.

I give root about 2x the space I expect it to take when fully populated. 4x if it's a very big disk. The rest is for me, not the OS.

> The smart money is on a single large partition for home and root and everything else.

With all due respect and deference:

Drivel. Absolute piffle. This is in fact the reverse of the truth.

Maybe you are young and inexperienced but I have bad news for you: OSes crash sometimes.

When (not if) they crash, volumes that they they have open files on tend to get corrupted. This is an especially key problem with some filesystems such as Btrfs that do not have working repair tools.

You should always keep your own data on a separate partition at least, and ideally, a separate physical drive. It will have less wear and that makes SSDs last longer.

In the last decade, keeping my OS on a different volume from my data in `/home` has saved my work at least 5-10 times. I work in the Linux industry. I work with testing OSes. But even on stable OSes, I've seen them crash far more than I'd like. Sadly, in my extensive personal experience, Btrfs is notably unstable and unreliable, and it fails frequently in normal routine operation, especially on snapshotting OSes such as openSUSE.

Always keep `/home` somewhere else, on a different disk format, for safety. XFS is good, but difficult to resize or repair. Plain old ext4 is very good in terms of repair tools.

> This way you get 100% disk availability

Until it fails

> with zero extra effort

Extra effort in setup is FAR preferable to extra effort in data recovery later.

> and you get maximum performance.

The opposite of the truth.

Swap on a different physical drive is faster.

Spread the load across multiple media for performance. That is how server OSes do it, because it is faster.

Any decent NAS OS will compel you to install the OS on different physical media from the data volumes for this specific reason.

You literally could not be more wrong.

> Unless you have some sort of special use case were root partition can't be shared with root then on most desktop setups having a single large partition is the most straightforward way to do things.

Easiest does not mean best. Best is usually not simplest or easiest.

Wrong again.

> Hibernation isn't really something really useful anymore.

Absolute nonsense. Your own experience does not mean universal experience.

Re:Stop making swap partitions–use swap files instead by akerl_ on Saturday September 12, 2026 @07:43AM (#49671331)
You’ve tainted your otherwise interesting comment pretty intensely by mixing in this level of condescension and hostility.
Re:Stop making swap partitions–use swap files instead by NBJack on Saturday September 12, 2026 @10:24AM (#49672626)
I, uh, would be more careful of making that statement given our public comment history. I know I can't cast any stones here.

More than interesting though, I will vouch for many of the points they presented in practice. Spreading partitions and taking advantage of the flexibility of Linux with how and where they are mounted has been a part of best practices for decades now. Many cloud-based solutions for Linux workstations I've used take full advantage of this for easier management of space (i.e. volume expansion) as well as security considerations, to say nothing of keeping your /var/log separate to avoid running out of space because you turned on verbose mode for something.

Re:Stop making swap partitions–use swap files instead by akerl_ on Saturday September 12, 2026 @10:39AM (#49672781)
I’m not sure what you’re trying to say.

I deserve to be called out just the same if I’m wrapping good points with “Drivel. Absolute piffle.” and “Maybe you are young and inexperienced”.

Re:Stop making swap partitions–use swap files instead by lproven on Tuesday September 22, 2026 @07:57AM (#49799832)
I'm sorry. I reacted badly. Both you and @zahlman gave the same advice with the same reasoning and I have extensive personal experience that means I know this can cause total data loss.

It is bad and dangerous advice.

If you don't believe me, I can give you the steps to reproduce. Others have posted comments to this effect here:

https://news.ycombinator.com/item?id=49768833

Seeing it twice in one thread, I overreacted.

Re:Stop making swap partitions–use swap files instead by lproven on Tuesday September 22, 2026 @07:54AM (#49799807)
I apologise for my confrontational tone.

I reacted badly when I see people giving what is, in my extensive personal experience, bad and dangerous advice that will lead to significant data loss.

It's as if I saw someone advising DIY facial piercing with a nailgun. I didn't stop to consider any motivation; my reaction is an immediate NO DON'T DO THAT!

Re:Stop making swap partitions–use swap files instead by Delk on Saturday September 12, 2026 @01:19PM (#49674664)
> In the last decade, keeping my OS on a different volume from my data in `/home` has saved my work at least 5-10 times.

Mine is of course just another anecdote, but despite seeing some crashes or hangs over the years, I can't remember the last time I've even had to manually fsck my ext4 filesystems, and I'm honestly not sure I've ever seen any unrecoverable corruption on ext4 or ext3. (I'm not saying it doesn't happen, as it certainly can, but I wouldn't think it's that common unless you're operating on a fairly large scale. And before journaling filesystems, crashes were of course a whole different deal.)

I used to keep /home separate on my personal devices (and maybe some other partitions as well because it was "a good practice"), but for more than a decade now my personal devices have had everything on a single large root fs, save for /boot and swap.

I've stuck with rather conservative fs choices and haven't used btrfs much, so I don't know if the story is different there.

What you gain with a single large root partition is of course that you don't need to know in advance how much software you'll want to install under /usr or how much space you'll need for /home or /var.

Multiple partitions can certainly be a good idea from a system management point of view, for cases where people either want to actively manage the system, or when their needs are demanding enough that it's warranted. If I were deploying a server for any kind of real use, yeah, the database or the server logs would certainly not be on the root volume.

But in case of desktops or laptops, most people, even engineers, don't really want to be meticulously managing their personal computers. Nor are most people's personal computing needs that demanding. The convenience of not running out of space on a single partition because you guessed the your future needs wrong wins over.

> Swap on a different physical drive is faster.

> Spread the load across multiple media for performance. That is how server OSes do it, because it is faster.

Of course it is, but in contrast, laptops don't really tend to have separate physical drives on which to put swap. I doubt most people would care enough about swap performance to install a separate high-performance drive for it even in desktops.

With that said, I also do keep a swap partition even on personal computers, and hibernation can be useful. (I think there are some issues with hibernation and encrypted swap in Linux, though, so I haven't bothered with it in a while).

Re:Stop making swap partitions–use swap files instead by efaref on Saturday September 12, 2026 @06:34AM (#49670946)
It also clouds disk usage stats, as a big chunk of your root device is taken up by the swap file. I'd rather look at `df /` and see the size of my OS installation without anything else.

Partition resizing is not exactly difficult, and I can count the number of times I've ever actually had to resize a swap partition in the last 30 years on the fingers of one foot.