If you know the array component devices, you can simply issue something as
mdadm --zero-superblock /dev/sd[abcd]
to remove the superblock from multiple devices with a single command.
Please note that mdadm
checks for superblock before zeroing anything, so specifying sd*
in the command above should only touch component disks, without writing anything to the others. However, I strongly suggest against doing that: any issues in the superblock detection routing, or using --force
, are going to overwrite good data on non-component disks (causing data loss). From the man page:
If the device contains a valid md superblock, the block is overwritten
with zeros. With --force the block where the superblock would be is
overwritten even if it doesn't appear to be valid.
For the reason above, if you don't know the array component devices I suggest listing them via
blkid -t TYPE="linux_raid_member" -o device
and then zeroing the specific disks with mdadm --zero-superblock
. This can be scripted with a single-line bash command:
for dev in `blkid -t TYPE="linux_raid_member" -o device`; do echo "zeroing $dev"; mdadm --zero-superblock $dev; done
As always, triple-check any such commands to avoid data loss.
EDIT: to discover the array component devices without resorting to parsing of mdadm --detail
output, you can use lsblk
. For example, on a test array created via loop
devices:
# lsblk -l -n -s /dev/md127
md127 9:127 0 255M 0 raid1
loop5 7:5 0 256M 0 loop
loop6 7:6 0 256M 0 loop
--zero-superblock
on the partitions or drive by hand. Or depending on the requirement, I dopv /dev/zero > /dev/sdXXX
to simply erase the entire drive. And then I just know which drives they were. Do you need to do this so often that a one-time manual operation does not suffice?mdadm --details ...
feels a bit fragile.