View Issue Details

IDProjectCategoryView StatusLast Update
0000302fileGeneralpublic2021-12-06 22:13
Reportercalestyo Assigned Tochristos  
PrioritynormalSeverityminorReproducibilityhave not tried
Status assignedResolutionopen 
Product Version5.41 
Summary0000302: GPT not correctly detected as such, because of it's protective MBR
DescriptionHey.

A file that contains a GPT (GUID Partition Table) is nonetheless detected as MBR, which is probably because every GPT contains a protective MBR just at the position where the regular MBR would be.

E.g.:
# gdisk -l example.img
GPT fdisk (gdisk) version 1.0.6

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk example.img: 16777216 sectors, 8.0 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): C93252EC-C2A3-41C8-9A12-ECF030C66D7E
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 16777182
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number Start (sector) End (sector) Size Code Name
   1 2048 67583 32.0 MiB EF00 EFI system partition
   2 67584 16777182 8.0 GiB 8300 Linux filesystem


whereas file only detects the MBR:
# file example.img
example.img: DOS/MBR boot sector; partition 1 : ID=0xee, start-CHS (0x0,0,2), end-CHS (0x3ff,255,63), startsector 1, 16777215 sectors, extended partition table (last)


Not really sure how one should (safely) detect a GPT.

The protective MBR always looks like this:
Expert command (? for help): o

Disk size is 16777216 sectors (8.0 GiB)
MBR disk identifier: 0x00000000
MBR partitions:

Number Boot Start Sector End Sector Status Code
   1 1 16777215 primary 0xEE

i.e. always type 0xEE ... but that alone is AFAIU not enough to say there's a GPT... furthermore, GPTs may not use a protective MBR at all.


The best is perhaps to just rely on the GPT signature, which is:
EFI PART at 0x0 (and I think with respect to the endianess)
(see https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_table_header_(LBA_1) )


Not sure if it makes sense to check for the backup GPT, probably not.

Cheers,
Chris.
TagsNo tags attached.

Activities

christos

2021-12-06 20:07

manager   ~0003682

file just does not look after the MBR for the GPT information... It could be made to look, but currently it does not.

calestyo

2021-12-06 22:13

reporter   ~0003683

Guess that would make sense... just like it looks deeper into various container formats to find out what's actually inside.

Issue History

Date Modified Username Field Change
2021-12-04 03:35 calestyo New Issue
2021-12-06 20:06 christos Assigned To => christos
2021-12-06 20:06 christos Status new => assigned
2021-12-06 20:07 christos Status assigned => feedback
2021-12-06 20:07 christos Note Added: 0003682
2021-12-06 22:13 calestyo Note Added: 0003683
2021-12-06 22:13 calestyo Status feedback => assigned