Removing Swap-Partition Debian

Hello together,

today I setup a new Debian-Server and I realizied that it has a SWAP partition by default:

grafik

Is it safe to remove the Swap-Partition? Probaly I have to reinstall Debian and choose the right options for it. Got plenty of RAM, like more than 3 GB per Node. Would the system crash when the RAM is full or what would be your advice.

Thanks and kind regards,

When you run out of ram, the out-of-memory killer will start killing processes based on each processes “oom score”. You can disable swap if you are fairly certain you’ll never run OOM.

However, what you might want to look into first is changing the “vm.swappiness” sysctl value to 0, which will minimize unnecessary swapping. You’ll still have swap if needed in an emergency, but it should cut down on swapping when you aren’t actually out of memory.

3 Likes

Thanks alot. I set the value to 0 in /etc/sysctl.conf:

grafik

Now I am wondering if the swap usage stays really at 0, so far it looks fine:

grafik

But it has to be observed in the next days and weeks.

This is very little. But not because node consumes a lot of ram. Node uses very little. But it creates a lot of files. You want free ram to fit metadata of all of them in cache. That cache resides in unused ram. If you don’t have unused ram — there is no cache, and all requests hit the HDD.

That’s how you reduce IO to disks, not by messing with swap. By the time swapping becomes a problem it’s already too late. It’s a wrong problem to be solving.

So far the swappiness looks fine and no data has flown in there with the value of 0.

Did you also adjust the vfs_cache_pressure? Currently it is at 100. Maybe lower it to 50 as well?

In a system running server processes it can happen that user interface processes get swapped out so that the server processes can run better or files can be cached better.
If that is affecting you, you can use swapoff
Messing with vm.swappiness is more an internet meme than anything useful but you might increase it if you had really fast swap and slow os drive

1 Like