Mounting Disk Image in Raw format

From http://major.io/2010/12/14/mounting-a-raw-partition-file-made-with-dd-or-dd_rescue-in-linux/, there's a suggestion to use an offset. First obtain the offset via fdisk(8) and then specify it with the offset option to mount. Use fdisk to determine the starting sector of the partition and the sector size. Then calculate offset in bytes using the starting sector number and sector size in bytes. See Mount single partition from image of entire disk (device) for an example. Finally:

mount -o offset=<offset in bytes> nps-2010-emails.dd /media/manu/

In a typical hard disk, the cells holding the data are grouped. The groupings are called sectors. The way we usually partition things, the first few sectors are kept aside for giving information about the partitions, leaving a gap. So if we have an image of an entire disk, these sectors also get included. Now, the mount command cannot directly start at the first byte, as the partition doesn't start at the first byte. So, we will have to tell mount how many bytes to skip (so that it can avoid the extra information)and get to the actual partition. This is called the offset. Now each sector can store a certain amount of information in bytes, which is called the size of a sector. We take the total size of information that can be stored in this gap by multiplying the size of a sector, with the size of the gap in number of sectors.

From the output of fdisk there, you can see the sector size is 512 bytes and it starts at sector 1. So the offset is 1*512=512. Try the following command:

mount -t vfat -o offset=512 ps-2010-emails.dd /media/manu/

I added the filesystem type since fdisk gave it as FAT32. To mount it for writing as well, use -o offset=512,rw instead.


You can also have the computer automatically scan all the partitions in a dump and automatically prepare all loop devices, as described here.

So, lets say you dumped your entire /dev/sda into something called sda.img. You can access its partitions as follows:

losetup -f -P sda.img

On my system, it then shows up as follows:

sda raw image

In non-GUI environments, you can list the created device with losetup -l, which will tell you the name of the loop device, example:

# losetup -l
NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE
/dev/loop0         0      0         0  0 /path/mmcblk0

You can then mount say, the first partition, with:

mount /dev/loop0p1 /mnt/mypartition

Hope that helps.