Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 5 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.

share|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

+1 for kpartx.

For command line fans, partx does the same job.

share|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

Your Answer

 
discard

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.