Bug 170945 - [gpt] disk layout not portable between direct connect and USB bridge
Summary: [gpt] disk layout not portable between direct connect and USB bridge
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-23 23:30 UTC by Dieter
Modified: 2018-01-03 05:16 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dieter 2012-08-23 23:30:06 UTC
With a SATA drive connected to a SATA controller, we get:
       start        size  index  contents
           0           1         PMBR
           1           1         Pri GPT header
           2          32         Pri GPT table
          34           6      1  GPT part - FreeBSD UFS/UFS2
          40  5860533095      2  GPT part - FreeBSD UFS/UFS2
  5860533135          32         Sec GPT table
  5860533167           1         Sec GPT header

(The 6 sector partition is for 4KiB alignment.)

With a USB bridge, we get this:
      start       size  index  contents
          0          1         PMBR
          1          1         Pri GPT header
          2          4         Pri GPT table
          6          6      1  GPT part - FreeBSD UFS/UFS2
         12  732566573      2  GPT part - FreeBSD UFS/UFS2
  732566585         55
  732566640          4         Sec GPT table
  732566644          1         Sec GPT header

Note that these are 4 KiB sectors, so the GPT header no longer
starts at 512, it now starts at 4096. It does work, so long as
we have the disk attached to the USB bridge.

But move the disk from the USB bridge to a direct sata controller,
and it breaks:
       start        size  index  contents
           0           1         PMBR
           1  5860533167

The GPT headers are not found, thus the partitions are not found. Unusable.
I suspect that moving a disk in the opposite direction is probably
broken as well.

[ Yes, with the USB's 4 KiB sectors the 6 sector alignment partition
is not needed. And with just one large data partition we can skip
partitioning and just newfs the drive. ]

Fix: 

Have the kernel look for a GPT header at 4096 as well as at 512.
(And similarly for the secondary header.)
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2012-08-24 00:16:39 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-fs

Over to maintainer(s).
Comment 2 Andrey V. Elsukov freebsd_committer freebsd_triage 2012-08-24 12:29:04 UTC
Hi,

GPT uses logical block addresses, not bytes.
So, if you changed sector size, then you lose the access to the GPT.
If you want get access to GPT, that has been created on the device with
4k sized sector, then you can use geom_nop(4).

-- 
WBR, Andrey V. Elsukov
Comment 3 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:19 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped