How to increase swap memory on Linux Mint
Recreate a bigger swap file on Linux Mint, verify it survives reboot, and tune swappiness for a 32GB desktop.
I upgraded my swap setup today on Linux Mint and documented the exact commands.
My goal was simple: move to a 16GB swap file and make the system less eager to swap on a 32GB RAM machine.
The Problem
On a dev workstation, memory pressure can show up when you have containers running and the browser open with too many tabs. When that happens, swap becomes your safety net, and having a “small enough” swap can turn into unnecessary swapping or even out-of-memory kills.
The Solution
I disabled the old swap, removed the file, created a new 16GB one, set permissions, initialized it, and turned it back on:
1
2
3
4
5
6
sudo swapoff /swapfile
sudo rm /swapfile
sudo fallocate -l 16G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
Then I verified:
1
2
swapon --show
free -h
swapon --show reported the real file size (16G). free -h showed 15Gi because of rounding, which is normal.
Also, after swapoff, pages that were in swap moved back into RAM. So seeing RAM usage change and swap usage drop to 0B is expected behavior.
Verify it persists after reboot
Since the file path is still /swapfile, usually no fstab edits are needed. I still check it:
1
grep swapfile /etc/fstab
Expected line:
1
/swapfile none swap sw 0 0
Optional: lower swappiness
My default value was 60:
1
cat /proc/sys/vm/swappiness
With 32GB RAM, I prefer 10 on a desktop/workstation so the kernel keeps app memory in RAM longer and swaps less aggressively.
Set it permanently:
1
2
echo "vm.swappiness=10" | sudo tee /etc/sysctl.d/99-swappiness.conf
sudo sysctl --system
Verify:
1
cat /proc/sys/vm/swappiness
You can also apply it immediately without reboot:
1
sudo sysctl vm.swappiness=10
Conclusion
The final setup is:
- 32GB RAM
- 16GB swap on NVMe
vm.swappiness=10
This gives me a good balance for development workloads, containers, and heavy browser sessions. The system stays responsive, and I still keep swap headroom for memory spikes.