Mounting a partition from a dd image
Posted by vostorga - 12/07/14 at 12:07:43 pmAt some point, everybody may have done a dd image of a USB/SD stick, as the below example shows:
dd if=/dev/sdb of=foo.img
But it is usual that at some point in time we would like to access the information inside the image, doing that is quite easy:
First,you should do a fdisk on the image:
fdisk -l foo.img
Disk foo.img: 7998 MB, 7998537728 bytes, 15622144 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0002fc6dDevice Boot Start End Blocks Id System
foo.img1 * 1 15622143 7811071+ c W95 FAT32 (LBA)
Then some maths are needed. The operators are the start of the partition and the sector size in bytes. The operation is simply start * sector size in bytes.
In this particular case the operation is 1 * 512 = 512.
Now that we have the result, that we call the offset. In other words, 512 is the offset where the partition starts in this dd image.
So the command to mount the partition is:
mount -t vfat -o loop,ro,noexec,offset=512 foo.img /mnt/mountpoint
And then we can copy the information from the partition inside!
No Comments yet »
RSS feed for comments on this post. TrackBack URI
Leave a comment
Powered by WordPress with GimpStyle Theme design by Horacio Bella.
Entries and comments feeds.
Valid XHTML and CSS.