Howard Lowndes <[EMAIL PROTECTED]> uttered the following thing:
> I have a disk image of a CompactFlash disk as a file on a PC.  The image 
> was created by using dd.
> 
> I know that the image has a partition table, a Linux (83) partition and 
> a Linux Swap (82) partition.  The Linux partition is formatted ext2.
> 
> I want to be able to mount the Linux partition rw somewhere onto the 
> PC's file system so that I can work on it using an editor.

The problem here of course is that the linux loopback filesystem mounter
doesn't know anything about partition tables, it expects a filesystem,
not an entire disk image. But all's not lost.  Here's a way which will 
work on most (but not all) disks, assuming the other ideas presented
fail.

The partition table and MBR and other disk header gubbins is stored in
the first few sectors on the disk. The trick is to find out just where
the "interesting" partitions start. You can use fdisk to verify that the
basic partition table stuff is there:

# fdisk disk.img
You must set cylinders.
You can do this from the extra functions menu.

Command (m for help): p

Disk disk.img: 0 MB, 0 bytes
4 heads, 32 sectors/track, 0 cylinders
Units = cylinders of 128 * 512 = 65536 bytes

   Device Boot      Start         End      Blocks   Id  System
   disk.img1   *           1         244       15600   83  Linux

   Command (m for help):

OK, so the interesting filesystem starts at the beginning.

Next step, hunt for the ext2 magic number, using our friend hexdump and
less:

# hexdump disk.img|less
[lots of hex]

You need to find the beginning of the partition. To do that, look for
the magic incantation:

/ef53 0001 0001

Which will lead you to something like this:

0003fe0 d1aa 0cd9 14e9 72f4 042e e10d 9994 3db3
0003ff0 1af5 6ba4 72ba 8e08 8930 e292 65bb da56
0004000 0000 0000 0000 0000 0000 0000 0000 0000
*
0004400 0f40 0000 3cf0 0000 030c 0000 0a50 0000
0004410 0f12 0000 0001 0000 0000 0000 0000 0000
0004420 2000 0000 2000 0000 07a0 0000 133c 450f
0004430 13cd 450f 0004 001a ef53 0001 0001 0000
0004440 0198 450f 4e00 00ed 0000 0000 0001 0000
0004450 0000 0000 000b 0000 0080 0000 0034 0000

Notic it's on the third line from the bottom here (0004430). You've found a
filesystem!

Next, wind back four lines, to where all the zeros are. In this case,
it starts at offset 0x4000. That's your filesystem start.

Now determine this in decimal:

$ printf "%d\n", 0x4000
16384

Then 'dd' the filesystem to another file, skipping til that point:

dd if=disk.img of=disk.img1 bs=<number above> skip=1

Now, disk.img1 contains your complete filesystem (plus all of the
trailing partitions, but that doesn't matter). You can now just mount it:

$ mount -o loop disk.img1 /mnt/blah

Problem solved :)

BB

-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to