Automation of space increase

XN-Matt

Well-Known Member
Aug 21, 2017
92
7
48
43
Looking through most recent threads on resizing, I can see wiki links on how to do this via commands within the VM but nothing specific outside of the VM.

We want to automate this so if an order comes in for an increase it can happen without user involvement or needing to get in to the VM itself.

Our images are set with one partition (/dev/vda1) making the process as easy as it can be.

Has anyone achieved this by stopping their VM, mounting the space on the hostnode doing the resize and then booting again?
 
Maybe one to be worked on. Hooks would be nice to be able to run at any point on the hostnode via the API? ;)

Code:
lvchange -ay /dev/vg-1/vm-xxx-disk-1
losetup -f (get next loop device)
losetup /dev/loop0 /dev/vg-1/vm-xxx-disk-1
kpartx -av /dev/loop0
parted /dev/loop0 resizepart 1 100% (resize first/only partition)
e2fsck -f /dev/mapper/loop0p1
resize2fs /dev/mapper/loop0p1
sync
kpartx -dv /dev/loop0
losetup -d /dev/loop0
lvchange -an /dev/vg-1/vm-xxx-disk-1

And then start again and all increased.
 
Last edited: