Jeff Boyce
2011-Dec-19 23:04 UTC
[CentOS-virt] Confusion over steps to add new logical volume to guest VM
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 fstab. [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 www.meridianenv.com
James B. Byrne
2011-Dec-20 21:41 UTC
[CentOS-virt] Confusion over steps to add new logical volume to guest VM
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. HTH. -- *** 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
Possibly Parallel Threads
- Re: Detach disk from VM - virsh (working) vs. PHP (not working)
- Fw: Re: [SPDK] VM boot failed sometimes if using vhost-user-blk with spdk
- Fwd: (no subject)
- virsh create snapshot not honoring diskspec?
- BUG: HMTL-based help.search() on vignettes may generate error (with PATCH)