share
Unix & LinuxSkip / shorten partition table reading on broken disk
[0] [1] Michal Oprendek
[2020-04-16 07:36:05]
[ linux hard-disk data-recovery partition-table ]
[ https://unix.stackexchange.com/questions/580407/skip-shorten-partition-table-reading-on-broken-disk ]

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

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

(1) Does this answer your question? Prevent Linux Probing for Partitions - Reinstate Monica
[0] [2020-04-16 08:07:19] frostschutz

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
"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
"libata.force=<port.device>:disable" – tried, but then the disk is not accessible at all (no /dev/sdb). - Michal Oprendek
"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
I included link to dmesg output, unfortunately, ddrescue runs automatically so it contains also errors from ddrescue run, not only startup errors. - Michal Oprendek
"I back up to a file" - dd it to a new drive and you back up to a drive. That or use losetup --offset to emulate the partition (you have to know the offset). For hotplug you sometimes have to enable it in bios. There is not much else I can suggest, sorry - frostschutz
(1) @frostschutz: Would you take a look at my answers to unix.stackexchange.com/a/691138/240014 - it's a kernel module to temporarily disable partscan. - Reinstate Monica
@frostschutz Also I flagged the duplicate where you answered this before (but I flagged it as a dupe of the question linked in my first comment) unix.stackexchange.com/a/558039/240014 - Reinstate Monica
1