bootparttest
I’m following this thread with great interest, and I wanted to try bootparttest
on one of my own computers.
Here is the result of running /usr/src/tools/tools/bootparttest
on the drives /dev/ada0
and /dev/ada1
:
GEOM provider "/dev/ada0" opened Mediasize: 500107862016 Bytes (976773168 sectors) Sectorsize: 512 Bytes /dev/ada0: read 1 blocks from the offset 0 [+0] /dev/ada0: read 1 blocks from the offset 1 [+0] ptable_open: PMBR detected /dev/ada0: read 1 blocks from the offset 1 [+0] /dev/ada0: read 32 blocks from the offset 2 [+0] /dev/ada0: read 1 blocks from the offset 976773167 [+0] ptable_gptread: new GPT partition added ptable_gptread: new GPT partition added ptable_gptread: new GPT partition added Partition table detected: GPT /dev/ada0p1: FreeBSD boot 128k /dev/ada0p2: FreeBSD swap 16G /dev/ada0p3: FreeBSD ZFS 449G GEOM provider "/dev/ada1" opened Mediasize: 500107862016 Bytes (976773168 sectors) Sectorsize: 512 Bytes /dev/ada1: read 1 blocks from the offset 0 [+0] /dev/ada1: read 1 blocks from the offset 1 [+0] ptable_open: PMBR detected /dev/ada1: read 1 blocks from the offset 1 [+0] /dev/ada1: read 32 blocks from the offset 2 [+0] /dev/ada1: read 1 blocks from the offset 976773167 [+0] ptable_gptread: new GPT partition added ptable_gptread: new GPT partition added ptable_gptread: new GPT partition added Partition table detected: GPT /dev/ada1p1: FreeBSD boot 128k /dev/ada1p2: FreeBSD swap 16G /dev/ada1p3: FreeBSD ZFS 449G
Here is how you should build bootparttest
:
root@enterprise:~>cd /usr/src/tools/tools/bootparttest root@enterprise:/usr/src/tools/tools/bootparttest>mkdir -p /usr/obj`pwd` root@enterprise:/usr/src/tools/tools/bootparttest>make gcc -I/usr/src/tools/tools/bootparttest/../../../sys/boot/common -I. -DLOADER_GPT_SUPPORT -DLOADER_MBR_SUPPORT -DPART_DEBUG -std=gnu99 -fstack-protector -c /usr/src/tools/tools/bootparttest/bootparttest.c ctfconvert -L VERSION bootparttest.o gcc -I/usr/src/tools/tools/bootparttest/../../../sys/boot/common -I. -DLOADER_GPT_SUPPORT -DLOADER_MBR_SUPPORT -DPART_DEBUG -std=gnu99 -fstack-protector -c /usr/src/tools/tools/bootparttest/../../../sys/boot/common/crc32.c ctfconvert -L VERSION crc32.o gcc -I/usr/src/tools/tools/bootparttest/../../../sys/boot/common -I. -DLOADER_GPT_SUPPORT -DLOADER_MBR_SUPPORT -DPART_DEBUG -std=gnu99 -fstack-protector -c /usr/src/tools/tools/bootparttest/malloc.c ctfconvert -L VERSION malloc.o gcc -I/usr/src/tools/tools/bootparttest/../../../sys/boot/common -I. -DLOADER_GPT_SUPPORT -DLOADER_MBR_SUPPORT -DPART_DEBUG -std=gnu99 -fstack-protector -c /usr/src/tools/tools/bootparttest/../../../sys/boot/common/part.c ctfconvert -L VERSION part.o gcc -I/usr/src/tools/tools/bootparttest/../../../sys/boot/common -I. -DLOADER_GPT_SUPPORT -DLOADER_MBR_SUPPORT -DPART_DEBUG -std=gnu99 -fstack-protector -lgeom -lutil -o bootparttest bootparttest.o crc32.o malloc.o part.o /usr/lib/libgeom.a /usr/lib/libutil.a ctfmerge -L VERSION -o bootparttest bootparttest.o crc32.o malloc.o part.o
The executable were placed in /usr/obj/usr/src/tools/tools/bootparttest
:
root@enterprise:/usr/src/tools/tools/bootparttest>pushd /usr/obj`pwd` /usr/obj/usr/src/tools/tools/bootparttest /usr/src/tools/tools/bootparttest root@enterprise:/usr/obj/usr/src/tools/tools/bootparttest>./bootparttest /dev/ada0; echo; ./bootparttest /dev/ada1 GEOM provider "/dev/ada0" opened Mediasize: 500107862016 Bytes (976773168 sectors) Sectorsize: 512 Bytes /dev/ada0: read 1 blocks from the offset 0 [+0] /dev/ada0: read 1 blocks from the offset 1 [+0] ptable_open: PMBR detected /dev/ada0: read 1 blocks from the offset 1 [+0] /dev/ada0: read 32 blocks from the offset 2 [+0] /dev/ada0: read 1 blocks from the offset 976773167 [+0] ptable_gptread: new GPT partition added ptable_gptread: new GPT partition added ptable_gptread: new GPT partition added Partition table detected: GPT /dev/ada0p1: FreeBSD boot 128k /dev/ada0p2: FreeBSD swap 16G /dev/ada0p3: FreeBSD ZFS 449G GEOM provider "/dev/ada1" opened Mediasize: 500107862016 Bytes (976773168 sectors) Sectorsize: 512 Bytes /dev/ada1: read 1 blocks from the offset 0 [+0] /dev/ada1: read 1 blocks from the offset 1 [+0] ptable_open: PMBR detected /dev/ada1: read 1 blocks from the offset 1 [+0] /dev/ada1: read 32 blocks from the offset 2 [+0] /dev/ada1: read 1 blocks from the offset 976773167 [+0] ptable_gptread: new GPT partition added ptable_gptread: new GPT partition added ptable_gptread: new GPT partition added Partition table detected: GPT /dev/ada1p1: FreeBSD boot 128k /dev/ada1p2: FreeBSD swap 16G /dev/ada1p3: FreeBSD ZFS 449G
Incidently, here’s a hex dump of the primary GPT header and the three entries currently in use on /dev/ada0
:
00000200 45 46 49 20 50 41 52 54 00 00 01 00 5c 00 00 00 |EFI PART....\...| 00000210 8b 9a f3 5f 00 00 00 00 01 00 00 00 00 00 00 00 |..ó_............| 00000220 2f 60 38 3a 00 00 00 00 22 00 00 00 00 00 00 00 |/`8:....".......| 00000230 0e 60 38 3a 00 00 00 00 6e 5a 1f 2c f9 39 e1 11 |.`8:....nZ.,ù9á.| 00000240 96 51 50 e5 49 41 4d 70 02 00 00 00 00 00 00 00 |.QPåIAMp........| 00000250 80 00 00 00 80 00 00 00 b5 e0 32 3c 00 00 00 00 |........µà2<....| 00000260 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000400 9d 6b bd 83 41 7f dc 11 be 0b 00 15 60 b8 4f 0f |.k½.A.Ü.¾...`¸O.| 00000410 3d 00 cc 3d f9 39 e1 11 96 51 50 e5 49 41 4d 70 |=.Ì=ù9á..QPåIAMp| 00000420 28 00 00 00 00 00 00 00 27 01 00 00 00 00 00 00 |(.......'.......| 00000430 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000480 b5 7c 6e 51 cf 6e d6 11 8f f8 00 02 2d 09 71 2b |µ|nQÏnÖ..ø..-.q+| 00000490 2d d5 57 64 f9 39 e1 11 96 51 50 e5 49 41 4d 70 |-ÕWdù9á..QPåIAMp| 000004a0 00 08 00 00 00 00 00 00 ff 07 00 02 00 00 00 00 |........ÿ.......| 000004b0 00 00 00 00 00 00 00 00 73 00 77 00 61 00 70 00 |........s.w.a.p.| 000004c0 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |0...............| 000004d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000500 ba 7c 6e 51 cf 6e d6 11 8f f8 00 02 2d 09 71 2b |º|nQÏnÖ..ø..-.q+| 00000510 8f 9e da 76 f9 39 e1 11 96 51 50 e5 49 41 4d 70 |..Úvù9á..QPåIAMp| 00000520 00 08 00 02 00 00 00 00 07 60 38 3a 00 00 00 00 |.........`8:....| 00000530 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| *
Here's my attempt at decoding the GPT header using http://en.wikipedia.org/wiki/GUID_Partition_Table as my guide:
Header field | Value |
---|---|
Signature | 4546492050415254 H = EFI PART ASCII |
Revision | 00010000 H = 1.0 |
Header size | 0000005C H = 92D |
CRC32 of header | 5FF39A8B H = 1609800331D |
Current LBA | 0000000000000001 H = 1D |
Backup LBA | 000000003A38602F H = 976773167D |
First usable LBA | 0000000000000022 H = 34D |
Last usable LBA | 000000003A38600E H = 976773134D |
Disk GUID | 2C1F5A6E39F911E1965150E549414D70 H = 2C1F5A6E-39F9-11E1-9651-50E549414D70 |
Starting LBA of array of partition entries | 0000000000000002 H = 2D |
Number of partitions entries | 00000080 H = 128D |
Size of single partition entry | 00000080 H = 128D |
CRC32 of partition array | 3C32E0B5 H = 1009967285D |
I even attempted to decode the first three partition entries:
Entry field | Value |
---|---|
Partition type GUID | 83BD6B9D7F4111DCBE0B001560B84F0F H = 83BD6B9D-7F41-11DC-BE0B-001560B84F0F |
Unique partition GUID | 3DCC003D39F911E1965150E549414D70 H = 3DCC003D-39F9-11E1-9651-50E549414D70 |
First LBA | 0000000000000028 H = 40D |
Last LBA | 0000000000000127 H = 295D |
Attribute flags | 0000000000000000 H = 0D |
Partition name | 0000 … 0000 H = no name recorded |
Entry field | Value |
---|---|
Partition type GUID | 516E7CB56ECF11D68FF800022D09712B H = 516E7CB5-6ECF-11D6-8FF8-00022D09712B |
Unique partition GUID | 6457D52D39F911E1965159E549414D70 H = 6457D52D-39F9-11E1-9651-59E549414D70 |
First LBA | 0000000000000800 H = 2048D |
Last LBA | 00000000020007FF H = 33556479D |
Attribute flags | 0000000000000000 H = 0D |
Partition name | 007300770061007000300000 … 0000 H = swap0 UTF-16LE |
Entry field | Value |
---|---|
Partition type GUID | 516E7CBA6ECF11D68FF800022D09712B H = 516E7CBA-6ECF-11D6-8FF8-00022D09712B |
Unique partition GUID | 76DA9E8F39F911E1965150E549414D70 H = 76DA9E8F-39F9-11E1-9651-50E549414D70 |
First LBA | 0000000002000800 H = 33556480D |
Last LBA | 000000003A386007 H = 976773127D |
Attribute flags | 0000000000000000 H = 0D |
Partition name | 0000 … 0000 H = no name recorded |
Microsoft's GUIDs are strange beasts with mixed endianness. My God, who other than Microsoft would devise such wierdness? It's utterly counterintuitive.