UFS gmirror synchronisation

Hi,

I have been experimenting a little with 2 external USB drives and gmirror. Placing the gmirror on the disk and then creating a single partition and also gmirror’ing only a smaller partition set.

I have noticed when I test its resilience by changing a small file on only one of the USB drives that when I reinsert the removed drive it rebuilds in entirety. Clearly, this works well, but is it meant to have some instrumentation to know only to rebuild the affected blocks or is it by design meant to rebuild the entire disk / partition regardless ?

Many thanks for any additional insight.
 
gmirror(8) has no knowledge of the underlying file system and keeps all its (very limited) metadata on the last sector of the mirror. So it's only option when one side of a mirror gets out of sync is to re-silver the entire mirror.

If the sync times are an issue, consider mirroring multiple (smaller) partitions, or use ZFS which has the advantage of knowing about the underlying hardware (well, provider) and the file system.
 
Thank you for the prompt reply, and language, you put that really well. As it turns out I am using ZFS on the main drive; the use of gmirror is for an off-board backup and I wanted it to be simple. I’ll try using a few smaller partitions. Also is it still recommended not to use GPT as the metadata clashes at the end of the disk? I‘m doing a before /after compare of hexdump for the last 1M of the disk to check for myself but it’s a bit inconclusive at this time.

Many thanks
 
Also is it still recommended not to use GPT as the metadata clashes at the end of the disk?
The short answer is that I still don't know. Sorry. I have migrated to mostly using ZFS, and these days only use gmirror for making swap partitions.

There's also a problem with software-mirroring an EFI partition. I'm still firmly of the view that it should not be software mirror'd with things like gmirror, as the EFI contents can be changed without the knowledge of the over-lying operating system (from the stand-alone shell-like command). Hardware RAID is usually OK, because the under-lying hardware RAID controller maintains integrity.
 
Also is it still recommended not to use GPT as the metadata clashes at the end of the disk?
Yes.

FWIW, I also had to have GEOM “re-taste” the partitions
Code:
true > /dev/ada0
true > /dev/ada1

That tip is from here:

This was several years ago, though. I would use ZFS mirroring if I was going to set up that server today.
 
Also is it still recommended not to use GPT as the metadata clashes at the end of the disk?
Yes.

I've notice many times that the FreeBSD documentation is not accurate (or outdated), which seems be the case with gmirror(8) overwriting GPT secondary table on the last sector of a disk as well.

The manual gmirror(8) states
Rich (BB code):
DESCRIPTION
     [...]
     The gmirror utility uses on-disk metadata (stored in the provider's last
     sector) to store all needed information. [...]

It says "provider's last sector", not disks. To my understanding a "provider" can be a disk or a partition.

I don't know on which source the author of the article bases his statement, but the mentioned FreeBSD 9 -> 11 versions, according to the manuals have all the same reference to a provider, not disk.

gmirror(8) appeared first in FreeBSD 5.3, it's manual also refers to a provider, not disk.

I think that "gmirror(8) metadata is written on the last sector of a disk" is a myth, a myth which made it in the handbook, took over unverified by the author of the chapter https://docs.freebsd.org/en/books/handbook/geom/#geom-mirror-metadata.

I did some (superficial) searching in src/sys/geom/mirror/, but didn't figure out how the metadata on which sector is handled.

So I tested in a VM and the results support my interpretation. gmirror(8) metadata does not overwrite GPT secondary table on the last sector of the disk.

First, gpart(8) show doesn't show the partition table corrupted after creating a gmirror(8), which would be the case if the secondary GPT table was overwritten, second, hexdump(1) confirms.


Test case 1:

Code:
=>      40  12582832  ada0  GPT  (6.0G)
        40      2008        - free -  (1.0M)
      2048  12578816     1  freebsd-ufs  (6.0G)
  12580864      2008        - free -  (1.0M)

=>      40  12582832  ada1  GPT  (6.0G)
        40      2008        - free -  (1.0M)
      2048  12578816     1  freebsd-ufs  (6.0G)
  12580864      2008        - free -  (1.0M)


hexdump(1) of ada0 after creating GPT table, showing primary and secondary GPT table

Rich (BB code):
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001c0  02 00 ee ff ff ff 01 00  00 00 ff ff bf 00 00 00  |................|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00  |EFI PART....\...|
00000210  84 db 2a f6 00 00 00 00  01 00 00 00 00 00 00 00  |..*.............|
00000220  ff ff bf 00 00 00 00 00  28 00 00 00 00 00 00 00  |........(.......|
00000230  d7 ff bf 00 00 00 00 00  54 a5 8f 32 e6 35 ef 11  |........T..2.5..|
00000240  b7 ac 08 00 27 c4 37 c5  02 00 00 00 00 00 00 00  |....'.7.........|
00000250  80 00 00 00 80 00 00 00  b5 4a 6b 97 00 00 00 00  |.........Jk.....|
00000260  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000400  b6 7c 6e 51 cf 6e d6 11  8f f8 00 02 2d 09 71 2b  |.|nQ.n......-.q+|
00000410  b4 2e 44 61 e6 35 ef 11  b7 ac 08 00 27 c4 37 c5  |..Da.5......'.7.|
00000420  00 08 00 00 00 00 00 00  ff f7 bf 00 00 00 00 00  |................|
00000430  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
17fffbe00  b6 7c 6e 51 cf 6e d6 11  8f f8 00 02 2d 09 71 2b  |.|nQ.n......-.q+|
17fffbe10  b4 2e 44 61 e6 35 ef 11  b7 ac 08 00 27 c4 37 c5  |..Da.5......'.7.|
17fffbe20  00 08 00 00 00 00 00 00  ff f7 bf 00 00 00 00 00  |................|
17fffbe30  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
17ffffe00  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00  |EFI PART....\...|
17ffffe10  28 e5 09 b4 00 00 00 00  ff ff bf 00 00 00 00 00  |(...............|
17ffffe20  01 00 00 00 00 00 00 00  28 00 00 00 00 00 00 00  |........(.......|
17ffffe30  d7 ff bf 00 00 00 00 00  54 a5 8f 32 e6 35 ef 11  |........T..2.5..|
17ffffe40  b7 ac 08 00 27 c4 37 c5  df ff bf 00 00 00 00 00  |....'.7.........|
17ffffe50  80 00 00 00 80 00 00 00  b5 4a 6b 97 00 00 00 00  |.........Jk.....|
17ffffe60  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

hexdump(1) of ada0 after creating a ada0p1/ada1p1 gmirror(8), label "ufsmir", primary and secondary GPT table highlighted

Rich (BB code):
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001c0  02 00 ee ff ff ff 01 00  00 00 ff ff bf 00 00 00  |................|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00  |EFI PART....\...|
00000210  84 db 2a f6 00 00 00 00  01 00 00 00 00 00 00 00  |..*.............|
00000220  ff ff bf 00 00 00 00 00  28 00 00 00 00 00 00 00  |........(.......|
00000230  d7 ff bf 00 00 00 00 00  54 a5 8f 32 e6 35 ef 11  |........T..2.5..|
00000240  b7 ac 08 00 27 c4 37 c5  02 00 00 00 00 00 00 00  |....'.7.........|
00000250  80 00 00 00 80 00 00 00  b5 4a 6b 97 00 00 00 00  |.........Jk.....|
00000260  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000400  b6 7c 6e 51 cf 6e d6 11  8f f8 00 02 2d 09 71 2b  |.|nQ.n......-.q+|
00000410  b4 2e 44 61 e6 35 ef 11  b7 ac 08 00 27 c4 37 c5  |..Da.5......'.7.|
00000420  00 08 00 00 00 00 00 00  ff f7 bf 00 00 00 00 00  |................|
00000430  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
17feffe00  47 45 4f 4d 3a 3a 4d 49  52 52 4f 52 00 00 00 00  |GEOM::MIRROR....|
17feffe10  04 00 00 00 75 66 73 6d  69 72 00 00 00 00 00 00  |....ufsmir......|
17feffe20  00 00 00 00 d0 bf 79 7e  a5 80 72 a2 02 00 00 00  |......y~..r.....|
17feffe30  00 01 00 00 00 00 00 10  00 00 02 00 fe df 7f 01  |................|
17feffe40  00 00 00 00 02 00 00 00  00 00 00 00 00 00 00 00  |................|
17feffe50  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
17feffe70  00 e0 7f 01 00 00 00 b5  62 b7 d6 f2 93 8a f4 56  |........b......V|
17feffe80  55 e0 25 2c ec c4 25 00  00 00 00 00 00 00 00 00  |U.%,..%.........|
17feffe90  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
17fffbe00  b6 7c 6e 51 cf 6e d6 11  8f f8 00 02 2d 09 71 2b  |.|nQ.n......-.q+|
17fffbe10  b4 2e 44 61 e6 35 ef 11  b7 ac 08 00 27 c4 37 c5  |..Da.5......'.7.|
17fffbe20  00 08 00 00 00 00 00 00  ff f7 bf 00 00 00 00 00  |................|
17fffbe30  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
17ffffe00  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00  |EFI PART....\...|
17ffffe10  28 e5 09 b4 00 00 00 00  ff ff bf 00 00 00 00 00  |(...............|
17ffffe20  01 00 00 00 00 00 00 00  28 00 00 00 00 00 00 00  |........(.......|
17ffffe30  d7 ff bf 00 00 00 00 00  54 a5 8f 32 e6 35 ef 11  |........T..2.5..|
17ffffe40  b7 ac 08 00 27 c4 37 c5  df ff bf 00 00 00 00 00  |....'.7.........|
17ffffe50  80 00 00 00 80 00 00 00  b5 4a 6b 97 00 00 00 00  |.........Jk.....|
17ffffe60  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|



Test case 2:

Code:
=>      40  12582832  ada2  GPT  (6.0G)
        40      2008        - free -  (1.0M)
      2048   4194304     1  freebsd-ufs  (2.0G)
   4196352   4194304     2  freebsd-ufs  (2.0G)
   8390656   4190208     3  freebsd-ufs  (2.0G)
  12580864      2008        - free -  (1.0M)

=>      40  12582832  ada3  GPT  (6.0G)
        40      2008        - free -  (1.0M)
      2048   4194304     1  freebsd-ufs  (2.0G)
   4196352   4194304     2  freebsd-ufs  (2.0G)
   8390656   4190208     3  freebsd-ufs  (2.0G)
  12580864      2008        - free -  (1.0M)


hexdump(1) of ada2 after creating GPT table, showing primary and secondary GPT table

Code:
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001c0  02 00 ee ff ff ff 01 00  00 00 ff ff bf 00 00 00  |................|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00  |EFI PART....\...|
00000210  5b 51 74 e2 00 00 00 00  01 00 00 00 00 00 00 00  |[Qt.............|
00000220  ff ff bf 00 00 00 00 00  28 00 00 00 00 00 00 00  |........(.......|
00000230  d7 ff bf 00 00 00 00 00  73 92 35 31 eb 35 ef 11  |........s.51.5..|
00000240  b7 ac 08 00 27 c4 37 c5  02 00 00 00 00 00 00 00  |....'.7.........|
00000250  80 00 00 00 80 00 00 00  ab 8c ea 1a 00 00 00 00  |................|
00000260  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000400  b6 7c 6e 51 cf 6e d6 11  8f f8 00 02 2d 09 71 2b  |.|nQ.n......-.q+|
00000410  7b 36 59 45 eb 35 ef 11  b7 ac 08 00 27 c4 37 c5  |{6YE.5......'.7.|
00000420  00 08 00 00 00 00 00 00  ff 07 40 00 00 00 00 00  |..........@.....|
00000430  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000480  b6 7c 6e 51 cf 6e d6 11  8f f8 00 02 2d 09 71 2b  |.|nQ.n......-.q+|
00000490  7f f8 78 46 eb 35 ef 11  b7 ac 08 00 27 c4 37 c5  |..xF.5......'.7.|
000004a0  00 08 40 00 00 00 00 00  ff 07 80 00 00 00 00 00  |..@.............|
000004b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000500  b6 7c 6e 51 cf 6e d6 11  8f f8 00 02 2d 09 71 2b  |.|nQ.n......-.q+|
00000510  af 28 76 49 eb 35 ef 11  b7 ac 08 00 27 c4 37 c5  |.(vI.5......'.7.|
00000520  00 08 80 00 00 00 00 00  ff f7 bf 00 00 00 00 00  |................|
00000530  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
17fffbe00  b6 7c 6e 51 cf 6e d6 11  8f f8 00 02 2d 09 71 2b  |.|nQ.n......-.q+|
17fffbe10  7b 36 59 45 eb 35 ef 11  b7 ac 08 00 27 c4 37 c5  |{6YE.5......'.7.|
17fffbe20  00 08 00 00 00 00 00 00  ff 07 40 00 00 00 00 00  |..........@.....|
17fffbe30  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
17fffbe80  b6 7c 6e 51 cf 6e d6 11  8f f8 00 02 2d 09 71 2b  |.|nQ.n......-.q+|
17fffbe90  7f f8 78 46 eb 35 ef 11  b7 ac 08 00 27 c4 37 c5  |..xF.5......'.7.|
17fffbea0  00 08 40 00 00 00 00 00  ff 07 80 00 00 00 00 00  |..@.............|
17fffbeb0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
17fffbf00  b6 7c 6e 51 cf 6e d6 11  8f f8 00 02 2d 09 71 2b  |.|nQ.n......-.q+|
17fffbf10  af 28 76 49 eb 35 ef 11  b7 ac 08 00 27 c4 37 c5  |.(vI.5......'.7.|
17fffbf20  00 08 80 00 00 00 00 00  ff f7 bf 00 00 00 00 00  |................|
17fffbf30  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
17ffffe00  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00  |EFI PART....\...|
17ffffe10  f7 6f 57 a0 00 00 00 00  ff ff bf 00 00 00 00 00  |.oW.............|
17ffffe20  01 00 00 00 00 00 00 00  28 00 00 00 00 00 00 00  |........(.......|
17ffffe30  d7 ff bf 00 00 00 00 00  73 92 35 31 eb 35 ef 11  |........s.51.5..|
17ffffe40  b7 ac 08 00 27 c4 37 c5  df ff bf 00 00 00 00 00  |....'.7.........|
17ffffe50  80 00 00 00 80 00 00 00  ab 8c ea 1a 00 00 00 00  |................|
17ffffe60  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

hexdump(1) of ada2 after creating ada2p[1,2,3]/ada3p[1,2,3] gmirror(8), label "ufsgm1|2|3", primary and secondary GPT table highlighted

Rich (BB code):
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001c0  02 00 ee ff ff ff 01 00  00 00 ff ff bf 00 00 00  |................|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00  |EFI PART....\...|
00000210  5b 51 74 e2 00 00 00 00  01 00 00 00 00 00 00 00  |[Qt.............|
00000220  ff ff bf 00 00 00 00 00  28 00 00 00 00 00 00 00  |........(.......|
00000230  d7 ff bf 00 00 00 00 00  73 92 35 31 eb 35 ef 11  |........s.51.5..|
00000240  b7 ac 08 00 27 c4 37 c5  02 00 00 00 00 00 00 00  |....'.7.........|
00000250  80 00 00 00 80 00 00 00  ab 8c ea 1a 00 00 00 00  |................|
00000260  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000400  b6 7c 6e 51 cf 6e d6 11  8f f8 00 02 2d 09 71 2b  |.|nQ.n......-.q+|
00000410  7b 36 59 45 eb 35 ef 11  b7 ac 08 00 27 c4 37 c5  |{6YE.5......'.7.|
00000420  00 08 00 00 00 00 00 00  ff 07 40 00 00 00 00 00  |..........@.....|
00000430  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000480  b6 7c 6e 51 cf 6e d6 11  8f f8 00 02 2d 09 71 2b  |.|nQ.n......-.q+|
00000490  7f f8 78 46 eb 35 ef 11  b7 ac 08 00 27 c4 37 c5  |..xF.5......'.7.|
000004a0  00 08 40 00 00 00 00 00  ff 07 80 00 00 00 00 00  |..@.............|
000004b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000500  b6 7c 6e 51 cf 6e d6 11  8f f8 00 02 2d 09 71 2b  |.|nQ.n......-.q+|
00000510  af 28 76 49 eb 35 ef 11  b7 ac 08 00 27 c4 37 c5  |.(vI.5......'.7.|
00000520  00 08 80 00 00 00 00 00  ff f7 bf 00 00 00 00 00  |................|
00000530  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
800ffe00  47 45 4f 4d 3a 3a 4d 49  52 52 4f 52 00 00 00 00  |GEOM::MIRROR....|
800ffe10  04 00 00 00 75 66 73 67  6d 31 00 00 00 00 00 00  |....ufsgm1......|
800ffe20  00 00 00 00 ed 30 90 9f  ba e2 2d e3 02 00 00 00  |.....0....-.....|
800ffe30  00 01 00 00 00 00 00 10  00 00 02 00 fe ff 7f 00  |................|
800ffe40  00 00 00 00 02 00 00 00  00 00 00 00 00 00 00 00  |................|
800ffe50  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
800ffe70  00 00 80 00 00 00 00 67  b2 cf 97 f6 81 78 66 64  |.......g.....xfd|
800ffe80  f9 76 83 64 ac 67 aa 00  00 00 00 00 00 00 00 00  |.v.d.g..........|
800ffe90  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
1000ffe00  47 45 4f 4d 3a 3a 4d 49  52 52 4f 52 00 00 00 00  |GEOM::MIRROR....|
1000ffe10  04 00 00 00 75 66 73 67  6d 32 00 00 00 00 00 00  |....ufsgm2......|
1000ffe20  00 00 00 00 50 17 f7 a5  2c a7 b7 c0 02 00 00 00  |....P...,.......|
1000ffe30  00 01 00 00 00 00 00 10  00 00 02 00 fe ff 7f 00  |................|
1000ffe40  00 00 00 00 02 00 00 00  00 00 00 00 00 00 00 00  |................|
1000ffe50  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
1000ffe70  00 00 80 00 00 00 00 99  91 e0 10 22 b9 5d e9 24  |...........".].$|
1000ffe80  57 fe 9a f5 8c 7d b2 00  00 00 00 00 00 00 00 00  |W....}..........|
1000ffe90  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
17feffe00  47 45 4f 4d 3a 3a 4d 49  52 52 4f 52 00 00 00 00  |GEOM::MIRROR....|
17feffe10  04 00 00 00 75 66 73 67  6d 33 00 00 00 00 00 00  |....ufsgm3......|
17feffe20  00 00 00 00 92 d9 7f 86  0e 6f 1d 9f 02 00 00 00  |.........o......|
17feffe30  00 01 00 00 00 00 00 10  00 00 02 00 fe df 7f 00  |................|
17feffe40  00 00 00 00 02 00 00 00  00 00 00 00 00 00 00 00  |................|
17feffe50  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
17feffe70  00 e0 7f 00 00 00 00 58  d0 fd 30 96 01 b3 2a 1c  |.......X..0...*.|
17feffe80  63 02 ae 48 8f 97 fa 00  00 00 00 00 00 00 00 00  |c..H............|
17feffe90  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
17fffbe00  b6 7c 6e 51 cf 6e d6 11  8f f8 00 02 2d 09 71 2b  |.|nQ.n......-.q+|
17fffbe10  7b 36 59 45 eb 35 ef 11  b7 ac 08 00 27 c4 37 c5  |{6YE.5......'.7.|
17fffbe20  00 08 00 00 00 00 00 00  ff 07 40 00 00 00 00 00  |..........@.....|
17fffbe30  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
17fffbe80  b6 7c 6e 51 cf 6e d6 11  8f f8 00 02 2d 09 71 2b  |.|nQ.n......-.q+|
17fffbe90  7f f8 78 46 eb 35 ef 11  b7 ac 08 00 27 c4 37 c5  |..xF.5......'.7.|
17fffbea0  00 08 40 00 00 00 00 00  ff 07 80 00 00 00 00 00  |..@.............|
17fffbeb0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
17fffbf00  b6 7c 6e 51 cf 6e d6 11  8f f8 00 02 2d 09 71 2b  |.|nQ.n......-.q+|
17fffbf10  af 28 76 49 eb 35 ef 11  b7 ac 08 00 27 c4 37 c5  |.(vI.5......'.7.|
17fffbf20  00 08 80 00 00 00 00 00  ff f7 bf 00 00 00 00 00  |................|
17fffbf30  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
17ffffe00  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00  |EFI PART....\...|
17ffffe10  f7 6f 57 a0 00 00 00 00  ff ff bf 00 00 00 00 00  |.oW.............|
17ffffe20  01 00 00 00 00 00 00 00  28 00 00 00 00 00 00 00  |........(.......|
17ffffe30  d7 ff bf 00 00 00 00 00  73 92 35 31 eb 35 ef 11  |........s.51.5..|
17ffffe40  b7 ac 08 00 27 c4 37 c5  df ff bf 00 00 00 00 00  |....'.7.........|
17ffffe50  80 00 00 00 80 00 00 00  ab 8c ea 1a 00 00 00 00  |................|
17ffffe60  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

As the black highlighted data in both test cases shows, the secondary GPT table in the last sector of the disk is intact.

gmirror(8) is writing the metadata on the providers (partitions), not disks last sector, nicely visible on the second, multi-partition test case.

The GPT partitions were added with -a 1m alignment, the test outcome is the same with partitions added with no alignment
 
T-Daemon curious about the actual sequence of steps. One of Michael Lucas books talks about this and the steps are roughly (going by memory because I'm too lazy to grab the book off the shelf):
gpart destroy -F ada0
gpart destroy -F ada1
gpart create -s gpt ada0
gpart create -s gpt ada1
At this point, there has been zero partitioning actually done
gmirror label mirror0 ada0
gmirror insert mirror0 ada1
Now we've actually created the mirror, then do the partitioning on the mirror
gpart add -t freebsd-boot -l boot -s 512K mirror/mirror0
and so on.

I think by doing that, creating the partitions on the mirror device it may avoid the issues
 
I think by doing that, creating the partitions on the mirror device it may avoid the issues
Your scenario above describes the situation where both GPT and gmirror(8) are being presented with a whole disk, and my understanding is that they both want the last sector of that disk for their own use. I think that the documentation is muddled because GPT was invented long after geom(8) and it's providers.

I don't perceive any problem when gmirror(8) is presented with partitions, as demonstrated by T-Daemon, above.
 
Back
Top