Invalid backup GPT header, overlapping partitions

Hello All,

I am new to OpenWRT < 1Month. I have a GL-iNet MT6000 and OpenWRT firmware is still in the snapshot phase, hence that is what I am using.

OpenWRT install and configuration seemed to go reasonably well and the device is functioning. It seems however that my partition table/layout was corrupted somewhere along the way. If you can read this, the router is still functioning.

I have worked with partitions on Windows machines but the drives were unmounted. I don't see a way to do that here.
I am new to Linux but can study some utilities. I have not done anything beyond initial investigation at this point.
See the gdisk report below.

I am looking for advice regarding the correct course of action, utilities and procedures. I am not concerned about having to flash and rebuild the configuration


OpenWrt login: root
Password:

BusyBox v1.36.1 (2024-03-11 08:58:20 UTC) built-in shell (ash)


| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -| || | | || || |
|
_____|| |
||||___||| |____|
|
| W I R E L E S S F R E E D O M

OpenWrt SNAPSHOT, r25464-79ee4cb039

root@OpenWrt:~# gdisk /dev/mmcblk0
GPT fdisk (gdisk) version 1.0.9

Caution: invalid backup GPT header, but valid main header; regenerating
backup header from main header.

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!
Main header: OK
Backup header: ERROR
Main partition table: OK
Backup partition table: ERROR

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.


Warning! Secondary partition table overlaps the last partition by
33 blocks!
You will need to delete this partition or resize it in another utility.

Command (? for help):


Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.


Warning! Secondary partition table overlaps the last partition by
33 blocks!
You will need to delete this partition or resize it in another utility.
root@OpenWrt:~#

Here is the existing partition table:

Command (? for help): p
Disk /dev/mmcblk0: 15269888 sectors, 7.3 GiB
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 2BD17853-102B-4500-AA1A-8A21D4D7984D
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 15269854
Partitions will be aligned on 1024-sector boundaries
Total free space is 8158 sectors (4.0 MiB)

Number Start (sector) End (sector) Size Code Name
1 8192 9215 512.0 KiB 8300 u-boot-env
2 9216 13311 2.0 MiB 8300 factory
3 13312 17407 2.0 MiB 8300 fip
4 17408 21503 2.0 MiB 8300 cfg
5 21504 25599 2.0 MiB 8300 log
6 25600 91135 32.0 MiB 8300 kernel
7 91136 15269887 7.2 GiB 8300 rootfs

The issue seemed to be that partition 7 was written to the end of the disk. This did not leave room for the backup GPT which then overlapped the end of partition 7. I believe I have solved this with the following gdisk commands in the OpenWRT terminal:

d - Delete partition 7
n - Create new partition 7. Same starting sector but 33K smaller. Type 8300 retained.
x - e - Enter expert mode to move backup GPT to end of disk.
v - Verify new configuration. Noticed name was changed.
c - change name to rootfs
v - Verify
w - Write changes
quit - exit gdisk
reboot

Memory fades but somewhere in there the backup GPT was still found to be corrupt. New backup GPT was written to end of disk with i believe e under the expert menu.

All seems fine now. There must have been no data on that last 32k. The corrupt backup file would have been occupying about half of that.

Thanks for listening...