Even after searching on internet, I could not find a way to change the Swap size. Various online tutorials only showed us how to create swap space but did not explicitly address how to change the size of swap space using Webmin. Of course, this tutorial does not use Webmin but instead it uses commands against the server.
Prerequisites/Assumptions
- Swap space already exists
- /swapfile is the file created for swap space
- I am changing the /swapfile from 270MB to 1GB
Commands to Resize Swap Space
- sudo swapoff /swapfile
- sudo fallocate -l 1G /swapfile
- ls -lh /swapfile
- sudo mkswap /swapfile
- sudo swapon /swapfile
Command Explanation
- Turns off/unmounts current swap
- Resizes swap file to 1G (or your desired size)
- Verifies the file size and permission. (Make sure permission is -rw——-)
- Marks this file as swap file. Without this command, system will use previous size
- Turns on swap file
Leave a Reply