Last active
June 19, 2023 17:09
-
-
Save SupaMic/f8c40818fb86f3c1bf9e532f949fffc5 to your computer and use it in GitHub Desktop.
Swap file setup on Rocky 9
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 | |
# Digital Ocean Source: https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-rocky-linux-9 | |
sudo fallocate -l 5G /swapfile | |
sudo chmod 600 /swapfile | |
sudo mkswap /swapfile | |
sudo swapon /swapfile | |
sudo swapon --show | |
sudo cp /etc/fstab /etc/fstab.bak | |
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab | |
sudo sysctl vm.swappiness=10 | |
sudo sysctl vm.vfs_cache_pressure=50 | |
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf | |
echo 'vm.vfs_cache_pressure=50' | sudo tee -a /etc/sysctl.conf | |
ls -lh /swapfile | |
free -h |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment