Bad sector removal (hdparm) - How to remove bad sectors?

| F.A.Q.

Usuwanie bad sektorów (Hdparm) - Jak usunąć bad sektory?

Example error:

Jan 29 18:19:54 dragon kernel: [66774.973049] end_request: I/O error, dev sdb, sector 1261069669

Check the list of sectors to be transferred and transferred (S.M.A.R.T 5 and 196 - should be equal)

smartctl -a /dev/sdb | grep -i reallocated

 5 Reallocated_Sector_Ct   0x0033   151   151   140    Pre-fail  Always       -       0
 196 Reallocated_Event_Count 0x0032   001   001   000    Old_age   Always       -       0
 
 0 na końcu oznacza że nie ma relokowanych sektorów na dysku.

Checking if the sector is really damaged

$ hdparm –read-sector 1261069669
/dev/sdb: Input/Output error

If there is no Input/Output error (reading sector 1261069669: succeeded) means that the sector is undamaged.

Recording of the damaged sector (data will be lost)

hdparm –write-sector 1261069669 /dev/sdb

Confirmation of enrollment

hdparm –write-sector 1261069669 –yes-i-know-what-i-am-doing /dev/sdb

Checking if S.M.A.R.T has moved the bad sectors

  $ smartctl -a /dev/sdb | grep -i reallocated
5 Reallocated_Sector_Ct   0×0033   100   100   005    Pre-fail  Always       -       2
  196 Reallocated_Event_Count 0×0032   100   100   000    Old_age   Always       -       2

Related pages:

  1. Linux Tools - dd
  2. Linux tools - Hdparm - (Disk management and bandwidth testing).
  3. Bad sector removal (hdparm) - How to remove bad sectors?