Opened 4 years ago

Closed 4 years ago

#12170 closed bug (fixed)

GPT corruption with more than one partition

Reported by: kallisti5 Owned by: jessicah
Priority: critical Milestone: R1/beta1
Component: Partitioning Systems/GPT Version: R1/Development
Keywords: GPT Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

Creating a few partitions (more than 1) will result in GPT corruption per gdisk. For example below, create 8 partitions on one disk, then read that disk with gdisk.

$ gdisk test.raw 
GPT fdisk (gdisk) version 0.8.10

Caution! After loading partitions, the CRC doesn't check out!
Warning! Main and backup partition tables differ! Use the 'c' and 'e' options
on the recovery & transformation menu to examine the two tables.

Warning! One or more CRCs don't match. You should repair the disk!

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

Found invalid MBR and corrupt GPT. What do you want to do? (Using the
GPT MAY permit recovery of GPT data.)
 1 - Use current GPT
 2 - Create blank GPT

Your answer: 1

Command (? for help): p
Disk test.raw: 204800 sectors, 100.0 MiB
Logical sector size: 512 bytes
Disk identifier (GUID): 82009838-FFFF-FFFF-3898-0082FFFFFFFF
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 204766
Partitions will be aligned on 8-sector boundaries
Total free space is 90045 sectors (44.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1           49192           65575   8.0 MiB     A501  
   5           49192           65575   8.0 MiB     A501  
   6           65576           81959   8.0 MiB     A581  
   7           81960           98343   8.0 MiB     A902  
   8           98344          114727   8.0 MiB     A901  
   9              40           16423   8.0 MiB     EB00  
  10           16424           32807   8.0 MiB     8300  
  11           32808           49191   8.0 MiB     AB00  
  12           49192           65575   8.0 MiB     A501  

Command (? for help): v

Problem: The CRC for the main partition table is invalid. This table may be
corrupt. Consider loading the backup partition table ('c' on the recovery &
transformation menu). This report may be a false alarm if you've already
corrected other problems.

Caution: The CRC for the backup partition table is invalid. This table may
be corrupt. This program will automatically create a new backup partition
table when you save your partitions.

Problem: partitions 5 and 1 overlap:
  Partition 5: 49192 to 65575
  Partition 1: 49192 to 65575

Problem: partitions 12 and 1 overlap:
  Partition 12: 49192 to 65575
  Partition 1: 49192 to 65575

Problem: partitions 12 and 5 overlap:
  Partition 12: 49192 to 65575
  Partition 5: 49192 to 65575

Identified 5 problems!

Command (? for help): 

Given the "65575" it looks like there is some overflow somewhere. Our GPT code places partitions on-top of each other :-\

Change History (4)

comment:1 Changed 4 years ago by kallisti5

Milestone: R1R1/beta1
Priority: highcritical

Bumping to beta 1 as this could easily result in data-loss.

comment:2 Changed 4 years ago by jessicah

Owner: changed from axeld to jessicah
Status: newassigned

I'll start looking into this. I'm familiar enough with GPT, and can reproduce many of the issues with Haiku's support for disk images easily (diskimage is so cool!). May even look into what it will take to port gdisk to Haiku... ;-)

comment:3 Changed 4 years ago by kallisti5

gdisk ported would be nice, but not really a requirement as we have our own GUI tool that works :P

Our GUID was successfully accepted a while back, most GPT applications show it now. We've taken over the BeOS eb00 moniker. Our slow Be assimilation is almost complete. (buwahahaha?)

Hex code or GUID (L to show codes, Enter = 8300): L
.
.
eb00 Haiku BFS             ed00 Sony system partitio  ed01 Lenovo system partit
.
.

comment:4 Changed 4 years ago by kallisti5

Resolution: fixed
Status: assignedclosed

Resolved as of hrev49667. Tested functional on hrev49669. Nice work jessicah!

$ gdisk test-gpt.img 
GPT fdisk (gdisk) version 1.0.0

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

Found valid GPT with corrupt MBR; using GPT and will write new
protective MBR on save.

Command (? for help): p
Disk test-gpt.img: 2097152 sectors, 1024.0 MiB
Logical sector size: 512 bytes
Disk identifier (GUID): 230DDDCA-B80E-EA4F-90FD-DF416876B88B
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 2097118
Partitions will be aligned on 8-sector boundaries
Total free space is 1981 sectors (990.5 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              40          327719   160.0 MiB   EB00  
   2          327720         1036327   346.0 MiB   EB00  
   3         1036328         2095143   517.0 MiB   EB00  

Command (? for help): q
Note: See TracTickets for help on using tickets.