Skip to content

Instantly share code, notes, and snippets.

@NotYusta
Last active August 7, 2024 08:40
Show Gist options
  • Save NotYusta/bc86b388b0661604bbab70a987c88bd2 to your computer and use it in GitHub Desktop.
Save NotYusta/bc86b388b0661604bbab70a987c88bd2 to your computer and use it in GitHub Desktop.
Swapfile installation script (1G) - Enterprise Linux
#!/bin/sh
dnf update -y
dnf install grep -y
fallocate -l 1G /swapfile
chmod 600 /swapfile
mkswap /swapfile
cp -rv /etc/fstab /etc/fstab.bak
if ! grep -q "/swapfile /swapfile swap sw 0 0" "/swapfile"; then
echo '/swapfile /swapfile swap sw 0 0' | sudo tee -a /etc/fstab
swapon /swapfile
echo "Activated swap"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment