Last active
October 2, 2023 13:53
-
-
Save hoangdh/073b57532acd8b789b602a83a7646c17 to your computer and use it in GitHub Desktop.
Add swapfile on Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
fallocate -l 1G /swapfile; | |
chmod 600 /swapfile; mkswap /swapfile; | |
cp /etc/fstab /etc/fstab.bk; | |
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab; | |
swapon -a; | |
sysctl vm.swappiness=15; | |
sysctl vm.vfs_cache_pressure=50 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment