Skip to content

Instantly share code, notes, and snippets.

@Juan-Severiano
Created September 8, 2025 20:24
Show Gist options
  • Select an option

  • Save Juan-Severiano/2cc948f31cb07b15c3ccee4842e73dc4 to your computer and use it in GitHub Desktop.

Select an option

Save Juan-Severiano/2cc948f31cb07b15c3ccee4842e73dc4 to your computer and use it in GitHub Desktop.
#!/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