Question: I try to reallocate a bad sector. After reading this Question my understanding is, that the hard-drive tries to reallocate automatically. To trigger the process I tried to write to the sector with dd but nothing changed at all.
$ smartctl -a /dev/sda…5 Reallocated_Sector_Ct ?… ?0197 Current_Pending_Sector ?… ?1…
The bad sector is: 215040
$ dd if=/dev/sda of=/dev/null bs=512 count=1 skip=215040io-error on reading
Why is the sector not allocated when I write to it?
$ dd if=/dev/zero of=/dev/sda bs=512 count=1 seek=215040io-error on writing
How can I cause the sector to be rewritten?
Answer: Try a low-level write using hdparm:
sudo hdparm –yes-i-know-what-i-am-doing –write-sector 215040 /dev/sda
where 215040 is the sector number you want to overwrite (and possibly remap) and /dev/sda is the device to which you want to write.
From the hdparm man page:
?
–write-sector
?
Writes zeros to the specified sector number. VERY DANGEROUS. The sector number must be given (base10) after this flag. hdparm will issue a low-level write (completely bypassing the usual block layer read/write mechanisms) to the specified sector. This can be used to force a drive to repair a bad sector (media error).