I have two hard drive partitions, which I have combined into a RAID1 using mdadm
, and created an ext4 filesystem on the resulting device.
When I mdadm --zero-superblock
the two partitions, and re-create the RAID, then the original ext4 metadata is magically preserved.
Why is that?
And how can I tell mdadm
to give me a truly new, uninitialised MD?
Details
How I create the RAID1 and file system:
ls /dev/sdc2 # partition 1
ls /dev/sdd2 # partition 2
mdadm --create --run --verbose /dev/md1 --level=1 --raid-devices=2 /dev/sdc2 /dev/sdd2
mkfs.ext4 -L mylabel /dev/md1
Wipe RAID1:
mdadm --stop /dev/md1
mdadm --zero-superblock /dev/sdc2
mdadm --zero-superblock /dev/sdd2
Recreate RAID1:
mdadm --create --run --verbose /dev/md1 --level=1 --raid-devices=2 /dev/sdc2 /dev/sdd2
Display device information (note wipefs
without the -a
flag doesn't wipe anything but just shows info):
# wipefs /dev/md1
offset type
----------------------------------------------------------------
0x438 ext4 [filesystem]
LABEL: mylabel
UUID: 3d230d31-fb82-46ef-a4e0-e9473e05825c
LABEL: mylabel
shows that the ext4 label "survived" the mdadm superblock wipe and RAID recreation.
How can that be?
I thought that after a superblock wipe and recreation, mdadm is supposed to present me with a "clean" view of the device (i.e. all zeros), unless a flag is given that turns that off (such as --assume-clean
, which I haven't given).