Table of Contents

LINUX: How to erase single block on HDD

This is useful, when you find bad block using SMART disk monitoring. Script overwrites block ID 9454180* on device /dev/sdX* and after this operation HDD controller can reallocate this 512byte block to spare reserved part of disk.
This may destruct content of this block of course!

# dd bs=512 count=1 conv=noerror ibs=512 obs=512 if=/dev/sdX of=/dev/sdX iflag=direct,sync oflag=direct,sync skip=9454180 seek=9454180

To find this block please run smartctl -tlong /dev/sdX* and wait some hours to complete test. Check it by running smartctl -a /dev/sdX* and you can find lines as

197 Current_Pending_Sector  0x0032   200   200   000    Old_age   Always       -       1
...
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Extended offline    Completed: read failure       90%     20211         9454180

* modify by your values

Results

After this operation, output from smartctl may look like

196 Reallocated_Event_Count 0x0032   200   200   000    Old_age   Always       -       1*
197 Current_Pending_Sector  0x0032   200   200   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   200   200   000    Old_age   Offline      -       0
...
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Extended offline    Completed without error       00%     21749         -

* Reallocated_Event_Count shows zero after some time

Read disk

dd if=/dev/sdX bs=1M of=/dev/null