3

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'>
  <name>win08e-vm1</name>
  <uuid>183a4ba0-1c0b-0b04-ad01-aa7c3a4cb390</uuid>
  <memory>1048576</memory>
  <currentMemory>1048576</currentMemory>
  <vcpu>2</vcpu>
  <os>
    <type arch='x86_64' machine='pc-0.12'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='localtime'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/kvm</emulator>
    <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>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/home/taazaa/iso/Win08ER264.iso'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' unit='0'/>
    </disk>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <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'/>
    </interface>
    <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <input type='tablet' bus='usb'/>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes' keymap='en-us'/>
    <video>
      <model type='vga' vram='9216' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </memballoon>
  </devices>
</domain>

Thanks!

1 Answer 1

1

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

6
  • Sorry. I did specify the size 50G. forgot to add it to this post.
    – taazaa
    Mar 6, 2011 at 15:04
  • I have posted the xml to the original post.
    – taazaa
    Mar 6, 2011 at 15:11
  • 1
    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, 2011 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, 2011 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, 2011 at 17:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .