forcing rewrite of one of mdadm raid1 disks

on not so important server i got an alert about SMART errors and failing weekly surface test [ smartctl -d sat -t long /dev/sdb ].

i wanted to force the drive to re-allocate bad sectors; i could not read it anymore – cat /dev/sdb > /dev/null would fail with read errors. i remember reading somewhere that drive will mark bad sectors and on attempt of rewriting them – will use reserved capacity and re-allocate them. so i’ve forced the data to be rewritten by:

#removing write intent - to force full rewrite of the drive
mdadm --grow /dev/md0 --bitmap=none
#failing and removing problematic partition from my raid1
mdadm --manage --set-faulty /dev/md0 /dev/sdb2
mdadm --manage /dev/md0 -r /dev/sdb2
#adding it again which forces rewrite based on the other drive in this RAID1
mdadm --manage /dev/md0 --add /dev/sdb2
#re-enabling write intent bitmap
mdadm --grow --bitmap=internal /dev/md0

interestingly – it worked; i can cat /dev/sdb > /dev/null without errors. obviously this drive will be replaced anyway.

Leave a Reply

Your email address will not be published. Required fields are marked *

(Spamcheck Enabled)