Last active
March 10, 2021 09:49
-
-
Save clivewalkden/925bfec817f5e7d98bd7f4af5820dcfa to your computer and use it in GitHub Desktop.
How to add swap to CentOS 7
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
# Check if we already have swap | |
swapon -s | |
# Second Check | |
free -m | |
# Check available space | |
df -h | |
# Generate the file (4GB) | |
sudo dd if=/dev/zero of=/swapfile count=4096 bs=1MiB | |
# Set correct permissions | |
sudo chmod 600 /swapfile | |
# Make it swap | |
sudo mkswap /swapfile | |
# Turn it on | |
sudo swapon /swapfile | |
# Test | |
swapon -s | |
free -m | |
# To Make Permanent | |
sudo nano /etc/fstab | |
# Add the following | |
/swapfile swap swap sw 0 0 | |
# Check Swappiness (default 30) | |
cat /proc/sys/vm/swappiness | |
# To change the level (10 on Mag2 Cluster) | |
sudo nano /etc/sysctl.conf | |
# Find the line | |
vm.swappiness = 10 | |
# Set for now | |
sudo sysctl vm.swappiness=10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment