mdraid destroyed on reboot


2020-03-08

Certain AsRock motherboards will see a “corrupted” GPT and helpfully repair it on boot from the backup one, breaking the RAID.

This only happens when using the device /dev/sdX and not a partition /dev/sdXY for the RAID.

Symptom:

root@CAPRICA ~ $ parted /dev/sde
GNU Parted 3.2
Using /dev/sde
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Error: The primary GPT table is corrupt, but the backup appears OK, so that will be used.
OK/Cancel? OK
Model: ATA ST6000VN0041-2EL (scsi)
Disk /dev/sde: 6001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start  End  Size  File system  Name  Flags

(parted)

Bad Drive:

root@CAPRICA ~ $ wipefs /dev/sde
DEVICE OFFSET        TYPE              UUID                                 LABEL
sde    0x1000        linux_raid_member 84165006-f1cb-589c-4be0-8787df8a2611 LUNA:0
sde    0x57541e95e00 gpt
sde    0x1fe         PMBR

Good Drive:

root@CAPRICA ~ $ wipefs /dev/sdf
DEVICE OFFSET TYPE              UUID                                 LABEL
sdf    0x1000 linux_raid_member 84165006-f1cb-589c-4be0-8787df8a2611 LUNA:0

Wipe the gpt and PMBR:

root@CAPRICA ~ $ wipefs --backup --force -o 0x57541e95e00 /dev/sde
/dev/sde: 8 bytes were erased at offset 0x57541e95e00 (gpt): 45 46 49 20 50 41 52 54

root@CAPRICA ~ $ wipefs --backup --force -o 0x1fe /dev/sde
/dev/sde: 2 bytes were erased at offset 0x000001fe (PMBR): 55 aa