Change swap file size in Virtualmin

Reading Time: 1 minute

If you follow to our Virtualmin Installation, the installation script set the Swap file size to 263M by default. If you wish to check your current swap file, run the “free -h”

[[email protected] ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:           992M        369M        426M        500K        195M        470M
Swap:          263M        120M        142M

To go about this, let us change the swap file size twice the size of your current RAM. In our situation, we have 1 GB of RAM. In my case, I will change the 2 GB.

Let us get this started!

swapoff -a
dd if=/dev/zero of=/swapfile count=2048 bs=1MiB

The 2048 is the MB size I wish to apply for my swap file. If you wish to change these to your desired MB size, feel free to do so.

mkswap /swapfile
swapon /swapfile

If you wish to check your change, run free -h again. This should return 2 GB of size. For example:

[[email protected] ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:           992M        496M        135M         19M        360M        320M
Swap:          2.0G        4.6M        2.0G

Was this post helpful?

Leave a Reply

Close Menu