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.)

link|improve this question
feedback

2 Answers

up vote 3 down vote accepted

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

link|improve this answer
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? – Job Apr 7 '10 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. – Ignacio Vazquez-Abrams Apr 7 '10 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! – Job Apr 7 '10 at 12:34
feedback

+1 for kpartx.

For command line fans, partx does the same job.

link|improve this answer
Except that kpartx isn't a GUI app. – Ignacio Vazquez-Abrams Apr 6 '10 at 12:38
Fair enough! I guessed it might be a kde gui thing... – CJBrew Apr 6 '10 at 13:20
Ignore my answer. Partx appears to be a subtly different tool. – CJBrew Apr 6 '10 at 13:21
feedback

Your Answer

 
or
required, but never shown

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