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

Mon Dec 19 23:04:57 UTC 2011
Jeff Boyce <jboyce at meridianenv.com>

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.  My host (earth) is CentOS 6 and so is my guest (disect).  The guest 
(disect) is my testing server.  The main objective of what I am trying to do 
is add a logical volume for /var into my guest.  The LV (lv_disectvar) is 
part of an existing VG (vg_mei) on the host. When I installed my guest OS, I 
could only select one LV from my host for the installation, so the entire OS 
was installed into lv_disectroot.  I have added lv_disectvar into the 
storage pool available for VMs through the VirtManager GUI, and successfully 
added the lv_disectvar to the guest VM also through the VirtManager GUI. 
And now I want to move my /var over to the new LV.

My notes show that I created the LV about two weeks ago, and added it to the 
guest VM last week.  I don't see any other notes indicating that I did 
anything else with this LV.  Today I finally got around to the task of 
moving /var from lv_disectroot over to lv_disectvar and editing fstab so 
that it would automount at boot.  So here are the steps that I was going to 
do, and what I saw that made me pause.

1.  Verify that the device is identified by the guest, and get the UUID for 
[jeffb at disect ~]$ ls -l /dev/disk/by-uuid
total 0
lrwxrwxrwx. 1 root root 10 Dec 12 14:37 
738923a4-c345-40bf-a850-4454caa152b6 -> ../../vda2
lrwxrwxrwx. 1 root root  9 Dec 12 14:37 
db1230fb-a061-4ea4-9229-c5953d29aef8 -> ../../vdb          <----lv_disectvar
lrwxrwxrwx. 1 root root 10 Dec 12 14:37 
db70a6db-3640-4392-b9ba-49839d6e4b45 -> ../../vda1

2.  Create a mount point for /dev/vdb
[root at disect jeffb]# mkdir /mnt/var

3.  Mount the device
[root at disect jeffb]# mount -t ext4 /dev/vdb /mnt/var

4.  At this point I was going to move /var to /mnt/var but decided to check 
the mount first
[root at disect mnt]# cd /mnt/var
[root at disect var]# ls
cache  lib  lock  log  lost+found  run

5.  When I saw the directories listed I was initially confused and thought I 
had possibly mounted the wrong device.  But after double checking everything 
it appears I did not do anything wrong.  As I mentioned above my notes do 
not show that I did anything with this LV other than create it and attach it 
to the guest VM.  I am wondering about the source of these directories and 
all the subsequent files under them.  My assumption is that these were 
created during the creation of the LVM and are part of its file system.  Is 
that a correct assumption?  How could I confirm this assumption?

6.  Can I just add a /var directory to this and move my /var from /vda2 over 
to /vdb?

7.  Then I would add the following line to my /etc/fstab in the guest disect
UUID=db1230fb-a061-4ea4-9229-c5953d29aef8 /var ext4 defaults 1 2

8.  I initially tried just adding the above line to my fstab, but realized 
after the guest VM hung on rebooting that /var is already mounted under /, 
and that of course caused a problem when booting.

Thanks for any advice you can provide.

Jeff Boyce
Meridian Environmental