VMDK convert and raw IMG mounting on Ubuntu 14.04 Linux


I haven’t tested mounting just the vmdk image, wasn’t sure if that would work, so I just ran the conversion first to raw img file.  I don’t really need to regularly, but I wanted to convert an old vmdk virtual disk to a ZFS file system with NTFS on it for use in KVM. (the vmdk I could use, but it was too small anyway)

First I convert: (cd to your vmdk dir, I am in /vm/sys )

qemu-img convert -f vmdk sourcefile.vmdk -O raw newfile.img

 

Next set the loop dev and find the partitions using

loopdev=$(losetup -s -f newfile.img)
kpartx -av $loopdev

 

On my system it added a new /dev/mapper:

/dev/mapper/loop0p1

 

Make a mountpoint and mount the loopdev as NTFS

mkdir mntimg
mount /dev/mapper/loop0p1 /vm/sys/mntimg

From here, I could easily mount my ZVOL and have it partitioned and formatted and ready for an rsync!

This of course doesn’t help me if I wanted to edit the VMDK disk image and continue to use it.  Later I might test a direct vmdk mount and see what happens, because that would be helpful while fixing non-booting vm’s!