JackCuthbert
4/25/2017 - 1:45 AM

Add swap to Ubuntu 16.04

#!/bin/bash

# create
fallocate -l 1G /swapfile

# verify
ls -lh /swapfile

# perm should be -rw------- 
chmod 600 /swapfile

# create and enable
mkswap /swapfile
swapon /swapfile

# verify
swapon --show
free -h

# persist across reboot
cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab