Skip to content

Instantly share code, notes, and snippets.

@NotYusta
Created February 8, 2024 08:02
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 none swap sw 0 0" "/swapfile"; then
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment