Webmin: How to change the size of Swap?

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.


  • 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

  1. sudo swapoff /swapfile
  2. sudo fallocate -l 1G /swapfile
  3. ls -lh /swapfile
  4. sudo mkswap /swapfile
  5. sudo swapon /swapfile

Command Explanation

  1. Turns off/unmounts current swap
  2. Resizes swap file to 1G (or your desired size)
  3. Verifies the file size and permission. (Make sure permission is -rw——-)
  4. Marks this file as swap file. Without this command, system will use previous size
  5. Turns on swap file



One response to “Webmin: How to change the size of Swap?”

  1. Michel van Moorselaar Avatar
    Michel van Moorselaar


    Nice explanation. This works for Virtuamin 6.14

Leave a Reply

Your email address will not be published. Required fields are marked *