Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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
share|improve this answer
    
"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. –  Jeff Halter 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
add comment

Your Answer

 
discard

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.