5 ms·
I suspect what's actually happening here is there was an old GPT partition table on the disk which was not wiped before mdadm -C was run. This means it has a c
by rwmj 8y ago
I suspect what's actually happening here is there was an old GPT partition table on the disk which was not wiped before mdadm -C was run. This means it has a correct primary partition table (with correct CRC etc), and MD RAID has overwritten the secondary PT at the end of the disk.
Unfortunately (and I genuinely hate to be "language lawyering" when someone has lost all their data), the ASRock firmware is doing the right thing according to the letter of the UEFI spec -- see section 5.3.2 of http://www.uefi.org/sites/default/files/resources/UEFI%20Spec%202_7_A%20Sept%206.pdf http://www.uefi.org/sites/default/files/resources/UEFI%20Spe... :
> If the primary GPT is invalid, the backup GPT is used instead and it is located on the last logical block on the disk. If the backup GPT is valid it must be used to restore the primary GPT. If the primary GPT is valid and the backup GPT is invalid software must restore the backup GPT.
Good time to promote my videos visualizing how GPT and Linux RAID work :-) I did some cool live visualizations of mdadm, mkfs.ext4, gdisk, injecting errors etc. https://rwmj.wordpress.com/2018/11/26/nbdkit-fosdem-test-presentation/#content https://rwmj.wordpress.com/2018/11/26/nbdkit-fosdem-test-pre... https://rwmj.wordpress.com/2018/11/06/nbd-graphical-viewer-raid-5-edition/#content https://rwmj.wordpress.com/2018/11/06/nbd-graphical-viewer-r...
- leni536 8y agoSo UEFI requires a GPT to be present, doesn't it? Otherwise what's the objective difference between an invalid GPT and no GPT?
- creshal 8y agoA valid GPT header either at the beginning or end of the disk. Due to how the GPT header is structured, the secondary starts with the partition table and ends with the header signature in the last 8 bytes of the disk. So unlike with MBR disks, you can't just nuke the first few sectors and call it a day, you have to wipe the whole disk (or use a GPT-aware tool like wipefs).
- Filligree 8y agoGoing by GP, if neither the primary nor backup GPTs are valid then nothing should happen. I would still recommend having a GPT, though. There's nothing useful to be gained by avoiding it, and we've just seen what sort of failure modes can come up.
- wtallis 8y agoNo GPT is required. Problems only happen when you have partial or conflicting partition table information. If you want to not use GPT on a disk, you need to make sure to delete both copies.
- theevilsharpie 8y agoIn addition, had the OP used disk partitions, a valid partition table (either MBR or GPT) would have been written to disk. Every Linux installer that I've used sets up disk partitions for software RAID volumes. I don't think an installer for a major distro will let you use a bare device, even if you wanted to, and all of the instructions/tutorials I've seen on setting up mdadm include the configuration of partitions. Seems like the OP went out of their way to configure software RAID in a non-standard manner, without understanding the consequences. I hate to kick the OP while they're down, but it doesn't look like this is an issue that someone would encounter with a default/recommended configuration.
- nh2 8y agoNo worries, this is good advice, I appreciate it. (Also note I managed to fully recover from this without data loss, and I have backups.) This RAID setup is already quite old. For newer RAID setups I routinely put the RAID on partitions as you said, after more advice has appeared on the Internet that this is recommended. However, I didn't find hard arguments for this beyond "if you make the partitions a bit smaller, you can accomodate disks that aren't exactly euqually large" -- certainly I didn't encounter "if you don't do this, UEFI may trash your setup". It would be inaccurate to say I went "out of my way to set it up in a non-standard manner" though. I didn't use a distro installer, simply because the machine was already installed when I added this RAID to it. I just used straightforward `mdadm --create --create /dev/md0 --level=1 --raid-devices=2 /dev/sdc /dev/sdd` on bare devices, which is a supported use case by mdadm, and much documentation and tutorial material still mention that you can choose bare devices vs partition (probably hard to blame them for that, given that this is the first and only mainboard I have encountered that does this).
- bradfa 8y agoAdditionally, unless you do an mdadm software RAID using full disks, you cannot ensure that the EFI system partition will be RAIDed. But if you want to avoid having your mdadm metadata at the start of the drives, you can have it placed in various locations which may help, see: https://raid.wiki.kernel.org/index.php/RAID_superblock_formats#Sub-versions_of_the_version-1_superblock https://raid.wiki.kernel.org/index.php/RAID_superblock_forma... I use mdadm RAID1 on full disks on my desktop with the metadata at the end of the disks (superblock version 1.0). Partitioning tools will complain that my backup GPT partition table is invalid and offer to fix it (I always politely decline) but the primary one is fine. My Dell desktop doesn't mind this situation and also does not ever write any data into the EFI partition so it works well for me.
- nh2 8y agoGood technical response! Is the part you quoted the one that's relevant here though? As per my post, gdisk reports "corrupt GPT" (due to CRC mismatch). In section 5.3.2 you posted, it says: > If the primary GPT is corrupt, software must check the last LBA of the device to see if it has a valid GPT Header and point to a valid GPT Partition Entry Array. > If it points to a valid GPT Partition Entry Array, then software should restore the primary GPT if allowed by platform policy settings (e.g. a platform may require a user to provide confirmation before restoring the table, or may allow the table to be restored automatically). > Software must report whenever it restores a GPT. So wouldn't the spec-compliant behaviour be to "provide confirmation before restoring", or at the very least, "must report whenever it restores a GPT"?
- rwmj 8y agoYes I believe you are right. It's possible the ASRock firmware did "report" this - I guess it doesn't need to ask for confirmation however ... arrgh. Did the ASRock firmware provide any "report" or feedback about what it was doing?
- nh2 8y agoNo, it didn't report anything. After cycling to the shop and buying a couple TB disks to make extra backups before messing with headers, I created new superblocks (you can tell `mdadm --create` to pick up existing data). I then repeated the repairing and subsequent re-deletion by the mainboard on boot around 10 times, in order to ensure it's reproducible before I post on their forums. I did not spot it outputting any kind of message about it.
- deleted 8y ago[deleted]
- vectorEQ 8y agooh the times of bios and just getting a message no boot disk found to let u know ur partition table was messed up :D ... such simpler times.. :D interesting comment though thanks a lot. makes much more sense now than reading just the article.
- nh2 8y agoSimpler times. This mainboard's UEFI even has a built-in GUI for filing tech support tickets, for the case things are broken to the extent that you cannot boot. (This feature is highlighted in the manual, "if you are having trouble with your PC".)
- Aissen 8y agoIn fact, gdisk even says so after the Main partition table CRC mismatch : Loaded backup partition table instead of main partition table! And there's no "backup partition table CRC mismatch". This tool can be very cryptic to decode the messages, though.
- ajnin 8y agoI don't agree with this assessment, the UEFI spec also states that : > If the primary GPT is corrupt, software must check the last LBA of the device to see if it has a valid GPT Header and point to a valid GPT Partition Entry Array. If it points to a valid GPT Partition Entry Array, then software should restore the primary GPT if allowed by platform policy settings (e.g. a platform may require a user to provide confirmation before restoring the table, or may allow the table to be restored automatically). Software must report whenever it restores a GPT. Emphasis on "if allowed by platform policy settings". Booting up the system should require read-only access to the disks and writing a new GPT should be prevented in that case. At the very least after asking fo ruser confirmation, as the following section suggests : > Software should ask a user for confirmation before restoring the primary GPT and must report whenever it does modify the media to restore a GPT. In that case, the motherboard uefi neither asked nor reported that the primary GPT was restored.
- kiallmacinnes 8y agoWell! This explains some odd behaviour I've seen on some servers that were wiped and reinstalled frequently, often with differing legacy BIOS vs UEFI vs GPT vs MBR settings. I had a `dd if=/dev/zero of=/dev/sda bs=1k count=1000` or similar to wipe the disk just enough that the provisioning would be happy... Or, at least, it was happy most of the time. I bet this was my root cause!
- rwmj 8y agowipefs(8) is your friend here, it knows about where various signatures are and usually erases things more accurately. Of course there is also the "nuclear" option of running blkdiscard.