<div dir="ltr">Hi all,<div><br></div><div>I have recently been writing a blog article on hard disk recovery, and think I have found an approach that would lend itself to a device mapper.</div><div><br></div><div>The idea is this:</div><div>Most tools currently try and copy the whole hard disk as best they can using an approach like ddrescue, this seems inefficient and risky if your disk is only partially used and you think it is about to fail (you've just replaced the heads for example).</div><div>Really what you want to recover first are the users' most important files, but to get to those first you need to read the partition table and filesystem(s) of which there are many to choose from. Of course you can access the filesystems using any number of tools like testdisk, fdisk, fsck, etc, but you don't get a copy. I think it would be most efficient to copy every disk access on the origin device to a backup device just in case the origin disk fails, but in a filesystem-agnostic way. Of course I'm talking of reads mostly, but also maybe writes if for example testdisk has been able to repair the partition table.</div><div><br></div><div>Having had a good search for a method of doing this, the closest available seems to be <b>dm-cache</b>. Having set the sequential_threshold and random_threshold both to 0, I assume dm-cache will copy all origin accesses to the cache device, and keep a record of the blocks in the cache and their physical location on the origin in the metadata device. This is very close, but to be able to restore the backup copy I need to be able to parse the metadata and reconstruct the copy in userspace.</div><div><br></div><div>Questions:</div><div><ol><li>Does this seem to be a good match for a device mapper or is there a better way of doing this?<br></li><li>Would this be best placed as a new device-mapper target or could this be implemented as a new operating mode or policy of an existing dm target?<br></li><li>Are there any userspace tools planned for the dm-cache metadata (like thin-provisioning-tools), and if not which kernel files would I look in as a start to writing a parser?<br></li></ol><div>In 'cache.txt' it states: "<span style="color:rgb(0,0,0);white-space:pre-wrap">The target reuses the metadata library used in the thin-provisioning </span><span style="color:rgb(0,0,0);white-space:pre-wrap">library.</span>" but I tried those tools and they didn't appear to work, failing with "bad checksum in superblock".</div></div><div><br></div><div>I would be interested in writing some kernel code since I do know C, but having never written any kernel code before I feel this might be a rather steep learning curve. I rather feel that my skills might be best placed writing a parser instead. I think at first I should at least prove the concept!</div><div><br></div><div>Many thanks in advance, and keep up the excellent work. I'm a long-time Linux user, since Redhat 5.2 I think!</div><div>Regards,</div><div>Richard</div></div>