Re: GPT secondary corrupt. Is dd'ing the first 40 sectors as a backup sufficient?

From: Frank Leonhardt <freebsd-doc_at_fjl.co.uk>
Date: Tue, 01 Apr 2025 12:59:53 UTC
On 19/03/2025 07:16, Dewayne Geraghty wrote:
> 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.
> <snip>
> 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 :}
>
Hi Dewayne,

Thanks for posting this. I've been a bit busy so I waited to read this 
all properly before replying. Your results were pretty much exactly what 
I'd have expected.

I routinely blank disks before adding them to ZFS or a GEOM Mirror. I 
agree it's not strictly necessary to wipe the entire drive as the 
beginning and end are the only places likely to contain metadata to 
screw things up, but I do it anyway to test that the drive is working 
properly before use. A surprising number have failures in the middle 
that have appeared during storage. It's also better if you want to take 
a compressed image. I use LTO tape a lot and a drive that's mostly zeros 
compresses really well ;-)

I guess you agree that GPT is the way to go for larger drives? For GEOM 
Mirror I just create one large partition and mirror that - it stops the 
GPT and Gmirror data clashing and means I don't have to worry if a 
replacement drive is a few Gb smaller. I always use different drives to 
start with anyway - getting two "matched" hard disks for the same type 
from the same batch is asking for them to fail at the same time :-)

I really ought to put that script up on the blog now that you've 
reminded me. Do you mind if I reference and add your research? I haven't 
actually tested anything with a BSD partition table for a very long time.

Feel free to look me up if you're ever in London. If you think the 
script was worth it you can buy me a coffee :-)

Regards, Frank.