Linux – swap size be same or larger than RAM

linuxswap

Many say that, if you have a 2GB RAM, you should configure a 2GB or more swap. FWIK the hibernation may need the same size swap to persist memory when power off, but generally, if you got a big RAM, you even don't need swap at all, isn't it?

For Linux users, when you install Linux without swap, the installer will warn you that you didn't have swap mount. No I just don't need it because my RAM is just big enough, right?

Best Answer

The swap file is not simply a buffer to run into when you run out of physical RAM. That is an over-simplistic view of how the swap file operates. That said, you can operate without a swap file, as long as you're 100% confident that you'll never exceed your RAM's capacity, at any point in time. Because if you do, your system crashes.

IMO, better to keep the page file and also keep tabs on how often it's being used by the system. If you're never thrashing, it's not a problem, and if you are thrashing, you have an issue that'd probably be even more serious if you weren't running a page file at all.

It's true that we have more RAM now, and it's cheap. But that's also true of disk space. Unless you have a compelling disk space constraint, I'd recommend sticking with a decent size swap file.

If you feel things are being paged to disk too often, you can look at tweaking your swappiness to be less aggressive.