qemu: could not open disk image: no such file or directory

By | January 5, 2012

Using libvirt (virsh) with KVM can be really handy. virsh allows you to create, edit, delete and migrate vm’s with ease. I had this problem (qemu: could not open disk image: /home/vmdisk/disk.qcow2 no such file or directory) while migrating vm from server to server. Well, that’s a very basic problem and here is a small fix for it.

NOTE: /home/vmdisk is my KVM disk directory, where I store all the qcow2 files and “disk.qcow2” is the current hard-disk of a virtual machine.

Fixing the problem:

STEP1: Make sure to have common disk storage place in all the servers where you store your virtual machine hard disks. I personally use /home/vmdisk as my common directory through out all my KVM servers. Use, common user and group permission for the disk storage directories.

STEP2: Make sure /home/vmdisk has common shared disk from SAN or NFS. Make sure to set proper permissions. The hard disk should be visible in both the machines.

(OR)

STEP2: If you don’t use shared disk, and you want to migrate the VM using TCP connection, then make sure you have /home/vmdisk in place on the destination server with proper permissions. SCP the qcow2 file (VM Hard disk) to the destination host virtual machine directory, which is (/home/vmdisk)

Now, try migrating and it should work.

Doing this, will generally solve the above mentioned problem. Virsh will look for your hard-disk (“disk.qcow2” ) on the destination server. If the hard-disks have common storage area which is (/home/vmdisk/), then virsh would look for the hard disk. If the disks are not mounted, we manually transfer the disk to /home/vmdisk directory in the destination server.

NOTE: Use the following command as root to transfer the VM from one server to another if you have no shared disk mounted. Make sure to have password less ssh login before trying the following command.

virsh -c qemu:///system migrate –live –persistentĀ –copy-storage-all VM-NAME qemu+ssh://root@DESTINATION-HOST-IP/systemĀ –migrateuri tcp://DESTINATION-HOST-IP

You can write a shell script to automate the whole process.

If you like this article, then please consider sharing it. Sharing really inspires us to do things much better!!

Leave a Reply

Your email address will not be published. Required fields are marked *