summaryrefslogtreecommitdiff
path: root/00_blog/00015_Admin/00030_Fixing-HDD/index.md
blob: 0bae7300193f1828e4ffbf4cb261e1a1890a9f8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# 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