Search code examples
partitioninglvm

Resize lvm partition without shutting down VM


I resized a qcow2 image to a increase it's size, in the process I passed the wrong device to extend and now virt-filesystems displays:

[root@node3 35]# virt-filesystems --long --parts --blkdevs -h -a disk.0
Name       Type       MBR  Size  Parent
/dev/sda1  partition  83   243M  /dev/sda
/dev/sda2  partition  05   1.0K  /dev/sda
/dev/sda5  partition  8e   9.8G  /dev/sda
/dev/sda   device     -    40G   -

I want to resize /dev/sda5 to take all that 40G from /dev/sda but in the virtual machine fdisk, lv tools, parted don't show that space and I'm kinda lost.

Any help or guidance is appreciated.

Fdisk output:

root@ubuntu:~# fdisk -l

Disk /dev/vda: 42.9 GB, 42949672960 bytes
16 heads, 63 sectors/track, 83220 cylinders, total 83886080 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
Disk identifier: 0x000bd79d

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048      499711      248832   83  Linux
/dev/vda2          499712    83883647    41691968    5  Extended
/dev/vda5          499714    20967425    10233856   8e  Linux LVM

Disk /dev/mapper/ubuntu--vg-root: 9940 MB, 9940500480 bytes
255 heads, 63 sectors/track, 1208 cylinders, total 19415040 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
Disk identifier: 0x00000000

Disk /dev/mapper/ubuntu--vg-root doesn't contain a valid partition table

Disk /dev/mapper/ubuntu--vg-swap_1: 536 MB, 536870912 bytes
255 heads, 63 sectors/track, 65 cylinders, total 1048576 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
Disk identifier: 0x00000000

Disk /dev/mapper/ubuntu--vg-swap_1 doesn't contain a valid partition table

Solution

  • I ended up by creating a new partition /dev/vda6 which I added it to the LVM group.