Add the "./createSwapStorage.sh" script.

This commit is contained in:
Lampros Smyrnaios 2023-04-28 20:55:58 +03:00
parent 7b7dd59b57
commit fcd80a8f3f
1 changed files with 25 additions and 0 deletions

25
createSwapStorage.sh Executable file
View File

@ -0,0 +1,25 @@
# This script adds swap in the System.
# Info found in: https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04
# Creating a Swap File with 2 Gb
sudo fallocate -l 2G /swapfile
ls -lh /swapfile
# Enabling the Swap File
sudo chmod 600 /swapfile
ls -lh /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
free -h
# Making the Swap File Permanent
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
# Adjusting the Swappiness Property
cat /proc/sys/vm/swappiness
sudo sysctl vm.swappiness=10 # Setting it closer to 0, makes the swaps more rare. (10 %)
echo "vm.swappiness=10" | sudo tee -a /etc/sysctl.conf # Append it to that file in order for the custom "swappiness" to be available on restart.