Question
How to change swap size on Ubuntu 14.04 ?
Now, I am using ubuntu 14.04 with 512 RAM and Swap 512 too. I want to change my swap to 1 GB. Can anyone help me ? Should I repeat this step on this article with different size ?
https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×
No, you don’t have to repeat these step if you already have swapfile in root directory.
Check swapfile
cd /
ls -a
Just follow these steps:
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
Worked with me I increased my swap size from 1.5 GB to 7 GB. But when I restarted my computer it came back to 1.5 GB, I don’t know why? could you please help.