Swapfile vs Swap partition vs no swap at all?

The obvious missing thing here is…how much memory do you have?

Generally speaking, between a swapfile and swap partition you are trading performance for flexibility. The swap partition is higher performing and the swapfile gives you more flexibility. Practically the performance difference in most desktop workloads is negligible so a swapfile is usually a better option. ZFS is an exception. You should never put swap in any form in a zpool due to this.

If we are limiting things to an SSD, I would always choose some swap over no swap. It is basically the choice between decreased performance and an OOM condition causing crashing. On an HDD, I would use no swap instead(or zram)

That being said, I think zram and/or zswap are better options than a straight swapfile.

2 Likes