conversion of a VMDK image with qemu-img failed with "error while reading sector 131072: Invalid argument"
I tried to convert a VMDK image found in a OVA file to the QCOW2 format with the qemu-img command but it failed with the error message qemu-img: error while reading sector 131072: Invalid argument
user@ubuntu:/tmp$ wget ftp://ftp.sanger.ac.uk/pub/databases/Pfam/vm/PfamWeb_20120124.ova
user@ubuntu:/tmp$ tar xfv PfamWeb_20120124.ova
PfamWeb_20120124_2.ovf
PfamWeb_20120124_2.mf
PfamWeb_20120124_2-disk1.vmdk
user@ubuntu:/tmp$ qemu-img convert -O qcow2 PfamWeb_20120124_2-disk1.vmdk PfamWeb_20120124_2.qcow2
qemu-img: error while reading sector 131072: Invalid argument
user@ubuntu:/tmp$ qemu-img --version | grep "qemu-img version"
qemu-img version 1.0, Copyright (c) 2004-2008 Fabrice Bellard
user@ubuntu:/tmp$ dpkg-query -f='${Version}\n' --show qemu-utils
1.0+noroms-0ubuntu14.1
user@ubuntu:/tmp$ cat /etc/issue
Ubuntu 12.04.1 LTS \n \l
How do I avoid the error?
Solution 1:
A bug related to this was fixed in qemu version 1.2.0. Ubuntu 12.04 has an older qemu version, but if you install qemu-img from source code
user@ubuntu:/tmp$ sudo apt-get install libglib2.0-dev
user@ubuntu:/tmp$ wget http://wiki.qemu.org/download/qemu-1.2.0.tar.bz2
user@ubuntu:/tmp$ tar xfj qemu-1.2.0.tar.bz2
user@ubuntu:/tmp$ cd qemu-1.2.0
user@ubuntu:/tmp/qemu-1.2.0$ ./configure && make qemu-img
the conversion runs without errors
user@ubuntu:/tmp/qemu-1.2.0$ cd /tmp
user@ubuntu:/tmp$ /tmp/qemu-1.2.0/qemu-img convert -O qcow2 PfamWeb_20120124_2-disk1.vmdk PfamWeb_20120124_2.qcow2
user@ubuntu:/tmp$