PDA

View Full Version : Fix HDD with uncorrectable sectors so they are isolated and i can read/write to HDD?



Fli
08-28-2016, 08:41 AM
Hello,

usually when one see he cant read/write data to HDD, one can display SMART data for that HDD (Crystal Disk Info) and if there is pending sector count, one can right click drive, go to Properties/Tools and do filesystem check to cure pending sectors.

Offline uncorrectable means problem with drive, if the count is above 200 one can experience data loss (canot read or write some sectors). If HDD is in warranty, return drive to the seller for replacement or contact local branch of the HDD vendor.

How to fix drive so bad / offline uncorrectable sectors are isolated and not used for writing data?

Here are some useful resources:

http://hdrecover.sourceforge.net/ - Attempts to recover a hard disk that has bad blocks on it.
http://www.dposoft.net/rbd.html - utility ... intended to isolate unrecoverable bad sectors from partitions.
http://www.sj-vs.net/forcing-a-hard-disk-to-reallocate-bad-sectors/ - manually reallocate bad sectors

Fli
10-23-2020, 09:59 AM
I have fixed one unbootable drive with several uncorrectable and pending sectors. The symptoms were:


[ 582.378180] print_req_error: critical medium error, dev sdc, sector 261314564
[ 582.378182] Buffer I/O error on dev sdc2, logical block 4, async page read
[ 584.270037] sd 11:0:0:0: [sdc] tag#0 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[ 584.270045] sd 11:0:0:0: [sdc] tag#0 Sense Key : Medium Error [current]
[ 584.270048] sd 11:0:0:0: [sdc] tag#0 Add. Sense: Unrecovered read error
[ 584.270052] sd 11:0:0:0: [sdc] tag#0 CDB: Read(10) 28 00 0f 93 58 04 00 00 01 00

This is what i did on Linux (not have?, try live bootable USB Linux):

- sdX is my faulty drive, replace by yours, see "lsblk" or "fdisk -l"
- Do this on your risk and possibly backup by "ddrescue" or other SW if drive contains precious data not backed up elsewhere.

$ sudo badblocks -vs /dev/sdX > 160GB_badblocks_bad_sectors
$ cat 160GB_badblocks_bad_sectors


83416588
83416589
83416590
83416591
130657280
130657281
130657282
130657283

$ smartctl -a /dev/sdX



...shown 2 pending sectors, 4 offline uncorectable...

$ for block in $(cat 160GB_badblocks_bad_sectors);do sudo dd if=/dev/zero of=/dev/sdb bs=1024 count=1 seek=$block;done
(bs=1024 is necessary since this is value used by badblocks)


1+0 vstoupivších záznamů
1+0 vystoupivších záznamů
1024 bajtů (1,0 kB, 1,0 KiB) zkopírováno, 4,59708 s, 0,2 kB/s
1+0 vstoupivších záznamů
1+0 vystoupivších záznamů
1024 bajtů (1,0 kB, 1,0 KiB) zkopírováno, 0,0149379 s, 68,6 kB/s
1+0 vstoupivších záznamů
1+0 vystoupivších záznamů
1024 bajtů (1,0 kB, 1,0 KiB) zkopírováno, 0,00450658 s, 227 kB/s
1+0 vstoupivších záznamů
1+0 vystoupivších záznamů
1024 bajtů (1,0 kB, 1,0 KiB) zkopírováno, 0,00585185 s, 175 kB/s
1+0 vstoupivších záznamů
1+0 vystoupivších záznamů
1024 bajtů (1,0 kB, 1,0 KiB) zkopírováno, 0,00143635 s, 713 kB/s
1+0 vstoupivších záznamů
1+0 vystoupivších záznamů
1024 bajtů (1,0 kB, 1,0 KiB) zkopírováno, 0,000484465 s, 2,1 MB/s
1+0 vstoupivších záznamů
1+0 vystoupivších záznamů
1024 bajtů (1,0 kB, 1,0 KiB) zkopírováno, 0,0451608 s, 22,7 kB/s
1+0 vstoupivších záznamů
1+0 vystoupivších záznamů
1024 bajtů (1,0 kB, 1,0 KiB) zkopírováno, 0,00502066 s, 204 kB/s

after that, "smartctl -a /dev/sdX" shows 0 pending sectors and 4 uncorrectable => like the writing succeeded and caused to mark 2 pending blocks as OK.

I then did short drive test: sudo smartctl -t short /dev/sdX
and after 2 minutes found in "sudo smartctl -a /dev/sdX" output that this test found no read errors unlike the test i have ran before writing to the sectors using "dd":


Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Short offline Completed without error 00% 19684 -
# 2 Extended offline Completed: read failure 90% 19684 166833180
# 3 Short offline Completed: read failure 90% 19684 166833180


full SMART:

ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x002f 200 200 051 Pre-fail Always - 2449
3 Spin_Up_Time 0x0027 137 133 021 Pre-fail Always - 4108
4 Start_Stop_Count 0x0032 099 099 000 Old_age Always - 1817
5 Reallocated_Sector_Ct 0x0033 200 200 140 Pre-fail Always - 0
7 Seek_Error_Rate 0x002e 100 253 000 Old_age Always - 0
9 Power_On_Hours 0x0032 074 074 000 Old_age Always - 19684
10 Spin_Retry_Count 0x0032 100 100 000 Old_age Always - 0
11 Calibration_Retry_Count 0x0032 100 100 000 Old_age Always - 0
12 Power_Cycle_Count 0x0032 099 099 000 Old_age Always - 1768
192 Power-Off_Retract_Count 0x0032 200 200 000 Old_age Always - 145
193 Load_Cycle_Count 0x0032 200 200 000 Old_age Always - 1671
194 Temperature_Celsius 0x0022 105 095 000 Old_age Always - 38
196 Reallocated_Event_Count 0x0032 200 200 000 Old_age Always - 0
197 Current_Pending_Sector 0x0032 200 200 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0030 200 200 000 Old_age Offline - 4
199 UDMA_CRC_Error_Count 0x0032 200 200 000 Old_age Always - 0
200 Multi_Zone_Error_Rate 0x0008 200 200 000 Old_age Offline - 4

and the drive is booting OS without any apparent issue and dmesg command does not look like showing any related issue. Thank you for help solving this. Feedback welcome.