I have been hacking away at trying to figure out how to loopback mount a Linux image file directly. I finally figured it out. Here are the steps.
1. Grab an image. I will use my linux-2.img file here.
2. od -x linux-2.img | grep "d45 28cd 0000 0001"
Which gives you something like:
0001000 3d45 28cd 0000 0001 0000 0000 0000 0000
14140000 3d45 28cd 0000 0001 0000 0000 0000 0000
17540000 3d45 28cd 0000 0001 0000 0000 0000 0000
23740000 3d45 28cd 0000 0001 0000 0000 0000 0000
25440000 3d45 28cd 0000 0001 0000 0000 0000 0000
25540000 3d45 28cd 0000 0001 0000 0000 0000 0000
Those are the offsets in octal inside the image.
3. You can see the matching filesystems using fdisk:
fdisk linux-2.img
gives you:
Device Boot Start End Blocks Id System
linux-2.img1 33 6208 3088 83 Linux
linux-2.img2 6209 31360 12576 5 Extended
linux-2.img5 6241 8000 880 83 Linux
linux-2.img6 8033 10176 1072 83 Linux
linux-2.img7 10209 11072 432 83 Linux
linux-2.img8 11105 30720 9808 83 Linux
4. Therefore, to create a loopback device for the first partition, do:
losetup -o 512 /dev/loop1 linux-2.img
(octal 1000 = decimal 512, the second partition would be decimal 3194880)
5. Then mount it somewhere:
mount /dev/loop1 /mnt
There you go. This of course assumes that you have CONFIG_BLK_DEV_LOOP and CONFIG_CRAMFS in your kernel. This is pretty cool because you can now mount your image without killing your CF card and poke around in it as much as you want. Should also be able to point vmware at these. That's my next bit of fiddling.