How to adjust swap size?

I want to resize the swap size to 8GiB.

sudo swapoff /var/swapfile
sudo dd if=/dev/zero of=/var/swapfile bs=1GiB count=8
sudo mkswap /var/swapfile
sudo chmod 0600 /var/swapfile
sudo swapon /var/swapfile
1 Like