Page MenuHomeFreeBSD

Make detection of GPT a bit more reliable.
ClosedPublic

Authored by ae on Nov 26 2015, 8:46 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Jan 8, 9:52 AM
Unknown Object (File)
Nov 30 2024, 10:48 PM
Unknown Object (File)
Oct 25 2024, 11:30 PM
Unknown Object (File)
Oct 22 2024, 4:09 PM
Unknown Object (File)
Oct 19 2024, 3:31 AM
Unknown Object (File)
Oct 19 2024, 3:30 AM
Unknown Object (File)
Oct 19 2024, 3:30 AM
Unknown Object (File)
Oct 19 2024, 3:30 AM
Subscribers

Details

Summary

Currently GEOM_PART_GPT doesn't try to detect GPT, when it didn't found
PMBR's signature. This patch changes this behavior.

When we are probing GPT and didn't found PMBR, try to find backup GPT,
then if it is found, report about it with low priority.

Test Plan
# mdconfig -s 100m
md0
# gpart create -s gpt md0
md0 created
# gpart show md0
=>    40  204720  md0  GPT  (100M)
      40  204720       - free -  (100M)

# gpart add -t freebsd-boot -s 128k md0
md0p1 added
# gpart add -t freebsd-ufs md0
md0p2 added
# gpart show md0
=>    40  204720  md0  GPT  (100M)
      40     256    1  freebsd-boot  (128K)
     296  204464    2  freebsd-ufs  (100M)

# gpart 
# dd if=/dev/zero of=/dev/md0 count=10
10+0 records in
10+0 records out
5120 bytes transferred in 0.003832 secs (1336214 bytes/sec)

GEOM: md0: the primary GPT table is corrupt or invalid.
GEOM: md0: using the secondary instead -- recovery strongly advised.

# gpart show md0
=>    40  204720  md0  GPT  (100M) [CORRUPT]
      40     256    1  freebsd-boot  (128K)
     296  204464    2  freebsd-ufs  (100M)

# gpart destroy -F md0
md0 destroyed
# gpart show md0
gpart: No such geom: md0.
# ./bootparttest md0
GEOM provider "md0" opened
Mediasize: 104857600 Bytes (204800 sectors)
Sectorsize: 512 Bytes
disk_open: disk0: unit 0, slice -1, partition -1 => 0x801620000
read 512 bytes from the block 0 [+0]
read 512 bytes from the block 1 [+0]
ptable_open: magic sequence not found
read 512 bytes from the block 1 [+0]
gpt_checkhdr: no GPT signature
read 512 bytes from the block 204799 [+0]
read 16384 bytes from the block 204767 [+0]
ptable_gptread: GPT detected
ptable_gptread: new GPT partition added
ptable_gptread: new GPT partition added
disk_insert: disk0: cached
disk_open: disk0: offset 0 => 0x801620000
	disk0:
  	disk0p1: FreeBSD boot           128KB
  	disk0p2: FreeBSD UFS            99MB
disk_close: disk0: closed => 0x801620000 [1]
#

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 1301
Build 1306: arc lint + arc unit

Event Timeline

ae retitled this revision from to Make detection of GPT a bit more reliable..
ae updated this object.
ae edited the test plan for this revision. (Show Details)
ae edited the test plan for this revision. (Show Details)
ae added a reviewer: marcel.

Check PMBR's data only when we have valid signature.

So, are there any objections?

sys/boot/common/part.c
639

If there's no PMBR, how do you even know to look for a GPT header? I'm not sure if it's valid to look at either a primary or secondary GPT header if the PMBR is invalid.

sys/boot/common/part.c
639

Currently we do not searching GPT when there is no PMBR. But PMBR don't have the backup copy and when it is damaged, GPT loses its fault-tolerance. I'm agree that the loader change can lead to increased number of read requests for empty disks, or when we have many disks without partition tables (i.e. in some sort of RAID, raidz). This is the main reason of this review.

rpokala edited edge metadata.
This revision is now accepted and ready to land.Dec 9 2015, 6:06 PM
This revision was automatically updated to reflect the committed changes.