[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: The backup GPT table is corrupt



Hi,

mick.crane wrote:
> root@courgette:/home/mick# gdisk /dev/sda
> ...
> Caution: invalid backup GPT header, but valid main header; regenerating
> backup header from main header.
> ...
> OK; writing new GUID partition table (GPT) to /dev/sda.
> ...
> The operation has completed successfully.
> ...
> root@courgette:/home/mick# gdisk /dev/sda
> ...
> 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: OK

That's strange. Can it be that the last block of the disk is bad ?

Please post the content of that block.
Refering to info from your initial post
> Units: sectors of 1 * 512 = 512 bytes
> Disk /dev/sda: 111.79 GiB, 120034123776 bytes, 234441648 sectors
this would be

  sudo dd bs=512 count=1 if=/dev/sda skip=234441647 | \
  od -t x1 >/tmp/gpt_backup_header.hex

The header is not supposed to contain private information beyond what
you already posted.


Background info:

The header CRC consists of 4 bytes at offset 16 and covers the first
92 bytes of the block while the CRC field is still 0.

In my cheat sheet for boot sectors i read that it has generating
polynomial 0x104c11db7 and seed value 0x46af6449. The result gets
bit-wise swapped (0 <-> 31, 1 <-> 30, ...), exored with 0xffffffff,
and stored as little-endian number.

Probably one can get it by cksum(1) out of coreutils.

According to Wikipedia it is used by an impressive list of standards.
See the first "CRC-32" under "Polynomial representations" of
  https://en.wikipedia.org/wiki/Cyclic_redundancy_check

(If not, then i plan to rip the function iso_crc32_gpt() out of
libisofs:
  https://sources.debian.org/src/libisofs/1.5.6.pl01-1.1/libisofs/system_area.c#L2575
Its implementation matches CRC tutorials in the web.
Other implementations are in
  https://sources.debian.org/src/gdisk/1.0.10-2/crc32.cc?hl=32#L32
  https://sources.debian.org/src/syslinux/3%3A6.04~git20190206.bf6db5b4%2Bdfsg1-3.2/utils/isohybrid.c#L765
Both are table driven. Fast but somewhat uneducational.
)


Have a nice day :)

Thomas


Reply to: