Linux KVM: Use software RAID as VM-guest disk
Posted: Sun Aug 18, 2013 3:43 am
Here's a short description about how to add a physical device's software-RAID partition directly as virtio disk, available to VM-guests.
Introduction:
I wanted to have one virtual machine guest accessing a certain software RAID partition, formatted on ext4 - exclusively.
I've tried adding that device to the KVM's storage pool, using virt-manager, but I failed. It always mounted the device and sold it to the guests as dir. That's not what I wanted.
Luckily, I found a post on Ronald Ever's blog, about adding a physical device using libvirt. I think this is currently not yet possible with virt-manager, so as Ronald says:
First: Stop the virtual machine guest you're planning to add the disk to.
Then, add the disk:
The XML block you have to add to "/etc/libvirt/qemu/<vm_guest>.xml" looks somewhat like this:
The only thing that's missing in Ronald's HowTo is, that the XML file should be edited using "virsh" - and not directly:
This opens the configuration XML of the <vm_guest> in your favorite editor. Now add the above XML block and adapt it to fit your environment.
Then restart libvirt:
Now, you should have the software RAID device available as "/dev/vdb1" on your virtual guest machine.
Have fun!
Introduction:
I wanted to have one virtual machine guest accessing a certain software RAID partition, formatted on ext4 - exclusively.
I've tried adding that device to the KVM's storage pool, using virt-manager, but I failed. It always mounted the device and sold it to the guests as dir. That's not what I wanted.
Luckily, I found a post on Ronald Ever's blog, about adding a physical device using libvirt. I think this is currently not yet possible with virt-manager, so as Ronald says:
But don't be afraid: It's actually really easy. If you're able to edit a textfile, you're ready to play!You have to do it by hand.
First: Stop the virtual machine guest you're planning to add the disk to.
Then, add the disk:
The XML block you have to add to "/etc/libvirt/qemu/<vm_guest>.xml" looks somewhat like this:
Code: Select all
<disk type='block' device='disk'>
<driver name='qemu' type='raw'/>
<source dev='/dev/md0'/>
<target dev='vdb1' bus='virtio'/>
</disk>
Code: Select all
$ virsh edit <vm_guest>
Then restart libvirt:
Code: Select all
$ /etc/init.d/libvirt-bin restart
Have fun!