Skip to content

Instantly share code, notes, and snippets.

@hoangdh
Last active October 2, 2023 13:53
Show Gist options
  • Save hoangdh/073b57532acd8b789b602a83a7646c17 to your computer and use it in GitHub Desktop.
Save hoangdh/073b57532acd8b789b602a83a7646c17 to your computer and use it in GitHub Desktop.
Add swapfile on Linux
#!/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