Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created an image of a disk using dd using the command dd if=/dev/sdb of=/jobs/image.dd. The SATA drive /dev/sdb has 3 partitions on it (one NTFS, two FAT32).

How do I mount the complete image with all its partitions in one go? I actually want to script this using Python but knowing how to do it is obviously the first step!

Thanks in advance

share|improve this question
up vote 7 down vote accepted

Use kpartx (from multipath-tools):

use losetup to get a /dev/loop? device, then use kpartx on it to create dev mappings for the partitions in the image file.

share|improve this answer
Great, kpartx worked great! – Luke Bibby Nov 9 '09 at 10:11

Doing one partition at a time isn't too difficult. Basically you use losetup with the offset parameter. Here is an article that describes the steps, and here is another.

If you wanted to do all at once you would probably have to write a script that retrieved the partition table from the disk image, and then ran losetup several times to create several loop devices. I am not aware of any tools that do this for you.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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