I used the process below to access VM files (VMDK, VMX) that were located in a binary image file of an EqualLogic LUN that contained a VMFS partition. The binary image files were located on NTFS formatted USB drives. This process can work for binary image files that contain other partition formats. You will need to make sure that NTFS-3G and VMFS-TOOLS are installed.
The first step is to see if you have a free loop device. If you see a loop device listed in /dev that is not listed by “losetup -a” then it should be available.
ls /dev/loop* losetup -a
If you do not have a free loop device you can make a new one and verify that it is now available.
mknod -m 660 /dev/loop5 b 7 5 mknod -m 660 /dev/loop6 b 7 6 ls /dev/loop* losetup -a
If you have a loop device that you previously used and need to free it up you can also detach a loop device. This will also be needed if you want to be able to unmount an attached drive that has a file that you attached a loop device to.
losetup -a losetup -d loop5 losetup -a
Connect the drive and if it does not auto-mount you will need to locate and mount the drive. You might also need to use gdisk or sgdisk if the drive uses a GPT partition table.
fdisk -l sgdisk -p /dev/sdg mkdir /mnt/extdrive1 mount /dev/sdg2 /mnt/extdrive1 cd /mnt/extdrive1
Next you will need to find the partitions located within the binary image file. Again you might need to use gdisk or sgdisk if the binary image file contains a GPT partition table. You will also need to record the start, and possibly end, position of any needed partitions.
fdisk -l file.bin sgdisk -p file.bin
Now you can attack a loop device to the start of the needed partition in the binary image file. In the below example the needed partition starts a sector 128 and since each sector is 512 bytes we can have bash do the math for the starting position. You may also need to add the ending position, or ending position plus one, by adding the option –sizelimit with the end sector or end sector plus one replacing the “128” in the equation.
losetup /dev/loop5 file.bin -o $((128*512))
Once the loop device is attached you can now mount the needed partition and access the files within the partition in the binary image file.
vmfs-fuse /dev/loop5 /mnt/vmfs1 ls /mnt/vmfs1
To undo all of this; unmount the loop device, detach the loop device, and then unmount the external storage.
umount /mnt/vmfs1 losetup -d /dev/loop5 umount /mnt/extdrive1
The following site was very helpful in figuring this out.
http://ram.kossboss.com/mount-luns-with-partitions-using-losetup-and-kpartx/