Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Often people take an image of a hard dive with dd, for example, and then mount the partitions within using kpartx or losetup. It's a common way to make the partitions on an image file mountable and look like a filesystem.

I'm wondering if it's possible to do the reverse; that is make a device like /dev/sda look like a file. Note: my purpose in asking this is in relation to a raid0 data recovery.

In my case, I could dd the two 2TB drives I'm working on to some other storage container and operate on the image files. But that is painful, so I'm trying to avoid taking images.

Any ideas how to make a drive like /dev/sda look like a file?

Edit to add more info.

The tool I'm trying to use for recovery is FUSE based, http://pyraid.googlecode.com If I run it against image files it works fine. If I run it against block devices (/dev/sdx) it does not work.

file /dev/sda
/dev/sda: block special

file sda.img
sda.img: data

So to ask my question another way, how can I make a block special device look like data?

share|improve this question
7  
It already "looks like a file." And if you're really trying to recover data from those disks, you should be taking images. –  Michael Hampton Sep 1 '13 at 5:26
3  
/dev/sda is a file and you can treat it like a file. –  mauro.stettler Sep 1 '13 at 5:32
4  
I don't know where in the world you are but I'm guessing it's really late and you're tired. Go to bed and come back refreshed tomorrow and marvel at how stupid being tired can make you. –  Iain Sep 1 '13 at 5:45
    
"It does not work" is not useful. You should have received (and posted here) an error message. –  Michael Hampton Sep 1 '13 at 14:43
    
There is no error message. Pyraid appears to work but it just creates a zero byte raid device when you feed it block devices. –  qwopper Sep 1 '13 at 15:28

1 Answer 1

Sure you can. In linux, everything acts like a file. The point of imaging isn't to make something into a file - its to ensure you do not mess things up and damage things further. You could do recovery directly from a drive, using the exact same tools, but if you have physical damage, or you wrote to the drive,... boom.

So, if you wanted to work directly off the whole drive - run your tools on /dev/sdX and on /sdXn if you wanted to work off a partition. Just that you risk more data loss. Making an image is the smart thing, since if you work off an image of an image, and you make a mistake you can just delete it, start over from a fresh copy and not lose anything.

Imaging is just due diligence. Do it. Its much more hassle to be working to recover things from part of a disk that you just accidentally dded over. It also is very useful if you suspect hardware failure. Its worth the 2-3 hours or so (and the temporary disk space you will need) for the peace of mind.

share|improve this answer

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.