Steps
Check Disk size if you have enough size
Check your existing swapfile size (in my case 9Gi)
Disable swapfile
Update to the required size (I will do to 10Gi)
Change swapfile permission
Setup Linux Area
Enable swapfile
Make it permanent
Verify
Check Disk size if you have enough size
Let's see the size of your swap file,I have 9Gi I will make it 10G
Disable swapfile, after disable your swapfile size would have become 0B
sudo swapoff /swapfile
Now Let's update it to 10Gi
sudo dd if=/dev/zero of=/swapfile bs=128M count=88
Here if you want 1GB your count value will be 8
Count Value | Swap file size (in Gi) |
8 | 1Gi |
16 | 2Gi |
Lets change the permission of the swapfile
sudo chmod 600 /swapfile
setup Linux swap area
sudo mkswap /swapfile
Enable the swapfile
sudo swapon /swapfile
Make it Permanent across reboots
Open file /etc/fstab in your favorite editor and write the below contents
/swapfile swap swap defaults 0 0
Verify the new size of your swapfile.