I have a broken hard drive with many corrupted blocks. I perform rescue with ddrescue quite successfully (I am on 99,5 %). Unfortunately:

  • For some reason, sometimes but not always when 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.
  • First block containing partition table is broken and system startup takes about an hour when the kernel retries to read the partition table again and 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

  • not to read the partition table or
  • to limit the number of retries?

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.

  • "This also disables you from accessing partitions" – Does not work for me, I back up to a file. I imagine ti could work but it seems to be a lot of work and expertise I do not have. – Michal Oprendek Apr 16 '20 at 9:33
  • "Not sure if it does any retries" – the system writes many errors to output for about an hour and then starts for some reason. I interpret it as attempts to read the partition table. So either the first block is finally read (not probable – no partitions are detected even after system started), or there is some retry-until condition I would like to modify. I do not have dmesg output because it is quite hard to "catch" a running system, but I will try to provide one. – Michal Oprendek Apr 16 '20 at 9:44
  • "libata.force=<port.device>:disable" – tried, but then the disk is not accessible at all (no /dev/sdb). – Michal Oprendek Apr 16 '20 at 9:47
  • "If your issue persists not only during the initial bootup but also when hotplugging the offending drive to an already running system" – I tried to hotplug, but I suppse the board does not support it because nothing happened (no dmesg output). – Michal Oprendek Apr 16 '20 at 9:48
  • I included link to dmesg output, unfortunately, ddrescue runs automatically so it contains also errors from ddrescue run, not only startup errors. – Michal Oprendek Apr 16 '20 at 10:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.