Resetting mdadm RAID on Ubuntu 22.04

A short record of resetting RAID disks with mdadm on Ubuntu 22.04, including stopping the array, clearing metadata, rescanning disks, and the main risk points.

Reset Procedure

Stop the RAID array first:

1
sudo mdadm --stop /dev/md0

Clear the superblock information from the member disks. Replace the device names with the disks that actually belong to your array:

1
2
sudo mdadm --zero-superblock /dev/sdb
sudo mdadm --zero-superblock /dev/sdc

If the disks were previously partitioned or still contain old filesystem signatures, wipe the signatures as well:

1
2
sudo wipefs -a /dev/sdb
sudo wipefs -a /dev/sdc

Reload partition information and check the current block devices:

1
2
3
sudo partprobe
lsblk
cat /proc/mdstat

After confirming that no old array is active, create the RAID array again according to the desired level and disk list:

1
sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdc

Finally, save the new array configuration:

1
2
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
sudo update-initramfs -u

Before running destructive commands such as --zero-superblock or wipefs -a, verify the disk names carefully. These commands remove RAID or filesystem metadata and can make existing data inaccessible.

记录并分享
Built with Hugo
Theme Stack designed by Jimmy