Webmin: How to change the size of Swap?

By | January 6, 2020 | 0 Comment

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. Ofcourse, this tutorial does not use Webmin but instead it uses commands against the server.

Prerequiresites/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

  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

About Vishal Monpara

Vishal Monpara is a full stack Solution Developer/Architect with 13 years of experience primarily using Microsoft stack. He is currently working in Retail industry and moving 1's and 0's from geographically dispersed hard disks to geographically dispersed user leveraging geographically dispersed team members.