sg3_utils
sg3_utils copied to clipboard
sg_dd adaptive bpt during "Medium, hardware or blank check error but no lba of failure in sense" errors
When using sg_dd to recover data from error prone older SCSI devices, e.g.
sg_dd retries=6 coe=1 bs=256 bpt=128 if=/dev/sg2 of=image.dd
sg_dd will prematurely terminate the copy with "Medium, hardware or blank check error but no lba of failure in sense" when bpt > 1. Setting bpt=1 lets sg_dd complete copying the whole disk, but about 140x slower. Setting coe=2, as expected, does not alter the outcome as the underlying failure produces the same unhelpful sense data.
I started trying to add some logic to enable dynamically changing the bpt in response to these conditions. Though I'm not sure how much that would break things throughout, hoping for some guidance as to where that would be easy to do or hard to do. At this point I'd settle for if that error is encountered, the BPT is dumbed down to 1 for the next retries until the the next BPT boundary is crossed to honor sectors / track. A more elaborate version would float the value up / down depending on the health of the media as seen in the retry count.