Skip to content

Instantly share code, notes, and snippets.

@sergioska
Created October 21, 2019 08:18
Show Gist options
  • Save sergioska/c02d5f5a1cb26bceb0c0a738fa3f631e to your computer and use it in GitHub Desktop.
Save sergioska/c02d5f5a1cb26bceb0c0a738fa3f631e to your computer and use it in GitHub Desktop.
Enable swap allocation
# swap space allocation
sudo fallocate -l 1G /var/swap.1
# or use following command that agnostic about distro
#sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo chmod 600 /var/swap.1
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1
# check if swap is up in the right way
sudo swapon --show
# (optionally) works to mount swap automatically with fstab on restart machine
sudo cp /etc/fstab /etc/fstab.bak
echo '/var/swap.1 none swap sw 0 0' | sudo tee -a /etc/fstab
sudo sysctl vm.swappiness=10
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
sudo sysctl vm.vfs_cache_pressure=50
echo 'vm.vfs_cache_pressure=50' | sudo tee -a /etc/sysctl.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment