Skip to content

Instantly share code, notes, and snippets.

@SupaMic
Last active June 19, 2023 17:09
Show Gist options
  • Save SupaMic/f8c40818fb86f3c1bf9e532f949fffc5 to your computer and use it in GitHub Desktop.
Save SupaMic/f8c40818fb86f3c1bf9e532f949fffc5 to your computer and use it in GitHub Desktop.
Swap file setup on Rocky 9
#!/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