Epic Voyage logo

Epic Voyage

The Wanderer's Journal

Main menu

  • Home

Geek Stuff: Pull Files from a Raw Disk Dump

Suppose that you clone a harddrive to a file on another harddrive (dd if=/dev/sda of=/home/user/dump.img). All of the partitions on the drive are in the dump file. How do you access a file on one of the partitions?

I’ve had to do this several times in the last two months. Today, my image is 50GB (not an exact harddrive image because I took a round-about way to pull the data):

ls -lh recovered.img 

-rw-r--r-- 1 chris root 50G Jul  9 15:48 recovered.img

sfdisk (probably as root) will show where the partitions are at:

sfdisk -l -uS recovered.img
Disk recovered.img: cannot get geometry
Disk recovered.img: 6527 cylinders, 255 heads, 63 sectors/track
Units = sectors of 512 bytes, counting from 0
   Device Boot    Start       End   #sectors  Id  System
recovered.img1          2048  93114367   93112320   7  HPFS/NTFS
recovered.img2             0         -          0   0  Empty
recovered.img3             0         -          0   0  Empty
recovered.img4             0         -          0   0  Empty

This indicates one NTFS partition at sector 2048. In order to turn that number into a byte offset, you have to multiply it by the number of cylinders on the drive (despite what sfdisk claims it knows about the file). That number has always been 512 for my data operations, which means 2048 * 512 = 1048576. With this magic number, we should be able to mount the partition as root:

mount -t ntfs-3g -o loop,offset=1048576 recovered.img /mnt/hd

The “loop” option tells “mount” that we are mounting a file instead of a literal device. If you can’t figure out the rest, go read the man page for mount.

Overheard at the Tavern

To pass lightly from old laws to new ones is a certain means to weakening the inmost essence of all law whatever. — Aristotle
Another »

Since This Page Loaded...

0 million dollars have been spent by Washington.
0.00 dollars per person in the US.

And that is only Federal spending...

0 babies have died worldwide in an abortion.
0 babies were in the United States.

0 Americans have contracted an STD.

About Me

{author}
Chris is probably out getting lost somewhere. He has a tendency to do that. Please don't worry unless he fails to show up again sometime in the next week.

Copyright 2024. All rights reserved.