Stop making swap partitions–use swap files instead
9 points by jenders 3 days ago | 5 comments

dwedge 30 minutes ago
Interestingly I always use swapfiles and this page made me realise there can be a performance impact if the filesystem is old - the lkml link says as long as the swap file isn't fragmented there's no impact
reply
WalterGR 19 minutes ago
In practice, there’s a potentially tremendous impact if you’re using a spinning metal disk. Sectors at the beginning of the disk (which is at the outer edge) are read/written way faster than sectors at the end. File systems tend to prefer writing files at the beginning. If the file system has been used for ‘a long time’ then it’s either fragmented - or it’s been defragmented and the free space is at the slow end of the drive.

One nice thing about swap partitions is that they can be fixed in place even before OS installation.

(Of course, if you’re using swap enough for this to be a huge factor, you probably have bigger problems. But I haven’t done the math.)

reply
mdspan 3 days ago
Swap files are also much easier to set up than partitions if you're using full disk encryption.
reply
demomode 29 minutes ago
Swap files are very fragile if you are using hibernation. For FDE I prefer LVM-over-LUKS and a dedicate partition
reply
charcircuit 16 minutes ago
Linux distros that do use swap files do so statically. It doesn't handle dynamically growing and shrinking it like other operating systems.
reply
0xbadcafebee 9 minutes ago
[delayed]
reply