It is a pretty common practice to use the command dd to make backup images of drives and partitions. It’s as simple as the command:
dd if=[input] of=[output]
A while back I did just that and made a dd backup of not just a partition but of an entire hard drive. This was very simple (I just used if=/dev/sda instead of something like if=/dev/sda2). The problem came when I tried to mount this image. With a partition image you can just use the mount command like normal, i.e. something like this:
sudo mount -o loop -t [filesystem] [path to image file] [path to mount point]
Unfortunately this doesn’t make any sense when mounting an image of an entire hard drive. What if the drive had multiple partitions? What exactly would it be mounting to the mount point? After some searching I found a series of forum posts that dealt with just this scenario. Here are the steps required to mount your whole drive image:
1) Use the fdisk command to list the drive image’s partition table:
fdisk -ul [path to image file]
This should print out a lot of useful information. For example you’ll get something like this:
foo@bar:~$ fdisk -ul imagefile.img You must set cylinders. You can do this from the extra functions menu. Disk imagefile.img: 0 MB, 0 bytes 32 heads, 63 sectors/track, 0 cylinders, total 0 sectors Units = sectors of 1 * 512 = 512 bytes Disk identifier: 0x07443446 Device Boot Start End Blocks Id System imagefile.img1 * 63 499967 249952+ 83 Linux imagefile.img2 499968 997919 248976 83 Linux
2) Take a look in what that command prints out for the sector size (512 bytes in the above example) and the start # for the partition you want to mount (let’s say 63 in the above example).
3) Use a slightly modified version of the mount command (with an offset) to mount your partition.
mount -o loop, offset=[offset value] [path to image file] [path to mount point]
Using the example above I would set my offset value to be sector size * offset, so 512*63 = 32256. The command would look something like this:
mount -o loop, offset=32256 image.dd /mnt/point
That’s it. You should now have that partition from the dd backup image mounted to the mount point.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).
Check out my profile for more information.
Visit my personal website at http://www.tylerburton.ca.