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: Fri, 21 Feb 2025 19:43:53 UTC
On 21/02/2025 12:03, Frank Leonhardt wrote:
 > On 21/02/2025 11:48, Frank Leonhardt wrote:
 >> As to questions two and three I'm saying nothing until I've tested 
it! All I will say is when recovering a corrupt disk dd it as an image 
and play with the image.
 >>
 >> I'll keep an eye on this thread in case experiments are called for 
as I current have a "disk lab" going.
 >
 > Okay, I can't stop thinking about this and I'll so I'll some 
experiments at the weekend and update the blog :-)
 >
Well, basically it seems to work :-)

# gpart create -s gpt da1

# gpart add -t freebsd-ufs da1

# gpart create -s gpt da3

# gpart add -t freebsd-ufs da3

# kldload geom_mirror

# gmirror label m1 da1p1 da3p1

# newfs -U /dev/mirror/m1

# mount /dev/mirror/m1 /mnt

# gmirror status
           Name    Status  Components
mirror/mirror1  COMPLETE  da1p1 (ACTIVE)
                           da3p1 (ACTIVE)

Obviously, in reality you'd load geom_mirror in loader.conf and add the 
mount to fstab.

I have done no testing on this other than creating a few files, but I 
just wanted to prove the concept worked.

# gpart show da1 da3
=>        40  5860533088  da1  GPT  (2.7T)
           40  5860533088    1  freebsd-ufs  (2.7T)

=>        40  5860533088  da3  GPT  (2.7T)
           40  5860533088    1  freebsd-ufs  (2.7T)



You could obviously use gpart backup da1 | gpart restore da3 rather than 
partitioning both, but I just happened to do it by typing the above