New issue
Advanced search Search tips

Issue 650362 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Sep 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

plain 'cpgt create' create empty PMBR

Project Member Reported by gwendal@chromium.org, Sep 26 2016

Issue description

On a chromebook with a USB stick (sdb) (pixel)
Running 

target_disk=/dev/sdb
cgpt create ${target_disk}
cgpt add -i 6 -b 64 -s 32768 -S 1 -P 5 -l KERN-A -t "kernel" ${target_disk}
blockdev --rereadpt ${target_disk}

The partition /dev/sdb6 is not created.
Kernel complains:
[  128.283541] sd 4:0:0:0: [sdb] No Caching mode page found
[  128.288172] sd 4:0:0:0: [sdb] Assuming drive cache: write through
[  128.295508]  sdb: unknown partition table

But gpt looks valid:
cgpt show /dev/sdb
       start        size    part  contents
           0           1          PMBR
           1           1          Pri GPT header
           2          32          Pri GPT table
          64       32768       6  Label: "KERN-A"
                                  Type: ChromeOS kernel
                                  UUID: A7167A7E-5F72-ED40-9C03-8D194F87CB39
                                  Attr: priority=5 tries=0 successful=1
    15466463          32          Sec GPT table
    15466495           1          Sec GPT header

However, od shows the PMBR is empty:
od -X -c /dev/sdb | less
0000000        00000000        00000000        00000000        00000000
         \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
*
0001000        20494645        54524150        00010000        0000005c
          E   F   I       P   A   R   T  \0  \0 001  \0   \  \0  \0  \0
0001020        76ed828c        00000000        00000001        00000000
        214 202 355   v  \0  \0  \0  \0 001  \0  \0  \0  \0  \0  \0  \0
0001040        00ebffff        00000000        00000022        00000000
        377 377 353  \0  \0  \0  \0  \0   "  \0  \0  \0  \0  \0  \0  \0
0001060        00ebffde        00000000        887f53cd        ae421163
        336 377 353  \0  \0  \0  \0  \0 315   S 177 210   c 021   B 256
0001100        c2f0cfaa        dce57c09        00000002        00000000
        252 317 360 302  \t   | 345 334 002  \0  \0  \0  \0  \0  \0  \0
0001120        00000080        00000080        7d185a88        00000000

fdisk do not report any partition:
fdisk -l /dev/sdb
Disk /dev/sdb: 7.4 GiB, 7918845952 bytes, 15466496 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Compare with a valid USB image:
sudo fdisk -l /dev/sdg
GPT PMBR size mismatch (6905791 != 15646719) will be corrected by w(rite).
Disk /dev/sdg: 7.5 GiB, 8011120640 bytes, 15646720 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 93152BA6-B68D-184E-A6FF-E995CF5298C0

Device       Start     End Sectors  Size Type
/dev/sdg1  4382720 6873087 2490368  1.2G Microsoft basic data
/dev/sdg2    20480   53247   32768   16M ChromeOS kernel
/dev/sdg3   286720 4382719 4096000    2G ChromeOS root fs
....

sudo od -X -c /dev/sdg | less
0000000        00000000        00000000        00000000        00000000
         \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
*
0000640        00000000        00000000        6d27e151        6c42e495
         \0  \0  \0  \0  \0  \0  \0  \0   Q 341   '   m 225 344   B   l
0000660        41f6c19f        c527d1fe        00000000        00009a1d
        237 301 366   A 376 321   ' 305  \0  \0  \0  \0 035 232  \0  \0
0000700        ffee0002        0001ffff        5fbf0000        00000069
        002  \0 356 377 377 377 001  \0  \0  \0 277   _   i  \0  \0  \0
0000720        00000000        00000000        00000000        00000000
         \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
*
0000760        00000000        00000000        00000000        aa550000
         \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0   U 252
0001000        20494645        54524150        00010000        0000005c
          E   F   I       P   A   R   T  \0  \0 001  \0   \  \0  \0  \0
0001020        78cbc27b        00000000        00000001        00000000
          { 302 313   x  \0  \0  \0  \0 001  \0  \0  \0  \0  \0  \0  \0
0001040        00695fbf        00000000        00000022        00000000
        277   _   i  \0  \0  \0  \0  \0   "  \0  \0  \0  \0  \0  \0  \0



Our kernel will not recognize the GPT if the MBR is invalid / empty.


 

Comment 1 by vapier@chromium.org, Sep 26 2016

is it only with an external stick ?  what about a local file ?

cd /tmp
rm f
truncate -s 8G f
cgpt create f
Workaround:
Before cgpt create ...

do
fdisk ${target_disk}

enter 'g' to create a GPT partition. It also creates a valid protective MBR.

You can then continue the process of create a meaningful GPT with

cgpt create ${target_disk}
cgpt add ...


Scratch #2, cgpt can create the PMBR for you:

cgpt boot -p ${target_disk}
cgpt create ${target_disk}
cgpt add ...

Will create proper MBR and GPT.
Status: WontFix (was: Untriaged)

Comment 5 by vapier@chromium.org, Sep 27 2016

so what's the verdict ?  we think `cgpt create` *shouldn't* auto-populate the PMBR and people have to explicitly use `cgpt boot -p` ?

Sign in to add a comment