-
-
Save alokraj68/c62b3eeaaf7b1be51c582494f5a18dd1 to your computer and use it in GitHub Desktop.
Add swap memory on Ubuntu
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
| #!/usr/bin/env bash | |
| # | |
| # USAGE: | |
| # sudo ./add_swap.sh 8G | |
| # | |
| # SOURCE: | |
| # https://linuxize.com/post/how-to-add-swap-space-on-ubuntu-18-04/ | |
| # | |
| fallocate -l $1 /swapfile | |
| chmod 600 /swapfile | |
| mkswap /swapfile | |
| swapon /swapfile | |
| echo "/swapfile swap swap defaults 0 0" >> /etc/fstab | |
| sysctl vm.swappiness=10 | |
| sysctl vm.vfs_cache_pressure=50 | |
| # print info | |
| swapon --show | |
| free -h | |
| # to run in linux | |
| ## With curl: | |
| #bash <(curl -sL https://gist.githubusercontent.com/alokraj68/c62b3eeaaf7b1be51c582494f5a18dd1/raw/d02785a02a7e7c74c46b22a4814061e63b754727/add_swap.sh) 8G | |
| # With wget: | |
| #bash <(wget -nv -O - https://gist.githubusercontent.com/alokraj68/c62b3eeaaf7b1be51c582494f5a18dd1/raw/d02785a02a7e7c74c46b22a4814061e63b754727/add_swap.sh) 8G |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment