Bobcares

Resize swap file for single partition KVM templates

by | Oct 11, 2021

Wondering how to resize swap file for single partition KVM templates? We can help you.

As part of our Server Management Services, we assist our customers with several SolusVM queries.

Today, let us see how our techs go about this query.

 

How to resize swap file for single partition KVM templates?

Older versions of SolusVM require to set swap size in the template file. However, versions from 1.20.09 of SolusVM use a swap size set via the web interface.

In this article, our Support Techs discuss how we can increase the size of a swap file for the single partition template on the SolusVM Master node.

Suppose, we want to apply the changes for the templates on the slave nodes. In that case, we need to synchronize the template with the slave nodes.

Moving ahead, let us see the steps our Support Techs follow in order to resize.

1. Initially, we connect to the SolusVM Master server via SSH.

2. Then we create a temporary directory for the mount point:

mkdir /mnt_tmp

3. In here, we mount a single-partition template image.

For example, here we use Ubuntu 16 x64 single partition template:

# guestmount -a /home/solusvm/kvm/template/linux-ubuntu-16.04-x86_64-minimal-latest.gz -i –rw /mnt_tmp

4. first-boot.sh script in the directory, /mnt_tmp/root/scripts/:

ls -l /mnt_tmp/root/scripts/
total 4
-rwxr-xr-x 1 root root 697 May 4 16:49 first-boot.sh

5. We open this file in any text editor. In addition, we update the script, change the value for count option of the dd utility up to 1024MB:

vi /mnt_tmp/root/scripts/first-boot.sh

Before:

cat /mnt_tmp/root/scripts/first-boot.sh | grep dd
dd if=/dev/zero of=/swapfile bs=1024 count=262144 >> /var/log/first-boot.log 2>&1

After:

cat /mnt_tmp/root/scripts/first-boot.sh | grep dd
dd if=/dev/zero of=/swapfile bs=1024 count=1048576 >> /var/log/first-boot.log 2>&1

Here, the count parameter changed from 262144 to 1048576, it is set in Kilobytes

6. Eventually, we unmount the image:

fusermount -u /mnt_tmp/

7. However, make sure to synchronize the template with slave KVM nodes.

8. Once done, the swap file on the VPS created using this template will have 1024 MB.

[Stuck in between? We’d be happy to assist you]

 

Conclusion

In short, we saw how our Support Techs resize the swap file.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.