Whatever you are trying to do, it does not sound like a good idea. In order to know where the bad blocks are, it has to read all the good blocks; and if you get any data off a dying drive, then you want to keep it - in which case, you are done, you have your data, toss out the dead disk before you hurt someone.
Bad blocks don't read. That's the definition. If you can read them, they aren't bad. I think what you are trying to do is learn where the bad blocks are, then create a file with blank data there, so you won't get an error when you try to read the file. In which case, there's a much easier way to do that - just try to read the file with ddrescue. ddrescue /mnt/path/to/file/with/errors /home/recovered/savedfile /home/recovered/savelogfile . When it has finished, you'll have a file containing all the data you can recover, and blocks of zeros where you can't. If you don't have a disk large enough to recover the whole disk, but you do have one large enough to store just the data, look at ddrutility, and the ddru_ntfsbitmap. You use it to create a domain file that you pass to ddrescue with the -m option, and it will only read used blocks. This means that, with sparse writes, you only need enough space to hold the data stored on the drive to do the recovery. Now, there are ways to tell the hard drive to return whatever it can when it comes to a read error, but the information on how to do this - things like connecting a RS-232 (maybe at TTL-levels) to a diagnostic port and sending the drive commands, of sending proprietary (i.e. things the manufacturer doesn't want to tell you) commands over the ATA bus - and is beyond the scope of ddrescue. If anyone does know more about these sort of things, this mailing list is all ears. The ability to turn off all retries for the first pass, and then return best-effort erroneous data for a last pass, would be a really nice trick. (hmm, just reading the documentation on ddru_diskutility - that looks like it may be worth investigating.) On 1 August 2017 at 16:57, Ole Tange <ta...@gnu.org> wrote: > I have said it before, but it cannot be repeated too often: Thanks you > for ddrescue. > > This summer I had to rescue files from a broken disk. I did not have a > same or bigger sized disk with me. > > It would have been really handy if I could have copied the bad sectors > onto a sparse file, then overlayed the device with the sparse file, > mounted it, and copied the files off the disk: > > mknod -m 660 /dev/loop1 b 7 1 > size=$(blockdev --getsize /dev/baddevice); > truncate -s$size overlayfile > ddrescue --onlybadblocks /dev/baddevice overlayfile mylog > loop=$(losetup -f --show -- overlayfile); > echo 0 $size snapshot /dev/baddevice $loop P 8 | dmsetup create baddevice > mount /dev/mapper/baddevice > > I would imagine all you have to do is ignore the blocks that succeeds > reading in the first try, and do as normal for all the rest. > > > /Ole > > _______________________________________________ > Bug-ddrescue mailing list > Bug-ddrescue@gnu.org > https://lists.gnu.org/mailman/listinfo/bug-ddrescue > _______________________________________________ Bug-ddrescue mailing list Bug-ddrescue@gnu.org https://lists.gnu.org/mailman/listinfo/bug-ddrescue