Re: GPT secondary corrupt. Is dd'ing the first 40 sectors as a backup sufficient?
Date: Wed, 19 Mar 2025 07:16:14 UTC
Thank-you for your advise and script. I performed a large array of tests on both FreeBSD 12.4S, 14.1S and HardenedBSD 14.2S systems. All tests were performed on memory devices then on separate drives and booted to init. My conclusions are: 1. The often cited method of: formatting a disk, creating a single disk mirror and then inserting a blank device(s) into the mirror, was successful with the BSD scheme. Following this sequence neither MBR or GPT were unsuccessful. Perhaps something changed from FBSD9 to 14 (??) So to the detail: a) The sequence of: creating a mirror (with attached disks) and then formatting its content works with schemes: MBR, GPT and BSD. b) Whilst creating a disk, then a mirror then adding another (blank) disk, resulted in: b i) For the MGR scheme, partitioning and newfs, then mirror - failed with these messages to the console: GEOM_MIRROR: Device mirror/gm2 launched (1/1). GEOM_PART: integrity check failed (mirror/gm2, MBR) GEOM_MIRROR: Device gm2: rebuilding provider ada6. [ DG ada6 is the second disk ] GEOM_MIRROR: Device gm2: rebuilding provider ada6 finished. b ii) Using the BSD scheme, partition, mirror then add disk - ok (well that is mysterious) c iii) Using the GPT scheme, partition, newfs then mirror - failed with console messages: GEOM: ada7: the secondary GPT table is corrupt or invalid. GEOM: ada7: using the primary only -- recovery suggested. GEOM_MIRROR: Device mirror/gm2 launched (1/1). GEOM: mirror/gm2: corrupt or invalid GPT detected. GEOM: mirror/gm2: GPT rejected -- may not be recoverable. GEOM_MIRROR: Device gm2: rebuilding provider ada6. GEOM_MIRROR: Device gm2: rebuilding provider ada6 finished. Note: The second device is blank. A better outcome if the disk has a scheme applied may result. (I didn't test that approach due to more steps) 2. MBR (and quite likely BSD) schemes are limited to 2TB (using storage with 512B sectors) or 16TB (for storage with 4k sectors, though I haven't tested the latter). As 4TB disks are relatively accessible with 512B/sectors, there remains a need to use GPT scheme to avoid storage size limitations. 3. Frequently the option of having multiple mirrors of partitions on a single disk is mentioned as a solution. But the need to have multiple mirrors complicates things and creates additional processes. This appears to be a workaround due to GEOM technology preceding the adoption/availability of GPT. Aside: With multiple mirror on a single disk its another stress during failure recovery. If anyone is interested I'm happy to provide the 250+ line script that does the work so you can reproduce. You'll only need to modify three lines and the general sequence is: script destroy (to prep disks); script create GPT|MBR|BSD; script display. For me success was booting the disk to init. To your questions Frank: As I vaguely recall Pawel's intent was to provide software RAID vs hw RAID cards. If you have disks of dissimilar sizes, gmirroring the two disks will result in a mirror that uses the size of the smaller disk. Yes, if you wish to mirror a partition, gmirror does a good job and retains access to the rest of the device(s). I appreciate the script that you provided which I successfully used. I went further with testing to reveal various failure states and their recovery. Unfortunately this resulted in my embarrassment for asking such naive questions at the outset. Regards, Dewayne PS I chose not to set kern.geom.part.check_integrity=0. And yes, it is a pity that zfs doesn't support MAC labels :}