Readme for ddrescue-1.19 SGIO patch-2.1 20150106
This patch currently works on ddrescue-1.19. It will not work on older
versions, and most likely not work on newer versions.
WARNING! There is absolutely no warranty with this patch. Use at your own risk!
This patch is meant for advanced users. There were features that I wanted for
personal use in ddrescue, so that is how this patch came into existance. I have
just decided to share it.
This patch will only work with on Linux at this time. You need to run the
ddrescue configure with the --enable-linux option to enable the passthrough
ability. If this patch is applied to ddrescue on a non-Linux system, it should
still compile as long as you don't use the --enable-linux option, and you would
just have normal ddrescue.
I do not recommend using the passthrough options on a USB connected drive. The
ata-passthrough should not work as the drive will not be recognized as ATA. But
the scsi-passthrough will likely work. The reason that I do not recommend using
the passthrough options (or ddrescue for that matter) on a USB connected device
is that personal testing with different devices and adapters has shown some
unpredictability in getting reliable data. If at all possible, you should
connect the drive directly to the computer. So you have been warned!
While I do extensive testing to make sure that this patch is stable and
accurate, it is always possible that the use of passthrough commands could have
undesired results (although it seems to work good for me!). You should not use
the passthrough option on a mounted device (you shouldn't be running ddrescue
on a mounted device anyway). It is also possible (although unlikely) that this
patch could break something in ddrescue, and is NOT supported by the author of
ddrescue in any way at this time.
To use this patch, put the whole patch folder in the ddrescue source folder.
Then navigate to the patch folder and execute "_patch.sh". Navigate up one
directory back to the ddrescue source, and then you can then run "make clean",
"make" and "make install" as normal to install ddrescue. Notice the addition of
"make clean", as this may be needed for the changes to take effect.
If the patch fails, it will restore the original files from backup. If it is
ran a second time on an already patched ddrescue, it will fail and therefore
revert back to stock ddrescue. So you can switch back and forth with this
patch.
This patch currently adds two options to perform SGIO passthrough reads,
--scsi-passthrough and --ata-passthrough. These bypasses the normal reads, and
send a more direct command to the disk. This has the benefit of skipping the
normal excessive read retries the kernel does when it encounters an error. It
also seems to help prevent it from switching to a slower read speed after read
errors, although testing shows it does not always completely prevent it. Note
that this may not work on all systems, and may not work on all drives.
This patch also adds a third option that can be used with the passthrough
options, --mark-abnormal-error. Normally (when using the passthrough) when an
error other than a normal read error happens (drive stops responding), ddrescue
will exit and the last read attempt is not logged in the logfile. Using the
--mark-abnormal-error option will mark the last read attempt as non-trimmed in
the logfile before exiting (if only one sector is being read then it will be
marked as bad). This is meant for the rare situation where a drive locks up
when bad sectors are read. Note that this option only works when using one of
the passthrough options.
The --scsi-passthrough translates the SCSI commands into the best commands for
the drive and will bypass some or most of the kernel retries. The
--ata-passthrough is a more direct approach with added benefits, but only works
on directly connected drives and will not work on USB drives. If
--ata-passthrough is selected the device is checked to see if it is ATA, and if
it isn't then it will exit with an error message.
One of the big benefits of the ata-passthrough is that when a block read fails,
the number of the first bad sector can be known. So it has been designed it so
that if the first read attempt fails, it will then once retry the read up to
that reported bad sector. This will allow the reading of more data in the
initial copying phases, and also allow the proper marking of that bad sector so
that it is not tried again in the triming or scraping phase. This can greatly
speed up a recovery.
There is a second possible benefit to the passthrough options. When an abnormal
error happens (other than a normal read error), ddrescue will exit. It is
possible under some circumstances that this would exit where using normal reads
would not. This could have the benefit of stopping when a drive locks up,
instead of ddrescue suddenly marking all the drive as bad.
A special note about the passthrough option: It only works on a whole drive,
and not an individual partition. There is a safeguard in place to prevent this
if the option is turned on. This is because when using the direct passthrough
commands, the kernel treats any reference to the drive as the whole drive. And
if you supplied a partition, the data returned would start from the beginning
of the disk and not the partition, which would give you incorrect data and you
would end up scratching your head wondering what the hell went wrong with the
recovery.
Another note about the passthrough option is that there is normally a cluster
limit of 1024 (with 512 byte sector). There is a limit stored at
/sys/block/DEVICE/queue/max_sectors_kb, where "DEVICE" is the device you are
reading (example "/sys/block/sda/queue/max_sectors_kb"). The number stored here
is referenced in KB, and the default for a hard drive is usually 512 (meaning
512KB). This number is smaller for a USB connected drive.
After successfully applying the patch, you can see the new options using the
"--help" command with ddrescue. But you will not find any information in the
ddrescue manual, as they are not supported. The new options will have the patch
version number at the end of the descriptions.
Changlog:
ddrescue-1.19 SGIO patch-2.0 20141007
Initial release for ddrescue 1.19
ddrescue-1.19 SGIO patch-2.1 20150108
Added code so that if an error other than a normal read error happens,
ddrescue will now properly exit saving the most recent changes to the logfile.
The previous version exited abruptly without saving the logfile.
Added the option --mark-abnormal-error, so when an abnormal error happens
during a read attempt (that causes program exit) the cluster is marked as
non-trimmed. A single sector read (clustersize 1) would result in the sector
being marked as bad.
Added short sense key definitions to abnormal error output.