Created
September 8, 2025 20:24
-
-
Save Juan-Severiano/2cc948f31cb07b15c3ccee4842e73dc4 to your computer and use it in GitHub Desktop.
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
| #!/bin/bash | |
| SIZE_OF_SWAP="$1" # 1G 2G | |
| echo "=== Alocando $SIZE_OF_SWAP no swapfile ===" | |
| sudo fallocate -l "$SIZE_OF_SWAP" /swapfile | |
| # Listar se foi realmente alocado | |
| ls -lh /swapfile | |
| echo "=== habilitando o swapfile para ser utilizado ===" | |
| sudo chmod 600 /swapfile | |
| ls -lh /swapfile | |
| echo "=== Marcando o arquivo como usable ===" | |
| sudo mkswap /swapfile | |
| echo "=== Permitindo que o sistema reconheca e utilize o arquivo! ===" | |
| sudo swapon /swapfile | |
| swapon --show | |
| sudo cp /etc/fstab /etc/fstab.bak | |
| echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment