Mounting a File System or Partition From a Disk Image

January 23, 2010 Category: Uncategorized

You cannot just make a disk copy with dd and then just mount it as a regular disk. You must know where the partition starts on the disk. So first, you need to get the partition table with sfdisk:

sfdisk -l -uS image_file.dd

The output is something like:

Disk /mnt/image/image_file.dd: 9729 cylinders, 255 heads, 63 sectors/track
Warning: The partition table looks like it was made
for C/H/S=*/240/63 (instead of 9729/255/63).

For this listing I'll assume that geometry.

Units = sectors of 512 bytes, counting from 0

Device Boot Start End #sectors Id System

/mnt/image/simon-besmet.img1 63 8497439 8497377 b W95 FAT32
/mnt/image/simon-besmet.img2 * 8497440 156280319 147782880 7 HPFS/NTFS
/mnt/image/simon-besmet.img3 0 - 0 0 Empty
/mnt/image/simon-besmet.img4 0 - 0 0 Empty

Next, we need to calculate the actual starting point of the partition. The sector number is in sectors, which contain 512 bytes. So in this case, the starting point of the NTFS partition is 8497440 x 512 = 4350689280.

To mount the image, enter the following command, using the calculated offset:

mount -o loop,offset=4350689280 /mnt/image/disk_image.dd /mnt/disk

Source:

http://lists.samba.org/archive/linux/2005-April/013444.html

Comments