[SOLVED] Unable to resize disk size inside the VM (using LVM)

meepmeep

Renowned Member
Apr 14, 2013
51
8
73
Hi

I try to extend one of my VM (debian 8.5) disk size, but it fails every time.

Steps :
  • In proxmox hypervisor, select "resize disk", add 10Gb
  • Start and stop VM, parted shows the free space on the physical drive with "print free" (free space at the end)
Code:
(parted) print free
Model: Virtio Block Device (virtblk)
Disk /dev/vda: 19.3GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start    End      Size     Type      File system  Flags
        0.03MB   1.05MB   1.02MB             Free Space
1      1.05MB   256MB    255MB    primary   ext2         boot
        256MB    257MB    1.05MB             Free Space
2      257MB    10736MB  10479MB  extended
5      257MB    10736MB  10479MB  logical                lvm
        10736MB  19327MB  8591MB             Free Space
  • Resizepart of the extended and logical partition to the end size :
Code:
resizepart 2 19327
resizepart 5 19327
  • Partitions after :
Code:
Number  Start    End      Size     Type      File system  Flags
        0.03MB   1.05MB   1.02MB             Free Space
1      1.05MB   256MB    255MB    primary   ext2         boot
        256MB    257MB    1.05MB             Free Space
2      257MB    19327MB  19070MB  extended
5      257MB    19327MB  19070MB  logical                lvm
        19327MB  19327MB  0.35MB             Free Space
  • pvresize the physical volume
Before :
Code:
  PV Size               9.76 GiB / not usable 2.00 MiB

Code:
 $pvresize  --setphysicalvolumesize 19327M /dev/vda5
  WARNING: /dev/vda5: Overriding real size. You could lose data.
  Physical volume "/dev/vda5" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized

After
Code:
  PV Size               18.62 GiB / not usable 0
and
Code:
  VG Size               18.62 GiB
  • lvextend the logical volume
Code:
lvextend -l+100%FREE /dev/yolo-vg/root

... and it fails :

Code:
  Size of logical volume yolo-vg/root changed from 9.31 GiB (2383 extents) to 18.17 GiB (4652 extents).
  device-mapper: resume ioctl on  failed: Invalid argument
  Unable to resume yolo--vg-root (253:0)
  Problem reactivating root

VM is broken, unable to get a shell, I use a snapshot to revert to previous state :/

So, were am I wrong ?
 
Hi,

you forgot to resize the partition before you resize the pv.
 
Hi,

How could I resize the partition before the "physical" volume ?? (my logic : Physical -> Volume -> Logical -> Partition)
 
Don't use --setphysicalvolumesize when growing, it did tell you you could lose data. If you don't pass a size to it it'll figure out the correct size on its own, which is good especially if eg. your partitioning tool doesn't cause a reload of the table or uses different factors (1000 vs 1024). If it doesn't pick up the size on its own properly try running partprobe (or reboot...).
 
Ok, thank you !

Solution :

Code:
pvresize /dev/vda5
lvextend -l+100%FREE /dev/yolo-vg/root
resize2fs /dev/yolo-vg/root
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!