News for hackers. Stuff that matters.
Re:Stop making swap partitions–use swap files instead by Kim_Bruning on Friday September 11, 2026 @04:16AM (#49655102)
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?

Re:Stop making swap partitions–use swap files instead by optionalsquid on Friday September 11, 2026 @05:26AM (#49655587)
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 by fc417fc802 on Friday September 11, 2026 @05:38AM (#49655687)
And since you should probably be running a modern CoW filesystem then you probably shouldn't be using swapfiles ... is the conclusion I arrived at anyway. Either install multiple times more RAM than you need and enable zswap or else set aside a swap partition as has always been done.
Re:Stop making swap partitions–use swap files instead by jenders on Friday September 11, 2026 @05:47AM (#49655798)
Truth be told—- I don’t use swap and set `vm.swappiness=0` but in these difficult times, swap may be the hero we need.
Re:Stop making swap partitions–use swap files instead by jeroenhd on Friday September 11, 2026 @04:10PM (#49664629)
Swapfiles on BTRFS seem to work great if you allocate them early (with the command linked in your article) and put them in a different subvolume than the rest of your system.

BTRFS in general seems more I/O constrained than ext4 or xfs so it's probably still worse to put a swapfile on a BTRFS partition, but so far my systems are doing fine.

Re:Stop making swap partitions–use swap files instead by cesarb on Saturday September 12, 2026 @12:18PM (#49673965)
> BTRFS in general seems more I/O constrained than ext4 or xfs so it's probably still worse to put a swapfile on a BTRFS partition,

AFAIK, on Linux swap bypasses the filesystem. It asks the filesystem for the extents which are used by the swapfile, and does the I/O directly on the block device. This explains the many restrictions swapfiles have on btrfs (the file can't be copy-on-write, can't be mirrored, etc), but it also means the speed for a swapfile will be the same on btrfs as on ext4 or xfs (assuming a similar layout, that is, the file is not too fragmented; IIRC, the kernel prints the number of extents when you do a swapon, so you can see when it's too fragmented).

Re:Stop making swap partitions–use swap files instead by jenders on Friday September 11, 2026 @05:36AM (#49655672)
That’s a good call out. I’ve never used ZFS on root. Been a ZFS user on Linux since the FUSE days but it has never seemed particular well suited (O_DIRECT support came late, ARC/page cache redundancy, etc). I can’t guarantee a consistent enough workload to optimize ZFS for and I don’t feel like it’s general purpose enough. Large object storage though? I’m sitting on a PB of ZFS.
Re:Stop making swap partitions–use swap files instead by jck86 on Friday September 11, 2026 @05:50AM (#49655816)
zswap indeed is the real magic almost silver bullet nowadays. Device backed swap is often not needed anymore and it solves a lot of the issues with freezing under memory pressure, though it may not be ideal for servers.

And if I have a separate otherwise unused ssd then using a swap partition simply is easier than creating a file system for it and mounting it somewhere. Block level backups also are easier.

What would be nice about swap files is if they could dynamically grow and shrink without a special setup.

Way too many variables on Linux for a one size fits all.

Re:Stop making swap partitions–use swap files instead by chuckadams on Friday September 11, 2026 @03:05PM (#49663660)
> Is it a rule that everything starting with a 'z' must be cool?

They tend to be the last word on the subject :)