[CentOS-virt] Confusion over steps to add new logical volume to guest VM

Tue Dec 20 21:41:51 UTC 2011
James B. Byrne <byrnejb at harte-lyne.ca>

On Mon, December 19, 2011 18:04, Jeff Boyce wrote:
> Greetings -
> I am hoping someone can confirm for me the steps that
> I am using to add an LV to an existing Guest in KVM,
> and what I am seeing as I do some of these steps.

I think that you will find it easier to create guest
storage volumes entirely from within virt-manager or virsh
and not try and manipulate them directly on the host.  I
have done so in the past but it adds a layer of complexity
to the process that yields no discernible benefits.

Here is what I have hit upon in my own explorations of kvm:

1. Create a virtual storage pool and add it to the host. 
I use an lv on the host.

2. Create initial guest instance and allocate a new volume
from the storage pool using virt-manager -> details ->
storage window through the guest storage browser.  Name
the new storage volume to something related to the vm
guest name.

3. Complete creating the vm guest.

4. To add additional storage to an existing vm guest first
open the guest's -> details -> hardware menu tab and then
select Add Storage.

5. In the guest hardware storage window select VirtIO
type, raw format, and press the browse button.

6. In the host storage window select the storage pool to
allocate storage from.

7. Select add a New Volume.

8. Assign a storage volume name (some variant of the base
storage volume such that all volumes assigned to a single
guest appear together in the host storage volume window
works best for me) and set the new volume size.  Refresh
the host storage display, select the new volume name, and
return to the guest storage window.

9. Push the Finish button.  Restart the guest.

10. Now open the guest console, find the newly added
device (fdisk -l ), say /dev/vdb for example, and
partition it using fdisk or parted. I always make one
partition for the entire device.  Refresh the devices
using parted.

11. Now add the newly partitioned device to the guest's
own vg using the normal lvm tools.

12. Now create new or expand existing lvs on the guest
using lvm.

The only trouble I had, well towards the end the only
trouble that I had left, was discovering that a VirtIO
storage volume is not automatically partitioned when
created.  Until it had a partition I could not add it to
the guest's vg even though I could see the device.


***          E-Mail is NOT a SECURE channel          ***
James B. Byrne                mailto:ByrneJB at Harte-Lyne.ca
Harte & Lyne Limited          http://www.harte-lyne.ca
9 Brockley Drive              vox: +1 905 561 1241
Hamilton, Ontario             fax: +1 905 561 0757
Canada  L8E 3C3