On one of my servers I needed extra swap space because the datacenter screwed up the partitioning and I didn’t have time to reimage the machine. so an easy way to add swap after partitioning is just to add it via a new file on any partition.
lets say you want to add 8GB of swap in a file called swapfile based in /
# generate empty swap file sudo dd if=/dev/zero of=/swapfile bs=1024 count=8192k # make the file into swap ready file sudo mkswap /swapfile # enable swap on said file so the OS / kernel knows about it sudo swapon /swapfile #list enabled swap swapon -s
This will last till a reboot, so you need to add it to /etc/fstab. type :
sudo nano /etc/fstab
add at the bottom :
/swapfile none swap sw 0 0
and you are done 🙂