How to resize LVM volumes on running machines¶
We describe here how to extend a volume on a running machine. Tested on a Juju controller (VM deployed by MAAS)
Link to the instructions used: https://www.rootusers.com/lvm-resize-how-to-increase-an-lvm-partition/
Procedure¶
Open virt-manager, select the VM
Add new hardware -> add storage
log onto the VM
fdisk -l -> identify the new device (e.g. /dev/vdb)
Initialize the device:
# fdisk /dev/vdb -> add new partition /dev/vdb1 (key sequence: n, return, return, return, w)
Add the device in the logical volume group:
# vgextend vgroot /dev/vdb1 # vgdisplay -> you should see some free space --- Volume group --- VG Name vgroot System ID ... VG Size 99.98 GiB PE Size 4.00 MiB Total PE 25596 Alloc PE / Size 12797 / 49.99 GiB Free PE / Size 12799 / 50.00 GiB # lvdisplay -> get LV path --- Logical volume --- LV Path /dev/vgroot/lvroot LV Name lvroot VG Name vgroot # lvextend -l +100%FREE /dev/vgroot/lvroot # resize2fs /dev/vgroot/lvroot
That’s all!