On Sat, Jan 11, 2025 at 12:11:39PM +0100, Roger Price wrote:
I am unable to erase an unwanted RAID 1 array. Command cat /proc/mdstat
reported
md4 : active raid1 sdb7[0]
20970368 blocks super 1.0 [2/1] [U_]
bitmap: 1/1 pages [4KB], 65536KB chunk
I understand that the array has to be inactive before it can be removed, so I
stopped it, but was not able to remove the array
root@titan ~ umount /dev/md4
root@titan ~ mdadm --misc /dev/md4 --stop
This is incorrect syntax, and a no-op (so the array did not stop). You
want `mdadm --misc --stop /dev/md4`. The --misc is implied so you can
just use `mdadm --stop /dev/md4`
root@titan ~ mdadm --manage /dev/md4 --remove /dev/sdb7
mdadm: hot remove failed for /dev/sdb7: Device or resource busy
This won't work and isn't necessary. (If md4 is actually stopped, it'll
say that it md4 doesn't exist. If md4 isn't stopped you'll get the
message above because you can't remove an active drive from an array.)
The command ps -ef | grep md4 reports
root 211 2 0 Jan09 ? 00:00:00 [md4_raid1]
I assume process 211 is keeping md4 busy. Do I have to kill process 211 or is
there some more elegant way? Or is it mdadm itself in process 663 which is
keeping md4 busy?
That's the kernel thread associated with the raid device. You can
not/should not kill it. (The [] and the fact that the parent pid is 2
are indicators that it is a kernel thread.)
To remove the raid device you want to check the details `mdadm -D
/dev/mdX` then stop it `mdadm -S /dev/mdX` and then zero the information
on the devices identified in the details, something like `mdadm
--zero-superblocks /dev/sdXN /dev/sdYN`. If the stop step fails you can
try `fuser /dev/mdX` and `fuser -m /dev/mdX` to identify why, as well as
`grep mdX /proc/mounts`