Honest question: why are we still defaulting to swap partitions in Linux distributions?

@karolherbst to answer the question with a question: what's the math for when swapfiles are effective? There seems to be a ratio of disk read and write speeds vs total RAM (or maybe total overcommit?) and disk latency.

Back in the day with only a few MB RAM, the higher relative disk speeds seemed to make the offset worthwhile. Maybe it's worth tuning in an age where RAM prices are through the roof.

@bakuninboys Well swap partitions kinda prevent a big swap, because nobody wants to waste 16GB on swap that they are barely using.

But if it's more dynamic, then the OS could allocate more swap if it wants to page out more things if they are never used.

And a file cache is often a better use of RAM than memory that's never used. So it could in theory even lower IO operations if more storage is made available as swap.

@karolherbst ah you're talking about swap partition vs swap file. Yeah I'm guessing the fs ops would be CPU bound so in the modern world you'd immediately make the trade.

I wonder if there is some specific handling for swap files needed by the fs. Eg: you update the swap file and the is driver just keeps the COW operation / journal in memory, defeating the purpose, or at least confounding the operation.