Swap files vs. swap partitions —
It took far too long to find this half-remembered linux-kernel thread on Google amidst all the results (mostly from distro installer guides) claiming that swap partitions are preferable to swap files. Here’s hoping the link below will help future searchers.
Swap files and swap partitions have the same performance:
In 2.6 [swap files and swap partitions] have the same reliability and they will have the same performance unless the swapfile is badly fragmented.
— Andrew Morton, on linux-kernel.
(There is a performance difference under Linux 2.4, though, as explained at the link above.)
Update: Tim comments that swsusp (the kernel software suspend-to-disk support) only works with swap partitions, so there is still one good reason to use a swap partition. Suspend2 doesn’t have this limitation.
The swap partiotion still has one advantage:
You can easily use one for several Linux installations if you dual-boot.
According to this, the kernel’s suspend code (CONFIG_SOFTWARE_SUSPEND) doesn’t play nice with swap files — you need a swap partition for it.
I agree that swap files are better in 99% of cases these days. But I also want to power down my computer without closing all my work.
(The ideal solution, of course, is a kickin’ suspend feature for Linux that can work with a swap file, but that doesn’t appear to be a priority for the kernel guys.)
Thanks, Tim; I didn’t know that, and I’ve added an update to the post.
Splutter. I decided to see if porting swapfile support from suspend2 was plausible, and found this (unrelated) snippet in Documentation/power/swsusp.txt as advice for how to get your page cache sane after a resume:
cat `cat /proc/[0-9]*/maps | grep / | sed 's:.* /:/:' | sort -u` > /dev/null