Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 09 Jan 2011 15:27:27 +0200
From:      "Luchesar V. ILIEV" <luchesar.iliev@gmail.com>
To:        zeus@ibs.dn.ua
Cc:        freebsd-geom@freebsd.org
Subject:   Re: "secondary GPT table is corrupt or invalid" issue again
Message-ID:  <4D29B7BF.3070706@gmail.com>
In-Reply-To: <20110109112027.GD66627@relay.ibs.dn.ua>
References:  <20110104170611.GA67159@relay.ibs.dn.ua> <4D28509D.607@yandex.ru> <20110108223747.GA66627@relay.ibs.dn.ua> <4D28FB15.9090907@gmail.com> <20110109112027.GD66627@relay.ibs.dn.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
On 01/09/2011 13:20, Zeus V Panchenko wrote:
> and again ... just to be sure i understand all correctly ...  
> 
> now i have two disks in gmirror ... to get rid of the secondary table
> corruption for my working gmirror (with mirror master ada1)
> 
>       Name    Status  Components
> mirror/gm0  COMPLETE  ada1p1
>                       ada2p1
> 
> i decided to destroy second (ada2) disk GPT and gmirror data, create
> GPT for it (ada2) from scratch, copy data to it from gmirror (gm0),
> destroy the mirror, create the mirror with second (ada2) disk as
> master, recreate GPT for first (ada1) disk and insert it to the mirror
> as secondary disk:
> 
>  1. gmirror remove gm0 ada2p1
>  2. gmirror clear ada2p1
>  3. gpart destroy ada2
>  4. gpart create -s gpt /dev/ada2
>  5. gpart add -b 2048 -s 1953521664 -t freebsd-ufs -i 1 -l labeldisk2 /dev/ada2
>  6. newfs -f 4096 -b 32768 -g 1048576 -o space -U -L labeldisk2 /dev/ada2p1
>  7. tar -cf - -C MNTPOIN_gm0 . | tar -xpf - -C MNTPOINT_ada2p1
>  8. gmirror stop gm0 
>  9. gpart destroy ada1
> 10. gpart create -s gpt /dev/ada1
> 11. gpart add -b 2048 -s 1953521664 -t freebsd-ufs -i 1 -l labeldisk1 /dev/ada1
> 12. newfs -f 4096 -b 32768 -g 1048576 -o space -U -L labeldisk1 /dev/ada1p1
> 13. gmirror label -v -h -b load gm0 gpt/labeldisk2
> 14. gmirror insert -v -h -p 1 gm0 gpt/labeldisk1
> 
> i think it is possible to ignore p.12
> 
> so, is it correct, any corrections/amendations to the algorythm?

Hi Zeus,

Yes, even though you could indeed just try "gpart recover", the
procedure you describe is likely the "cleanest" solution.

A few notes:

1. It's usually safest to create filesystems on already set up mirrors.
Shouldn't be a problem to create the mirror with an existing filesystem
as well, but only if you are really certain that it doesn't extend to
the very end of the device, occupying the last sector.

2. You wouldn't be able to destroy a GPT scheme unless you first delete
all existing partitions, or -F-orce it.

The first note is more important. An alternative way to do the whole
thing in accordance with it might be:

# gmirror stop gm0

(at this point it might be wise to check if you can mount the FS on
/dev/ada1p1 w/o problems, though I don't see a reason why you shouldn't)

# gmirror clear -v ada1p1 ada2p1
# gpart destroy -F ada2
# gpart create -s gpt ada2
# gpart add -b 2048 -s 1953521664 -t freebsd-ufs -i 1 \
-l labeldisk2 ada2
# gmirror label -v -h -b load gm0 gpt/labeldisk2
# newfs [...] /dev/mirror/gm0

Here you'd copy the files from /dev/ada1p1 to /dev/mirror/gm0. BTW, I
find using net/rsync easier to use, e.g. rsync -avH /src/ /dst/, but
that's really just a personal preference.

After you make sure that gm0 now holds your information correctly...

# gpart destroy -F ada1
# gpart create -s gpt ada1
# gpart add -b 2048 -s 1953521664 -t freebsd-ufs -i 1 \
-l labeldisk1 ada1
# gmirror insert -v -h -p 1 gm0 gpt/labeldisk1

When resync finishes, and if you prefer gpt/labeldisk1 to be your
"master", you might change the priorities.

Of course, this is going to be a long procedure with those 1 TB disks.

Again, please take all my comments with a grain of salt. Good luck!

Cheers,
Luchesar



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4D29B7BF.3070706>