Wednesday, August 29, 2018

Device Not Found when Removing HDD from mdadm RAID

I have encountered a case when I'm trying to fail and remove a disk from a mdadm RAID array using the following two commands:
  • mdadm --manage /dev/md1 --fail /dev/sdf --remove /dev/sdf
  • mdadm /dev/md1 --fail /dev/sdf --remove /dev/sdf
I encountered error "device not found".

Looking at the Disks (gnome-disks), the device /dev/sdf is still shows as a member of RAID /dev/md1.


What is the solution?

After examine using both:
  • mdadm --detail /dev/md1
  • cat /proc/mdstat
Confirming that /dev/sdf is not currently active in the RAID array, I execute mdadm --zero-superblock /dev/sdf. This reset the HDD and now it appears as an empty disk in Disks (gnome-disks).

I can then re-add the HDD to the array again as a spare unit, mdadm --add /dev/md1 /dev/sdf.