I have a broken hard drive with many corrupted blocks. I perform rescue with ddrescue quite successfully (I am on 99,5 %). Unfortunately:
ddrescue hits badly damaged part, the disk "goes crazy" and either returns only read errors for the rest of the disk or reports unaligned read error and terminates; the computer needs to be restarted and those parts can be read again.Funny thing: I do not need to read the partition table at all, I am performing a "whole disk" rescue.
So is there a way how to tell the kernel
System startup speedup will increase recovery speed dramatically because in this phase the system starts for an hour, then continues in recovery for several minutes and then restarts due to one of errors mentioned above (I have automated this by startup script).
dmesg output: https://cloud.oprendek.sk/index.php/s/Mk8figkaspD8xRE
I feel like I answered this before but can't find it at the moment...
If your issue persists not only during the initial bootup but also when hotplugging the offending drive to an already running system, then you're more or less out of luck.
In a full Linux install you pretty much can't prevent a drive getting scanned for partitions, UUIDs and other metadata, every time you connect it. The kernel detects partition tables, udev creates disk/by-uuid links, and so on.
However, partition table support is optional in kernel (CONFIG_*_PARTITION, * being one of MSDOS, EFI, MAC, ...). So you could compile a custom kernel that doesn't support any / disables all of them, and then (to also prevent UUID scanning and the like) use it with a minimal initramfs environment that contains ddrescue only.
This also disables you from accessing partitions on any of your other drives unless you emulate it with losetup and offset / sizelimits, or alternatively the device mapper (dmsetup). So you'll have to work around the lack of partitions as a whole.
- to limit the number of retries?
Not sure if it does any retries, what you can do is set timeouts (in /sys/block/*/device/timeouts) which would only be useful if the drive isn't responding at all, I guess.
For built-in non-removable devices, you could also make use of libata.force=<port.device>:disable kernel parameter to disable it entirely.
dmesg output, unfortunately, ddrescue runs automatically so it contains also errors from ddrescue run, not only startup errors. - Michal Oprendek