Issue when increasing the swap space of a KVM guest

SYSTEM INFORMATION
OS type and version CentOS 7.9
Webmin version 1.990
Cloudmin version 9.6 Pro

I’ve encountered an issue when increasing the swap space of a KVM guest by resizing it using the Web interface. I changed it from 4GiB to 8GiB, but it failed (I stupidly didn’t note the error at the time, but it was related to swapon failing). Interestingly, Webmin Action Log didn’t record it either. The KVM guest is running RHEL 8.5.

I can see that the 4GiB partition exists, with the 8GiB device:

$ fdisk -l
Disk /dev/vda: 320 GiB, 343597383680 bytes, 671088640 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x4152b3b0

Device     Boot Start       End   Sectors  Size Id Type
/dev/vda1        2048 671088639 671086592  320G 83 Linux


Disk /dev/vdb: 4 GiB, 4294967296 bytes, 8388608 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00076e34

Device     Boot Start      End  Sectors Size Id Type
/dev/vdb1        2048 16775167 16773120   8G 83 Linux

/etc/fstab:

$ cat /etc/fstab 
/dev/vda1	/	ext3	rw,usrquota,seclabel,relatime,grpquota,quota	0	1
/dev/vdb1	swap	swap	defaults	0	0

swapon thinks there is no swap drive:

$ swapon --show

Perhaps the disk didn’t expand successfully, but swapoff did run?

instead of increasing swap increase the ram allocation. a properly running machine should not swap on a regular basis…especially requiring a swap increase.

It’s also a very expensive and usually unfeasiable way to manage memory contraints. I suppose in an ideal world I would have 128GiB of memory for each VPS :rofl:

@hescominsoon - do you have anything to actually help with my issue please?

this may or may not help.

1 Like

Thanks @stefan1959 - this is useful.

I imagine the action of expanding the swap drive will need to be tested further as I feel this could be a bug.

LOL, the drive wasn’t mounted :sweat_smile:

swapon --show
NAME      TYPE      SIZE USED PRIO
/dev/vdb1 partition   8G 524K   -2

Whoop!

So for some reason, Cloudmin successfully increased the size of the partition but didn’t remount.

I told you how to fix it. a properly c configured and running machine should not swap. if you are having to add swap you either have a misconfiguration or you simply…need…to…add…more…ram. Right now I have 50 plus domains on a server that is using a total of 7 gigs of ram. I do not have anything running except apache, PHP, mysqlk. I have everything else disabled. so if you have 4 gigs of ram and you are having to increase swap then for some reason you do not have enough ram.

How many domains and what features are you using?

Thanks for your input, but you didn’t help with my problem. I just needed to figure out how to get the swap partition back up and running.

If you’re really interested, this is a single domain - a busy WordPress website - server memory on the web server between 16 -24 GiB depending on traffic. When I increased the disk space on the server, I noticed that I hadn’t increased swap from 4GiB, and as it gives breathing space for spikes in traffic, considered this too low. So I increased it to 8 GiB, but this failed for some reason (refer to the solution if you’re interested in how I fixed it).

And if you’re interested in the bottleneck: it is the php-fpm processes that chew up the memory, size inflated by WordPress plugins. And regarding turning everything off, I’m running a distributed infrastructure, with mariadb, varnish, redis on separate servers, so likely even leaner than what you have set up.

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.