Change Swap size on a running linux machine

Make all swap off
sudo swapoff -a

Resize the swapfile
sudo dd if=/dev/zero of=/swapfile bs=1M count=1024

Make swapfile usable
sudo mkswap /swapfile

Make swapon again
sudo swapon /swapfile

Davide Andreazzini

Read more posts by this author.