tuxera / ntfs-3g

NTFS-3G Safe Read/Write NTFS Driver
https://www.tuxera.com/company/open-source
GNU General Public License v2.0
994 stars 149 forks source link

ntfsclone: support writing a ddrescue domain mapfile #40

Open jbosboom opened 2 years ago

jbosboom commented 2 years ago

ntfsclone's rescue mode has (at least) two shortcomings:

ddrescue does those things, but it has no knowledge of the volume structure, so it can't save just the allocated sectors. But it does support using a "domain mapfile" to denote the sectors to read. This commit adds a -D option to ntfsclone that writes a domain mapfile covering the allocated sectors.

partclone can also write a domain mapfile, but it only looks at $Bitmap, so if there are allocated clusters not in the bitmap (which I've found to be oddly common) it won't save all the data. (Also it has other problems with NTFS.) The unmaintained ddrutility package can also write a domain mapfile, but it's unmaintained.

I can't recommend merging this. The way I implemented this is pretty dumb, so after walking the volume, ntfsclone spends nearly all of its time in lseek (once seeking to where it wants to read, then calling it again to get the current file position). Adding another mode also adds more tricky conditionals to a program already full of them. A "proper" implementation would or any extra allocated clusters into the main bitmap and just scan through it. But this may still be useful to others.

Neustradamus commented 1 year ago

@jpandre: Have you looked this PR?