public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* expanding virtual disk based on lvm
@ 2012-08-28 20:26 Ross Boylan
  2012-08-28 21:15 ` Freddie Cash
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Ross Boylan @ 2012-08-28 20:26 UTC (permalink / raw)
  To: kvm; +Cc: ross

My vm launches with -hda /dev/turtle/VD0 -hdb /dev/turtle/VD1, where VD0
and VD1 are lvm logical volumes.  I used lvextend to expand them, but
the VM, started after the expansion, does not seem to see the extra
space.

What do I need to so that the space will be recognized?

The net has references to qemu-resize and virt-resize, but I don't seem
to have them.  The host system is on QEMU emulator version 0.13.0
(qemu-kvm-0.13.0), Copyright (c) 2003-2008 Fabrice Bellard from the
Debian   I'm on lenny (it's the upgrade I'm testing).

The other problem is that everything on the net refers to files that are
disk images; I'm not sure if the same procedures apply when a logical
volume is the underlying device.

The virtual disks each have 3 partitions.  Inside the VM software raid
produces dm0 from the 2 first partitions and dm1 from the 2 third
partitions.

Thanks for any help.
Ross Boylan


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: expanding virtual disk based on lvm
  2012-08-28 20:26 expanding virtual disk based on lvm Ross Boylan
@ 2012-08-28 21:15 ` Freddie Cash
  2012-08-28 21:33   ` Ross Boylan
  2012-08-28 21:33 ` Matthew Patton
  2012-09-04 12:53 ` Avi Kivity
  2 siblings, 1 reply; 9+ messages in thread
From: Freddie Cash @ 2012-08-28 21:15 UTC (permalink / raw)
  To: Ross Boylan; +Cc: kvm

On Tue, Aug 28, 2012 at 1:26 PM, Ross Boylan <ross@biostat.ucsf.edu> wrote:
> My vm launches with -hda /dev/turtle/VD0 -hdb /dev/turtle/VD1, where VD0
> and VD1 are lvm logical volumes.  I used lvextend to expand them, but
> the VM, started after the expansion, does not seem to see the extra
> space.

You've increased the size of the hard drive, but you haven't changed
the filesystem on top of the hard drive to use that extra space.

How you do that depends on whether the virtual disks are partitioned
with filesystems in the partitions; or formatted with a filesystem
directly.

If they are partitioned, then you need to boot off a LiveCD, extend
the partition, then extend the filesystem in the partition.

If they are formatted directly, then (depending on the filesystem) you
can grow the filesystem.  Some filesystems can't be extended live, so
you have to boot to a LiveCD.

No fancy VM-related tools required.  Just think in terms of real,
physical hardware, and it all becomes clear.  :)
-- 
Freddie Cash
fjwcash@gmail.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: expanding virtual disk based on lvm
  2012-08-28 20:26 expanding virtual disk based on lvm Ross Boylan
  2012-08-28 21:15 ` Freddie Cash
@ 2012-08-28 21:33 ` Matthew Patton
  2012-08-28 21:40   ` Freddie Cash
  2012-09-04 12:53 ` Avi Kivity
  2 siblings, 1 reply; 9+ messages in thread
From: Matthew Patton @ 2012-08-28 21:33 UTC (permalink / raw)
  To: kvm, Ross Boylan

On Tue, 28 Aug 2012 16:26:38 -0400, Ross Boylan <ross@biostat.ucsf.edu>  
wrote:

> What do I need to so that the space will be recognized?

your partition table for hd{a,b} within the guest is also now wrong. the  
"correct" way to add more space is to add another disk and then use LVM  
inside the guest to add space to filesystems.

> The other problem is that everything on the net refers to files that are
> disk images; I'm not sure if the same procedures apply when a logical
> volume is the underlying device.

Semantically there is no difference. The guest's view of the disks is  
going to be wrong no matter if the source is a file or LVM item.

-- 
Cloud Services Architect, Senior System Administrator
InfoRelay Online Systems (www.inforelay.com)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: expanding virtual disk based on lvm
  2012-08-28 21:15 ` Freddie Cash
@ 2012-08-28 21:33   ` Ross Boylan
  0 siblings, 0 replies; 9+ messages in thread
From: Ross Boylan @ 2012-08-28 21:33 UTC (permalink / raw)
  To: Freddie Cash; +Cc: ross, kvm

On Tue, 2012-08-28 at 14:15 -0700, Freddie Cash wrote:
> On Tue, Aug 28, 2012 at 1:26 PM, Ross Boylan <ross@biostat.ucsf.edu> wrote:
> > My vm launches with -hda /dev/turtle/VD0 -hdb /dev/turtle/VD1, where VD0
> > and VD1 are lvm logical volumes.  I used lvextend to expand them, but
> > the VM, started after the expansion, does not seem to see the extra
> > space.
> 
> You've increased the size of the hard drive, but you haven't changed
> the filesystem on top of the hard drive to use that extra space.
> 
> How you do that depends on whether the virtual disks are partitioned
> with filesystems in the partitions; or formatted with a filesystem
> directly.
The virtual disks are partitioned.
> 
> If they are partitioned, then you need to boot off a LiveCD, extend
> the partition, then extend the filesystem in the partition.
So I edit the parition table  directly?  I thought there might be some
meta-information that kvm used to establish the size of the physical
disk.

I'm not sure what the final sector number should be; I could get it
approximately from the size, but I'm not sure my calculation would be
just right.
> 
> If they are formatted directly, then (depending on the filesystem) you
> can grow the filesystem.  Some filesystems can't be extended live, so
> you have to boot to a LiveCD.
> 
> No fancy VM-related tools required.  Just think in terms of real,
> physical hardware, and it all becomes clear.  :)
My real physical disks have never grown spontaneously. :)  I also wasn't
sure how the kernel would react, and so I shut it down during the
growth.

Ross


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: expanding virtual disk based on lvm
  2012-08-28 21:33 ` Matthew Patton
@ 2012-08-28 21:40   ` Freddie Cash
  0 siblings, 0 replies; 9+ messages in thread
From: Freddie Cash @ 2012-08-28 21:40 UTC (permalink / raw)
  To: Matthew Patton; +Cc: kvm, Ross Boylan

On Tue, Aug 28, 2012 at 2:33 PM, Matthew Patton <mpatton@inforelay.com> wrote:
> On Tue, 28 Aug 2012 16:26:38 -0400, Ross Boylan <ross@biostat.ucsf.edu>
> wrote:
>
>> What do I need to so that the space will be recognized?
>
> your partition table for hd{a,b} within the guest is also now wrong. the
> "correct" way to add more space is to add another disk and then use LVM
> inside the guest to add space to filesystems.

For "incorrect" definitions of "correct".  :)  Or, at least,
convoluted definitions.  Now you have a filesystem on top of guest-LVM
on top of multiple virtual disks on top of host-LVM on top of multiple
disks.  Instead of just filesystem on virtual disk on LVM on physical
disk(s).

The following has worked for us since the KVM-60-something days:
  Stop the VM.
  Expand the LVM LV used by the VM (on the host side).
  Boot the VM to a LiveCD.
  Modify partition table to use all the extra space in the virtual disk.
  Grow the filesystem to use all the extra space (we only use XFS with
ext3 for /boot, so they expand nicely).
  Boot the VM.
  Enjoy all the extra space.

And, for our Xen boxes that use LVM LV directly (no partition table),
it's possible to do the expansion "live" with only a single reboot to
pick up the larger disk size:
  Expand the LVM LV used by the VM (on the host side).
  Reboot to get the larger disk size.
  Expand the filesystem live or via single-user mode boot (again, XFS
works wonderfully)

-- 
Freddie Cash
fjwcash@gmail.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: expanding virtual disk based on lvm
  2012-08-28 20:26 expanding virtual disk based on lvm Ross Boylan
  2012-08-28 21:15 ` Freddie Cash
  2012-08-28 21:33 ` Matthew Patton
@ 2012-09-04 12:53 ` Avi Kivity
  2012-09-04 18:58   ` Ross Boylan
  2 siblings, 1 reply; 9+ messages in thread
From: Avi Kivity @ 2012-09-04 12:53 UTC (permalink / raw)
  To: Ross Boylan; +Cc: kvm

On 08/28/2012 11:26 PM, Ross Boylan wrote:
> My vm launches with -hda /dev/turtle/VD0 -hdb /dev/turtle/VD1, where VD0
> and VD1 are lvm logical volumes.  I used lvextend to expand them, but
> the VM, started after the expansion, does not seem to see the extra
> space.
> 
> What do I need to so that the space will be recognized?

IDE (-hda) does not support rechecking the size.  Try booting with
virtio-blk.  Additionally, you may need to request the guest to rescan
the drive (no idea how to do that).  Nor am I sure whether qemu will
emulate the request correctly.


-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: expanding virtual disk based on lvm
  2012-09-04 12:53 ` Avi Kivity
@ 2012-09-04 18:58   ` Ross Boylan
  2012-09-05  7:25     ` Avi Kivity
  0 siblings, 1 reply; 9+ messages in thread
From: Ross Boylan @ 2012-09-04 18:58 UTC (permalink / raw)
  To: Avi Kivity; +Cc: ross, kvm

On Tue, 2012-09-04 at 15:53 +0300, Avi Kivity wrote:
> On 08/28/2012 11:26 PM, Ross Boylan wrote:
> > My vm launches with -hda /dev/turtle/VD0 -hdb /dev/turtle/VD1, where VD0
> > and VD1 are lvm logical volumes.  I used lvextend to expand them, but
> > the VM, started after the expansion, does not seem to see the extra
> > space.
> > 
> > What do I need to so that the space will be recognized?
> 
> IDE (-hda) does not support rechecking the size.  Try booting with
> virtio-blk.  Additionally, you may need to request the guest to rescan
> the drive (no idea how to do that).  Nor am I sure whether qemu will
> emulate the request correctly.
> 
Thank you for the suggestion.

I think the "physical" recognition of the new virtual disk size was
accomplished when I restarted the VM, without any other steps.  I've had
plenty of other problems, but I think at the VM level things are good.

I needed to manually resize the last partition with fdisk.  None of the
other tools (cfdisk, parted, gparted) would manipulate the partition
table, for reasons that became apparent.

The resized partitions were in an mdadm RAID1 array.  When I expanded
them it meant the raid superblock was no longer found (theory), and the
RAID could not be reassembled (fact).  I've attempted to fix that by
recreating the array, but mdadm is refusing to use the UUID I specify,
instead modifying it with the localhost name.  The virtual disks are for
a Debian lenny VM, but the only other spare VM around was squeeze, and
mdadm in squeeze does the localhost rewriting.

By the way, it's really great to have a VM's as a testing area in which
I can discover these problems without trashing my real system.  Thanks
to everyone who made it possible.

Ross Boylan


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: expanding virtual disk based on lvm
  2012-09-04 18:58   ` Ross Boylan
@ 2012-09-05  7:25     ` Avi Kivity
  2012-09-05  9:15       ` Alexandre DERUMIER
  0 siblings, 1 reply; 9+ messages in thread
From: Avi Kivity @ 2012-09-05  7:25 UTC (permalink / raw)
  To: Ross Boylan; +Cc: kvm

On 09/04/2012 09:58 PM, Ross Boylan wrote:
> On Tue, 2012-09-04 at 15:53 +0300, Avi Kivity wrote:
>> On 08/28/2012 11:26 PM, Ross Boylan wrote:
>> > My vm launches with -hda /dev/turtle/VD0 -hdb /dev/turtle/VD1, where VD0
>> > and VD1 are lvm logical volumes.  I used lvextend to expand them, but
>> > the VM, started after the expansion, does not seem to see the extra
>> > space.
>> > 
>> > What do I need to so that the space will be recognized?
>> 
>> IDE (-hda) does not support rechecking the size.  Try booting with
>> virtio-blk.  Additionally, you may need to request the guest to rescan
>> the drive (no idea how to do that).  Nor am I sure whether qemu will
>> emulate the request correctly.
>> 
> Thank you for the suggestion.
> 
> I think the "physical" recognition of the new virtual disk size was
> accomplished when I restarted the VM, without any other steps.  I've had
> plenty of other problems, but I think at the VM level things are good.

Certainly restart (shutting down qemu and restarting it, not a reset)
works, I thought you wanted online resize.



-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: expanding virtual disk based on lvm
  2012-09-05  7:25     ` Avi Kivity
@ 2012-09-05  9:15       ` Alexandre DERUMIER
  0 siblings, 0 replies; 9+ messages in thread
From: Alexandre DERUMIER @ 2012-09-05  9:15 UTC (permalink / raw)
  To: Ross Boylan; +Cc: kvm, Avi Kivity


>>Certainly restart (shutting down qemu and restarting it, not a reset) 
>>works, I thought you wanted online resize. 

You can resize an lvm volume online without restarting the guest.


just use lvextend to extend you lvm volume

then use qmp block_resize command with the same size. (so the guest will see the new size)



I have implemented this in the proxmox kvm distribution, and it's working fine.

(tested with virtio-blk and virtio-scsi)



----- Mail original ----- 

De: "Avi Kivity" <avi@redhat.com> 
À: "Ross Boylan" <ross@biostat.ucsf.edu> 
Cc: kvm@vger.kernel.org 
Envoyé: Mercredi 5 Septembre 2012 09:25:26 
Objet: Re: expanding virtual disk based on lvm 

On 09/04/2012 09:58 PM, Ross Boylan wrote: 
> On Tue, 2012-09-04 at 15:53 +0300, Avi Kivity wrote: 
>> On 08/28/2012 11:26 PM, Ross Boylan wrote: 
>> > My vm launches with -hda /dev/turtle/VD0 -hdb /dev/turtle/VD1, where VD0 
>> > and VD1 are lvm logical volumes. I used lvextend to expand them, but 
>> > the VM, started after the expansion, does not seem to see the extra 
>> > space. 
>> > 
>> > What do I need to so that the space will be recognized? 
>> 
>> IDE (-hda) does not support rechecking the size. Try booting with 
>> virtio-blk. Additionally, you may need to request the guest to rescan 
>> the drive (no idea how to do that). Nor am I sure whether qemu will 
>> emulate the request correctly. 
>> 
> Thank you for the suggestion. 
> 
> I think the "physical" recognition of the new virtual disk size was 
> accomplished when I restarted the VM, without any other steps. I've had 
> plenty of other problems, but I think at the VM level things are good. 

Certainly restart (shutting down qemu and restarting it, not a reset) 
works, I thought you wanted online resize. 



-- 
error compiling committee.c: too many arguments to function 
-- 
To unsubscribe from this list: send the line "unsubscribe kvm" in 
the body of a message to majordomo@vger.kernel.org 
More majordomo info at http://vger.kernel.org/majordomo-info.html 

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-09-05  9:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-28 20:26 expanding virtual disk based on lvm Ross Boylan
2012-08-28 21:15 ` Freddie Cash
2012-08-28 21:33   ` Ross Boylan
2012-08-28 21:33 ` Matthew Patton
2012-08-28 21:40   ` Freddie Cash
2012-09-04 12:53 ` Avi Kivity
2012-09-04 18:58   ` Ross Boylan
2012-09-05  7:25     ` Avi Kivity
2012-09-05  9:15       ` Alexandre DERUMIER

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox