Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Win 2008 KVM based guest VM running on a Ubuntu 10 host. It is a raw image of 22G. I want to add a "data" drive which would show up as "D:\" drive on the guest. I first created a raw image using:

qemu-img create -f raw ~/vmdisk2.img 50G

Then, tried attaching it using virsh attach-disk. When that did not work, I tried editing the xml file of the VM directly. Both did not seem to work.

I would greatly appreciate any help on how to do this and what the best practice is. I want to keep the base image small, so that I can clone it (hopefully) and then attach necessary storage based on the application at hand.

Update: The xml of the vm before adding the second drive:

<domain type='kvm'>
    <type arch='x86_64' machine='pc-0.12'>hvm</type>
    <boot dev='hd'/>
  <clock offset='localtime'/>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/win08e-vm1.img'/>
      <target dev='hda' bus='ide'/>
      <address type='drive' controller='0' bus='0' unit='0'/>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/home/taazaa/iso/Win08ER264.iso'/>
      <target dev='hdc' bus='ide'/>
      <address type='drive' controller='0' bus='1' unit='0'/>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    <interface type='bridge'>
      <mac address='52:54:00:7f:a7:ae'/>
      <source bridge='br0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    <serial type='pty'>
      <target port='0'/>
    <console type='pty'>
      <target type='serial' port='0'/>
    <input type='tablet' bus='usb'/>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes' keymap='en-us'/>
      <model type='vga' vram='9216' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>


share|improve this question
up vote 0 down vote accepted

can you post the xml? normally it should be edited by virsh edit and not directly. also, when you created the second raw file, why didn't you specify a size - this might also lead to problems

share|improve this answer
Sorry. I did specify the size 50G. forgot to add it to this post. – taazaa Mar 6 '11 at 15:04
I have posted the xml to the original post. – taazaa Mar 6 '11 at 15:11
sorry, formatting is all messed up... maked every newline with a '>' > <disk type='file' device='disk'> > <driver name='qemu' type='raw'/> > <source file='/var/lib/libvirt/images/vmdisk1.img'/> > <target dev='hda' bus='ide'/> > <address type='drive' controller='0' bus='0' unit='1'/> > </disk> something like this should work. make sure the image is not in your home dir but in the proper place. – dyasny Mar 6 '11 at 15:25
Thanks. The only difference is the unit and actual image path. I tried it and rebooted the VM, the drive does now show up (either in explorer or manage storage). Do I need to reload/change anything else? – taazaa Mar 6 '11 at 16:40
Perfect. I had to use virsh dumpxml/create to get the changes to stick. directly editing the xml did not work. But this worked well! – taazaa Mar 6 '11 at 17:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.