I've got an Ubuntu 9.04 server running two VM's. In /etc/libvirt/qemu/machine1.xml two disk devices are defined like this:

 <disk type='file' device='disk'>
   <source file='/vserver/machine1/disk0.qcow2'/>
   <target dev='hda' bus='ide'/>
 <disk type='file' device='disk'>
   <source file='/vserver/machine1/disk1.qcow2'/>
   <target dev='hdb' bus='ide'/>

I need more storage space in at least one of the devices and thought about adding a third hdc device by simply adding one with same style as above and re-organising my mount structure (The virtual sizes of the current qcow2 files are unfortunately limited.)

My problem is that reloading libvirtd and restarting the VM do not result in a new visible device (checked with fdisk).

I'm aware of extending an existing qcow2 file (converting to raw format, cat-ing/adding the new one, using smth. like gparted) - but only as a last resort.

Hopefully it's something very simple I'm missing?


Log in to the VM and shut it down.

Create a new virtual disk.

qemu-img create -f qcow2 /vserver/machine1/disk2.qcow2 $SIZE

Force shut down the VM.

virsh destroy machine1

Open the VM configuration in your default editor.

virsh edit machine1

Add a new disk stanza like below.

<disk type='file' device='disk'>
    <source file='/vserver/machine1/disk2.qcow2'/>
    <target dev='hdc' bus='ide'/>

Close your editor. libvirt will automatically reload the configuration.

Start the VM.

virsh start machine1
  • "virsh destroy" is a little heavy handed, as it shuts the VM down ungracefully. I'd advise graceful shutdown with "virsh shutdown" unless the VM is totally unresponsive. – Jerf Altair Dec 7 '12 at 7:28
  • "virsh shutdown" won't work if ACPI is not enabled in the libvirt config or a daemon like acpid is not properly configured and running in the guest. I've edited my instructions to include shutting down the guest first. – sciurus Dec 8 '12 at 21:18
  • the current versions on qemu-kvm support disk hotplug, so shutdown shouldn't be needed. besides, using qcow2 on a flat image is a waste, and using ide is borderline criminal, when you have virtio – dyasny Dec 8 '12 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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