uknowngithubuser
10/20/2018 - 5:33 PM

Create Swap #ubuntu #shell

Create Swap #ubuntu #shell

#  Remove language related ign from apt-get update

sudo echo -e "Acquire:Languages "none";" >> /etc/apt/apt.conf.d/00aptitude

# Swap File 

echo "Setting up Swap File"

# Step 0 - Disable the currect file from working

sudo swapoff -a

# Step 1 – Checking the System for Swap Information

sudo swapon --show
free -h

# Step 2 – Checking Available Space on the Hard Drive Partition

df -h

# Step 3 – Creating a Swap File

sudo fallocate -l 12G /swapfile
ls -lh /swapfile

# Step 4 – Enabling the Swap File

sudo chmod 600 /swapfile
ls -lh /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
free -h

# Step 5 – Making the Swap File Permanent

sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
cat /proc/sys/vm/swappiness


# Step 6 – Tuning your Swap Settings

cat /proc/sys/vm/swappiness
echo "if 60 do not commit any changes"
echo "for servers type command sudo sysctl vm.swappiness=10"

# Step 7 - Adjusting the Cache Pressure Setting

cat /proc/sys/vm/vfs_cache_pressure
sudo sysctl vm.vfs_cache_pressure=50

# Step 8 - Making Cache Pressure Setting Permanent

sudo echo -e "vm.swappiness=10" >> /etc/sysctl.conf