EDIT: It appears that this might be an inherent issue with the .9 superblock version. Figures that I would only be able to find these links after I posted here.
https://bugs.launchpad.net/ubuntu/+source/debian-installer/+bug/599515 mdadm assembles with drives instead of partitions
Recently, I added to new disks to a machine. I created one partition on each drive, and used software raid to set up a raid1 between the partitions. However, for some reason after I add the partitions to the array, mdadm also detects the superblock in the underlying block devices. This causes a lot of problems during boot, as udev tries to assemble arrays incrementally and stumbles on /dev/sda before /dev/sda1. As you can see below, only md3 suffers from this problem. It was assembled with mdadm -A /dev/md3 /dev/sda1 /dev/sdb1
. Have I set up these partitions incorrectly somehow?
root@blaster:/# mdadm --examine --verbose --scan
ARRAY /dev/md3 level=raid1 num-devices=2 UUID=33868dc0:becdb6b6:8b9f62c7:cb89d2ee
spares=2 devices=/dev/sdb1,/dev/sdb,/dev/sda1,/dev/sda
ARRAY /dev/md0 level=raid1 num-devices=2 UUID=866cc7e5:f18b48c0:539d4f3e:4592bf76
devices=/dev/sdd1,/dev/sdc1
ARRAY /dev/md1 level=raid1 num-devices=2 UUID=550101be:d1fac9c9:48c0e818:59501087
devices=/dev/sdd2,/dev/sdc2
ARRAY /dev/md2 level=raid1 num-devices=2 UUID=7783bbb3:6e381768:8b9f62c7:cb89d2ee
devices=/dev/sdf1,/dev/sde1
Linux RAID superblock information is stored in the very last blocks of the device or partition. Re-formatting or or re-partitioning a device generally will NOT overwrite this block, so you have to do it manually. Running
mdadm --zero-superblock
will do exactly that, but you have to be very careful when you use it, or you'll nuke your RAID metadata.The metadata is stored at the end of the disk which caused the issue as you already figured out. To avoid confusion like this you can try using version 1 superblock (
man mdadm
for details). You have version 1.1 storing this info at the start of the device, and version 1.2 storing it 4k from the start. With both of these versions you will not see this problem.