1

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:

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

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?

initall
  • 2,205
  • 3
  • 18
  • 19

1 Answers1

3

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'/>
</disk>

Close your editor. libvirt will automatically reload the configuration.

Start the VM.

virsh start machine1
sciurus
  • 12,493
  • 2
  • 30
  • 49
  • "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 07 '12 at 07: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 08 '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 08 '12 at 22:00