2
  • Let's have unknown disk drive uncompressed raw image (created for example by dd if=/dev/sda of=image) in single file.
  • If we knew the disk layout, we could mount particular partitions from the file as the loop devices via skipping some offsets.
  • Let's suppose we don't know the layout. Can we somehow "mount" the whole disk drive image, which process would create virtual block devices according to the disk layout? For example having 2 partitions in the image would result in creating 3 devices (/dev/sdx, /dev/sdx1, /dev/sdx2). We could then mount such devices as usual.

marked as duplicate by Deltik, Community Jan 30 '16 at 17:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • What you are looking for is the loop device. You can attach anything on one loop device, then run kpartx against it to discover partitions which can then be mounted. – Sami Laine Jan 30 '16 at 16:29
  • @Deltik: Thanks, I have already found similar posts and formulated an answer. – sharpener Jan 30 '16 at 16:54
  • if it is an image of a single partition you cant just mount it directly. Only if the image contains more than a single partition or filesystem do you need a program to parse input and emulate several volumes. – jiggunjer Jan 30 '16 at 18:04
1

After some more research I have found, there are at least two methods to test:

  1. According to this post, kpartx is applicable tool.
    • Unfortunately it didn't work on Arch Linux for me
    • It's from AUR: yaourt multipath-tools-git, seems to be not well supported/finished and ended up with errors like:

      device-mapper: reload ioctl on loop0p1 failed: No such device

    • Can be at least used to list the embedded partitions: kpartx -l image
    • EDIT: According to this post, it seems to be obsolete and the preferred method is the following one.
  2. According to this post, losetup can be used.
    • Firstly it didn't work: losetup /dev/loop0 image (missing the devices for particular partitions).
    • Trying again using additional -P option did the work: losetup -d /dev/loop0, losetup -P /dev/loop0 image and /dev/loop0pX devices were created.
    • These devices are then mountable as expected, like mount /dev/loop0p3 /mnt/x -t ntfs
  • I wonder if would work without the MBR/GPT information. What if you cropped the first couple of sectors, so the image starts at the first partition? And are those /dev/loop0px volumes writable, as in changes are saved to the original image file? – jiggunjer Jan 30 '16 at 18:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.