Virtualization With KVM On A Fedora 17 Server - Page 5
8 Creating An LVM-Based Guest From The Command LineFedora 17 KVM Host: LVM-based guests have some advantages over image-based guests. They are not as heavy on hard disk IO, and they are easier to back up (using LVM snapshots). To use LVM-based guests, you need a volume group that has some free space that is not allocated to any logical volume. In this example, I use the volume group /dev/vg_server1 with a size of approx. 465GB... vgdisplay [root@server1 ~]# vgdisplay ... that contains the logical volumes /dev/vg_server1/LogVol00 with a size of approx. 100GB and /dev/vg_server1/LogVol01 (about 6GB) - the rest is not allocated and can be used for KVM guests: lvdisplay [root@server1 ~]# lvdisplay I will now create the virtual machine vm12 as an LVM-based guest. I want vm12 to have 20GB of disk space, so I create the logical volume /dev/vg_server1/vm12 with a size of 20GB: lvcreate -L20G -n vm12 vg_server1 Afterwards, we use the virt-install command again to create the guest: virt-install --connect qemu:///system -n vm12 -r 512 --vcpus=2 --disk path=/dev/vg_server1/vm12 -c /var/lib/libvirt/images/debian-6.0.5-amd64-netinst.iso --vnc --noautoconsole --os-type linux --os-variant debiansqueeze --accelerate --network=bridge:br0 --hvm Please note that instead of --disk path=/var/lib/libvirt/images/vm12.img,size=20 I use --disk path=/dev/vg_server1/vm12, and I don't need to define the disk space anymore because the disk space is defined by the size of the logical volume vm12 (20GB). Now follow chapter 5 to install that guest.
9 Converting Image-Based Guests To LVM-Based GuestsFedora 17 KVM Host: No let's assume we want to convert our image-based guest vm10 into an LVM-based guest. This is how we do it: First make sure the guest is stopped: virsh --connect qemu:///system shutdown vm10 quit Then create a logical volume (e.g. /dev/vg_server1/vm10) that has the same size as the image file. To find out the size of the image, type in ... ls -l /var/lib/libvirt/images/ [root@server1 ~]# ls -l /var/lib/libvirt/images/ As you see, vm10.img has a size of exactly 12884901888 bytes. To create a logical volume of exactly the same size, we must specify -L 12884901888b (please don't forget the b at the end which tells lvcreate to use bytes - otherwise it would assume megabytes): lvcreate -L 12884901888b -n vm10 vg_server1 Now we convert the image: qemu-img convert /var/lib/libvirt/images/vm10.img -O raw /dev/vg_server1/vm10 Afterwards you can delete the disk image: rm -f /var/lib/libvirt/images/vm10.img Now we must open the guest's xml configuration file /etc/libvirt/qemu/vm10.xml... vi /etc/libvirt/qemu/vm10.xml ... and change the following section...
... so that it looks as follows:
Afterwards we must redefine the guest: virsh --connect qemu:///system define /etc/libvirt/qemu/vm10.xml Still on the virsh shell, we can start the guest... start vm10 ... and leave the virsh shell: quit
10 Links
|



Recent comments
19 hours 38 min ago
19 hours 43 min ago
1 day 42 min ago
1 day 7 hours ago
1 day 8 hours ago
1 day 9 hours ago
1 day 13 hours ago
1 day 20 hours ago
2 days 15 min ago
2 days 1 hour ago