6

If you have a hard disk image (including partition table, multiple partitions,...), is it possible to let Linux treat it as a regular hard disk?

By "regular hard disk" I mean I would like to have the image show up as, for instance, /dev/hdx and its partitions as /dev/hdx1,...

(I know I can mount one of the partitions in the image using "mount -o loop,offset=x ..." but I don't really like this option.)

2 Answers 2

6

kpartx will generate multiple device files from the partitions within the file which you can then loopmount to get at the contents.

3
  • Yes that does what I want! Just one thing: only the partitions show up as dev-nodes, is it also possible to create a node for the entire device?
    – mtvec
    Apr 7, 2010 at 8:14
  • I'm not certain why you'd need to. With the exception of ioctls, a normal file works just like a block device. Apr 7, 2010 at 8:21
  • I need it to access the MBR, but you're right: I can do that via the image file as well. Thanks for the help!
    – mtvec
    Apr 7, 2010 at 12:34
1

+1 for kpartx.

For command line fans, partx does the same job.

3
  • Except that kpartx isn't a GUI app. Apr 6, 2010 at 12:38
  • Fair enough! I guessed it might be a kde gui thing...
    – CJBrew
    Apr 6, 2010 at 13:20
  • Ignore my answer. Partx appears to be a subtly different tool.
    – CJBrew
    Apr 6, 2010 at 13:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .