Atlas1j Atlas1j - 3 months ago 16
Linux Question

loopback mounting individual partitions from within a file that contains a partition table on linux

Is there any new/better way of loopback mounting individual partitions from within a file that contains a partition table on linux? I see the following but they are somewhat dated.

http://linux.derkeiler.com/Mailing-Lists/Kernel/2005-01/7183.html

http://lists.gnu.org/archive/html/grub-devel/2005-01/msg00077.html

ftp://ftp.hq.nasa.gov/pub/ig/ccd/enhanced_loopback/

Answer

Let's say $IMAGE is set to the path to your image file. You could write a small script by using

fdisk -u sectors -l $IMAGE

to get a list of partitions inside the image. And then use a sequence of

mount -o ro,loop,offset=$OFFSET -t auto $IMAGE /media/$DEST

Where offset is calculated means the info from fdisk (start sector * size of a sector in bytes) and $DEST a unique name for each of the partitions.

That's not directly the solution but I hope a pretty good indication on how to realize it. If you make the job once, you've some small nice beginning for some forensic toolkit!​​​​​​​​​​​​​​​​​​​​​