Removing one mdraid device/partition is quite easy. This process should not require reboot (but it is still recommended). Note: this process will make your data unreadable
Step 1: Identify the RAID device Link to heading
First, you need to identify the RAID device that you want to remove. You can list all RAID devices using the following command:
Note down which RAID device (mdX) you want to remove. Also note its disk partitions (you can also list them using the
Step 2: Unmount the RAID partition (if mounted) and edit /etf/fstab Link to heading
If the to-be-removed-device contains any partition currently mounted to your system, unmount it.
sudo umount /partition
Now remove the partition from
/etc/fstab so it the system won’t try to mount it after the next reboot.
Step 3: Stop the RAID Device and remove it from /etc/mdadm/mdadm.conf Link to heading
Now stop the RAID device using the mdadm tool.
sudo mdadm --stop /dev/mdX
Now edit the mdadm config file (
/etc/mdadm/mdadm.conf) and remove the device from there.
Step 4: Remove the RAID Device Link to heading
You can remove the RAID device
sudo mdadm --remove /dev/mdX
Note: if this won’t command gives an error about non-existing device, reboot the system and remove the raid afterwards.
Step 5: Remove RAID superblocks Link to heading
Now you should zero the superblocks on the individual disks that were part of the RAID. This can prevent them from being automatically reassembled into a RAID array in the future. Remember - you do this on the disk partitions (/dev/sdX) and NOT on the RAID device (/dev/mdX).
sudo mdadm --zero-superblock /dev/sdX1 /dev/sdX2
Optional: overwrite disks with random data Link to heading
If you want to remove the data, you can rewrite it using
dd if=/dev/urandom bs=4096 of=/dev/sdX
Note: you can use /dev/random on the systems like Debian 11+ and Ubuntu 22.04+.