Re: Need help to recover root filesystem after a power supply issue

Andrey Zhunev
2019-07-11T07:10:27Z

Thursday, July 11, 2019, 5:47:36 AM, you wrote:

> On 11/07/2019 01.43, Andrey Zhunev wrote:
>>
>> Ok, the ddrescue finished copying whatever it was able to recover.
>> There were many unreadable sectors near the end of the drive.
>> In total, there were over 170 pending sectors reported by SMART.
>>
>> I then ran the following commands:
>>
>> # smartctl -l scterc,900,100 /dev/sda
>> # echo 180 > /sys/block/sda/device/timeout
>>
>> But this didn't help at all. The unreadable sectors still remained
>> unreadable.
>>
>> So I wiped them with hdparm:
>> # hdparm --yes-i-know-what-i-am-doing --write-sector <sector_number> /dev/sda

> This has always eluded me. How did you know the sector numbers?

When you use ddrescue (or any other tool) to try and read the data
and there is a read error, an error message is added to your kernel
log. You can find the sector number there:

Jul 10 11:56:01 mgmt kernel: blk_update_request: I/O error, dev sda, sector 157804112

You can then try to re-read that specific sector with:

# hdparm --read-sector 157804112

If that one still gives an error - then you're sure you can wipe it.

> At this point, I typically take the brutal approach of overwriting the
> entire partition (or disk) with zeroes using dd, which works as a
> destructive write test ;-)

> Previous to that, I attempt to create an image with ddrescue, of course.

>>
>> I then re-read all these sectors, and they were all read correctly.
>>
>> The number of pending sectors reported by SMART dropped down to 7.
>> Interestingly, there are still NO reallocated sectors reported.

> I suspect that the figure SMART reports only starts to rise after some
> unknown amount of sectors have been remapped, so when the numbers
> actually appear there, it is serious.

Hmmm, this is an interesting thought!
Everybody lies... :)

---
Best regards,
Andrey