cancel
Showing results for 
Search instead for 
Did you mean: 

The gpt partition table dmaged

SChen.11
Associate III

Hi, I read more wiki pages and found below command to partition emmc on uboot

setenv emmc_part "name=ssbl,size=2MiB;name=bootfs,type=linux,bootable,size=64MiB;name=rootfs,type=linux,size=512"
gpt write mmc 1 ${emmc_part}

When my board start up and execute above commands. I use gdisk to saw some error message.

gdisk -l /dev/mmcblk1
GPT fdisk (gdisk) version 1.0.1
 
Caution: invalid backup GPT header, but valid main header; regenerating
backup header from main header.
 
Warning! One or more CRCs don't match. You should repair the disk!
 
Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: damaged
 
****************************************************************************
Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.
****************************************************************************
Disk /dev/mmcblk1: 7733248 sectors, 3.7 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 00042021-0408-4601-9DCC-A8C51255994F
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 7733214
Partitions will be aligned on 2-sector boundaries
Total free space is 7598012 sectors (3.6 GiB)
 
Number  Start (sector)    End (sector)  Size       Code  Name
   1              34            4129   2.0 MiB     0700  ssbl
   2            4130          135201   64.0 MiB    8300  bootfs
   3          135202          135202   512 bytes   8300  rootfs

So, I am confused about this. The GPT shows damaged.

1 REPLY 1
Christophe Guibout
ST Employee

Hi @Community member​ ,

I see two potential issues :

- the backup GPT is not placed where it should be (offset issue), in that case, before creating new GPT table, erase it before :

sgdisk -o -Z /dev/mmcblk1

- The size of rootfs partition seems to be a bit small (512 bytes), maybe 512 MiB would be better.

Anyway, I tried to reproduice it on my side by modifying the GPT table in u-boot, and check if modifications are taken into account without any error on backup GPT table:

1) Check that everything is fine (initial conditions)

root@stm32mp1:~# gdisk -l /dev/mmcblk0
GPT fdisk (gdisk) version 1.0.4
 
Partition table scan:
 MBR: protective
 BSD: not present
 APM: not present
 GPT: present
 
Found valid GPT with protective MBR; using GPT.
Disk /dev/mmcblk0: 31116288 sectors, 14.8 GiB
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 97C3E279-9EC4-4D8C-9DBA-20F3D3C3B81D
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 3145694
Partitions will be aligned on 2-sector boundaries
Total free space is 0 sectors (0 bytes)
 
Number Start (sector)   End (sector) Size      Code Name
  1             34            545  256.0 KiB  8301 fsbl1
  2            546           1057  256.0 KiB  8301 fsbl2
  3           1058           5153  2.0 MiB    8301 ssbl
  4           5154         136225  64.0 MiB   8300 bootfs
  5         136226         168993  16.0 MiB   8300 vendorfs
  6         168994        1705857  750.4 MiB  8300 rootfs
  7        1705858        3145694  703.0 MiB  8300 userfs

2) Update GPT table in u-boot (increase rootfs partition size)

mmc dev 0
setenv emmc_part "name=fsbl1,size=256KiB;name=fsbl2,size=256KiB;name=ssbl,size=2MiB;name=bootfs,type=linux,bootable,size=64MiB;name=vendorfs,type=linux,size=16MiB;name=rootfs,type=linux,size=768MiB;name=userfs,type=linux,size=600MiB"
gpt write mmc 0 ${emmc_part}

3) Check is modification are OK without any error :

root@stm32mp1:~# gdisk -l /dev/mmcblk0
GPT fdisk (gdisk) version 1.0.4
 
Partition table scan:
 MBR: protective
 BSD: not present
 APM: not present
 GPT: present
 
Found valid GPT with protective MBR; using GPT.
Disk /dev/mmcblk0: 31116288 sectors, 14.8 GiB
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 54B02E87-0600-4775-B5D0-5621F9B65990
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 31116254
Partitions will be aligned on 2-sector boundaries
Total free space is 28145597 sectors (13.4 GiB)
Number Start (sector)   End (sector) Size      Code Name
  1             34            545  256.0 KiB  0700 fsbl1
  2            546           1057  256.0 KiB  0700 fsbl2
  3           1058           5153  2.0 MiB    0700 ssbl
  4           5154         136225  64.0 MiB   8300 bootfs
  5         136226         168993  16.0 MiB   8300 vendorfs
  6         168994        1741857  768.0 MiB  8300 rootfs
  7        1741858        2970657  600.0 MiB  8300 userfs

GPT update is taken into account and no backup GPT issue. Of course, in that case, userfs partition needs to be formated to be usable.

If it doesn't help, please dump your GPT table in order to look into.

BR,

Christophe

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.