www.idziorek.net | blog | contact

Fixing HDD after Free Falling

So you also dropped your hard-disk and some of your secotrs got damaged, probably by the head hitting the platter?

Backup all your data.

smartctl

Try from fastest to slowest to find faulty sector: replace LBAi_START,LBA_END with meaningful values.

smartctl -t [long|conveyence|short|select,LBA_START-LBA_END] -C /dev/sda 

hdparm

Bi-search via –read-sector if complete ranges are affected (as in my case) and then fix them in one step:

for i in {36312851..36312886}; do hdparm --write-sector $i /dev/sda; done

Example

Exemplary session fixing one sector:

WARNING: this will destroy your data !

1)  # smartctl -a /dev/sda | egrep 'Pend|Real|Offline_Unc'

  5 Reallocated_Sector_Ct   0x0033   100   100   036    Pre-fail  Always       -       4
197 Current_Pending_Sector  0x0012   098   098   000    Old_age   Always       -       47
198 Offline_Uncorrectable   0x0010   098   098   000    Old_age   Offline      -       47

2)  # smartctl -t short /dev/sda

3)  # smartctl -l selftest /dev/sda

[...] 1  Short offline       Completed: read failure       90%     10632         152076520

4)  # hdparm --read-sector 152076520 /dev/sda  # verification

[...] reading sector 152076520: FAILED: Input/output error

5)  # hdparm --write-sector 152076520 /dev/sda 

6)  # smartctl -a /dev/sda | egrep 'Pend|Real|Offline_Unc'

  5 Reallocated_Sector_Ct   0x0033   100   100   036    Pre-fail  Always       -       4
197 Current_Pending_Sector  0x0012   098   098   000    Old_age   Always       -       46
198 Offline_Uncorrectable   0x0010   098   098   000    Old_age   Offline      -       46