I’m in a situation where I can increase the SWAP of the Ubuntu Server 22.04 OS Virtual Machine:
sudo swapoff -a
sudo rm -f /swapfile
sudo dd if=/dev/zero of=/swapfile bs=1024 count=32M
sudo swapon -s
sudo chown root:root /swapfile && sudo chmod 0600 /swapfile
sudo mkswap /swapfile && sudo swapon /swapfile
Once everything is done I can see the new SWAP, but when I restart the Ubuntu VM the new SWAP dissapear and go back to the original 8G SWAP.
Just for test, if I apply the above codes in the workstation the SWAP change succefully and after reboot is still there.
Do you have any suggestion?