Also is it still recommended not to use GPT as the metadata clashes at the end of the disk?
Yes.
In FreeBSD, the GEOM framework permits access and control to classes, such as Master Boot Records and BSD labels, through the use of providers, or the disk devices in /dev.
docs.freebsd.org
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