When dealing with former MD RAID arrays, residual superblocks can cause unexpected device binding during system boot. This occurs even after repartitioning disks for new purposes like btrfs or swap space. The system continues to recognize these disks as RAID members due to remaining metadata.
MD RAID superblocks can exist in multiple locations depending on the RAID version and creation parameters:
- At the end of the device (version 0.90)
- At the beginning of the device (version 1.x)
- 4K from the start (default for --metadata=1.2)
To clear superblocks without affecting existing partitions:
# First identify all potential RAID members
mdadm --examine --scan
# For each affected device (e.g., /dev/sdX)
mdadm --zero-superblock /dev/sdX
# Verify removal
mdadm --examine /dev/sdX
When disks contain valuable partitions, we need more surgical approaches:
# Method 1: Targeted superblock erasure (metadata 1.2)
dd if=/dev/zero of=/dev/sdX bs=1K count=1 seek=4096
# Method 2: Full metadata search and clean
wipefs -a /dev/sdX -t linux_raid_member
After cleaning, confirm successful removal:
# Check for remaining RAID signatures
mdadm --examine /dev/sdX
# Verify filesystem integrity
btrfs check /dev/sdX1
fsck /dev/sdX2
When repurposing RAID disks:
- Always clear superblocks before repartitioning
- Consider using
wipefs -a
for comprehensive cleaning - Update initramfs after changes:
update-initramfs -u
When repurposing former MD RAID disks for new partitions and filesystems, residual RAID superblocks can cause unexpected device binding during system boot. This occurs because:
- The Linux kernel autodetects RAID signatures during boot
- Old metadata persists even after partition table changes
- MDADM attempts to reassemble arrays from historical signatures
MD RAID superblocks are typically stored at these offsets:
# Standard superblock locations:
1.0: At end of device (minus 8KB)
1.1: 64KB from start of device
1.2: 256KB from start of device
These locations exist outside standard partition boundaries, which is why they survive repartitioning.
Here's how to clear superblocks without affecting your partitions:
# First identify all array components
mdadm --examine /dev/sd[abc]
# For each device containing old superblocks:
sudo mdadm --zero-superblock /dev/sdX
# Verify removal (should show no output if successful)
mdadm --examine /dev/sdX | grep "Magic"
When dealing with disks containing multiple partitions:
# Check partition table first
sudo fdisk -l /dev/sdX
# Zero specific offsets (example for 1.1 format)
sudo dd if=/dev/zero of=/dev/sdX bs=1K count=64 seek=0
# Alternative method for non-root users
sudo badblocks -t 0x00 -w -v -b 4096 /dev/sdX 64 64
After zeroing, perform these checks:
# Recheck for any remaining superblocks
mdadm --examine /dev/sdX
# Update initramfs to prevent resurrection
sudo update-initramfs -u
# Check kernel messages for any MD activity
dmesg | grep md
When decomissioning RAID arrays:
- Always stop and remove arrays properly:
sudo mdadm --stop /dev/mdX
- Use
--remove
when deleting:
sudo mdadm --remove /dev/mdX
- Clear superblocks immediately after array deletion