Re-adding failed drive in mdadm

Yesterday I have problem with fglrx witch cause ugly system reset. After that, one of my drives was marked as failed in RAID5 array. Hotspare was automatically used to rebuild array. But this hotspare is the oldest and slowest drive I’ve got…
After rebuild I’ve tested failed drive and it was fine – no bad block, no any other issue – so I wanted it running back in array.

What I do:

  • I’ve added checked disk to array as spare
    mdadm /dev/md0 -a /dev/sdb1
  • I’ve  set this “slow” drive as failed (and rebuild started)
    mdadm /dev/md0 -f /dev/sdf1
  • I removed this drive
    echo 1 > /sys/block/sdf/device/delete
  • I run dmesg to see what was scsi host of this drive
    # dmesg
    [ 1302.433419] sd 8:0:0:0: [sdf] Synchronizing SCSI cache
    [ 1302.433468] sd 8:0:0:0: [sdf] Stopping disk
  • Now I could readd this drive
    echo "- - -" > /sys/class/scsi_host/host8/scan
  • I run dmesg  again to see if disk was detected
    # dmesg
    [ 1489.013270] scsi 8:0:0:0: Direct-Access     ATA      SEAGATE ST2000DM001  1AQ1 PQ: 0 ANSI: 5
    [ 1489.013375] sd 8:0:0:0: [sdf] 3907029168 512-byte logical blocks: (2.00 TB/1.81 TiB)
    [ 1489.013397] sd 8:0:0:0: Attached scsi generic sg6 type 0
    [ 1489.013445] sd 8:0:0:0: [sdf] Write Protect is off
    [ 1489.013447] sd 8:0:0:0: [sdf] Mode Sense: 00 3a 00 00
    [ 1489.013466] sd 8:0:0:0: [sdf] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
    [ 1498.318159]  sdf: sdf1
    [ 1498.318391] sd 8:0:0:0: [sdf] Attached SCSI disk
  • Now I could re-add this drive to the array as spare
    mdadm /dev/md0 -a /dev/sdf1