Resize a KVM LVM hardisk

c0mputerking

Active Member
Oct 5, 2011
174
5
38
I am trying to resize a kvm disk using proxmox 2.x used

Code:
lvextend -L +140G /dev/vg1/vm-110-disk-1
Extending logical volume vm-110-disk-1 to 150.00 GiB

and it worked as a lvs shows the newly resized disk, however when i try to use resize2fs i get error

Code:
vm-110-disk-1 vg1  -wi-ao 150.00g

Code:
resize2fs /dev/vg1/vm-110-disk-1
resize2fs 1.41.12 (17-May-2010)
resize2fs: Bad magic number in super-block while trying to open /dev/vg1/vm-110-disk-1
Couldn't find valid filesystem superblock.

Of course once inside VM 102 there is no extra space

Code:
root   u10043lts64base -wi-ao   9.29g

So i try to lvextend it to 150G to match the newly resized proxmox logical volume

Code:
lvextend -L +140G /dev/mapper/u10043lts64base-root
  Extending logical volume root to 149.29 GiB
  Insufficient free space: 35840 extents needed, but only 0 available
Next i try to resize the filesystem from within vm 110 im stumped please help
Code:
resize2fs /dev/mapper/u10043lts64base-root
resize2fs 1.41.11 (14-Mar-2010)
The filesystem is already 2436096 blocks long.  Nothing to do!

PS i made a similar post in someone elses thread link below as i have had this problem before. I really do think this topic deserves a new thread as there must be lots of time when resizing a KVM VM is important.

http://forum.proxmox.com/threads/7177-error-with-pve-cluster-and-pve-manager
 
I am trying to resize a kvm disk using proxmox 2.x used

Code:
lvextend -L +140G /dev/vg1/vm-110-disk-1
Extending logical volume vm-110-disk-1 to 150.00 GiB

and it worked as a lvs shows the newly resized disk, however when i try to use resize2fs i get error

Code:
vm-110-disk-1 vg1  -wi-ao 150.00g

Code:
resize2fs /dev/vg1/vm-110-disk-1
resize2fs 1.41.12 (17-May-2010)
resize2fs: Bad magic number in super-block while trying to open /dev/vg1/vm-110-disk-1
Couldn't find valid filesystem superblock.

Of course once inside VM 102 there is no extra space

Code:
root   u10043lts64base -wi-ao   9.29g

So i try to lvextend it to 150G to match the newly resized proxmox logical volume

Code:
lvextend -L +140G /dev/mapper/u10043lts64base-root
  Extending logical volume root to 149.29 GiB
  Insufficient free space: 35840 extents needed, but only 0 available
Next i try to resize the filesystem from within vm 110 im stumped please help
Code:
resize2fs /dev/mapper/u10043lts64base-root
resize2fs 1.41.11 (14-Mar-2010)
The filesystem is already 2436096 blocks long.  Nothing to do!

PS i made a similar post in someone elses thread link below as i have had this problem before. I really do think this topic deserves a new thread as there must be lots of time when resizing a KVM VM is important.

http://forum.proxmox.com/threads/7177-error-with-pve-cluster-and-pve-manager
Hi,
you resize the disk for an client. But you don't resize the partition-table of the disk - so resize2fs can't work!

You must stop and start the VM (so that the bios see the bigger disk). After that it's depends on your VM (used partition layout, filesystem). If your VM used also lvm, you can (all inside the VM!)
a) create a new partition on the new space and add them to the vg; after that expand the lv and do an resize2fs
b) expand your existing partition (perhaps after that a reboot of the VM is nessearry, because the kernel use the old partition-table (lvm)).

If you don't use lvm inside the VM you can also boot an live-cd like partition-magic to expand the partitions.

And have allways an valid backup!

Udo
 
You were right after a reboot the freespace shows up under fdisk -l and i am using lvm

Code:
Disk /dev/vda: 161.1 GB, 161065467904 bytes
16 heads, 63 sectors/track, 312084 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00081c52

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           3         496      248832   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2             498       20804    10233857    5  Extended
Partition 2 does not end on cylinder boundary.
/dev/vda5             498       20804    10233856   8e  Linux LVM

Maybe i am just being picky here i know you suggested i just create another patition and at that to my volume group, then extend the logical volume needed, and finally resize2fs to get make the new space avliable to the VM. Wow that is actually a bit compicated now that i have written it out but i think i could make it work.

However maybe i am just being picky but i do not really want another partition kicking around, but i cannot find a way to make the volume group extend into unallocates space. Is there a way i may have read something about merging but i am confused enough that i have to ask here.
 
I have read the PVE Wiki http://pve.proxmox.com/wiki/Resize_disks#Resizing_guest_disk, but still cannot seem to resize my partition, only add an new one which is fine, but does not seem as clean as expanding the existing one that seems be doable according to the Wike

cfdisk (util-linux 2.20.1)

Disk Drive: /dev/mapper/u12041lts64-root
Size: 8329887744 bytes, 8329 MB
Heads: 255 Sectors per Track: 63 Cylinders: 1012

Name Flags Part Type FS Type [Label] Size (MB)
------------------------------------------------------------------------------
Pri/Log Free Space 8329.89*











[ Help ] [ New ] [ Print ] [ Quit ] [ Units ]
[ Write ]
Cannot maximize this partition
Create new partition from free space
 

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!