make-swapfile
This commit is contained in:
31
tools/make-swapfile.sh
Executable file
31
tools/make-swapfile.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
set -exo pipefail
|
||||
|
||||
# https://www.linode.com/docs/guides/how-to-increase-swap-space-in-ubuntu/
|
||||
# https://help.ubuntu.com/community/SwapFaq
|
||||
|
||||
sudo swapon --show
|
||||
free -h
|
||||
df -h
|
||||
|
||||
if [ -f /swapfile ]; then
|
||||
set +x
|
||||
echo "Already exists"
|
||||
exit 1
|
||||
fi;
|
||||
|
||||
sudo fallocate -l 1G /swapfile
|
||||
sudo chmod 600 /swapfile
|
||||
sudo mkswap /swapfile
|
||||
sudo swapon /swapfile
|
||||
|
||||
sudo swapon --show
|
||||
free -h
|
||||
df -h
|
||||
|
||||
sudo cp /etc/fstab /etc/fstab.bak
|
||||
echo "/swapfile swap swap defaults 0 0" | sudo tee -a /etc/fstab
|
||||
sudo sysctl vm.swappiness=50
|
||||
echo "vm.swappiness=50" | sudo tee -a /etc/fstab
|
||||
|
||||
sudo swapon --show
|
||||
Reference in New Issue
Block a user