add compatibility with swapfile directory (for btrfs)

This commit is contained in:
PowerUser64 2022-05-11 03:37:23 -07:00
parent e89ae1a694
commit f511cc73ab
2 changed files with 19 additions and 6 deletions

View file

@ -2,8 +2,14 @@
# Makes a swapfile at /swapfile of a given size (ex: mkswp 4G)
sudo fallocate -l "$1" /swapfile &&
sudo chmod 600 /swapfile
sudo mkswap /swapfile &&
sudo swapon /swapfile
if [ -d /swap ]; then
SWAPFILE=/swap/swapfile
else
SWAPFILE=/swapfile
fi
sudo fallocate -l "$1" "$SWAPFILE" &&
sudo chmod 600 "$SWAPFILE"
sudo mkswap "$SWAPFILE" &&
sudo swapon "$SWAPFILE"

View file

@ -1,6 +1,13 @@
#!/bin/bash
# Deletes the swapfile created by mkswp()
sudo swapoff -v /swapfile
sudo rm /swapfile
if [ -d /swap ]; then
SWAPFILE=/swap/swapfile
else
SWAPFILE=/swapfile
fi
sudo swapoff -v "$SWAPFILE"
sudo rm "$SWAPFILE"