sunetdrive/templates/scriptreceiver/makeswap.erb.sh
2023-02-14 12:07:43 +01:00

13 lines
296 B
Bash

#!/bin/bash
if ! [[ -f /swapfile ]]; then
gb=$(free --gibi| grep Mem: | awk '{print $2}')
fallocate -l "${gb}G" /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
if ! grep -E '^(#)?/swapfile' /etc/fstab; then
echo '/swapfile none swap sw 0 0' >> /etc/fstab
fi
fi