Solved Corrupt GPT Table

I am getting
Code:
Nov 3 22:03:32 anthem kernel: GEOM: ada3: the primary GPT table is corrupt or invalid.
Nov 3 22:03:32 anthem kernel: GEOM: ada3: using the secondary instead -- recovery strongly advised.
This started in October where I took an ext4 drive and made /dev/ada3 a zpool drive, naming it Backup. I created the zfs dataset called Backup.

zpool status shows:
Code:
pool: Backup
state: ONLINE
scan: none requested
config:

NAME STATE READ WRITE CKSUM
Backup ONLINE 0 0 0
ada3 ONLINE 0 0 0

errors: No known data errors
When I execute gdisk, I get

Code:
(23:47)ROOT@anthem:/root# gdisk /dev/ada3
GPT fdisk (gdisk) version 1.0.5

NOTE: Write test failed with error number 1. It will be impossible to save
changes to this disk's partition table!
You may be able to enable writes by exiting this program, typing
'sysctl kern.geom.debugflags=16' at a shell prompt, and re-running this
program.

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

Warning: Invalid CRC on main header data; loaded backup partition table.
Warning! Main and backup partition tables differ! Use the 'c' and 'e' options
on the recovery & transformation menu to examine the two tables.

Warning! Main partition table CRC mismatch! Loaded backup partition table
instead of main partition table!

Warning! One or more CRCs don't match. You should repair the disk!
Main header: ERROR
Backup header: OK
Main partition table: ERROR
Backup partition table: OK

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.
****************************************************************************

Command (? for help):

I would like to recover the disk, as a learning experience. However, it is one of two backup drives, so it would be no loss to nuke it.

oh, gpart recover ada3 failed.

TIA

-JJ
 
What are the outputs of gpart show ada3 and gpart recover ada3?

Did you take the whole ada3 as zfs pool? And if yes, has this disk used before?
 
You assigned the entire disk to ZFS. That overwrites the partition table.
 
But then why am I getting the error?
Because it's only partially overwritten. That corrupted it. Because there are still some remnants gpart(8) will start to complain about it. When you want to add the whole drive to the pool it's a good idea to remove any existing partitioning information; gpart destroy <drive>.
 
For your information, you have a backup header & a partition table at the end of the disk if it had had a GPT scheme. This information typically persists and alert the system about possible corruption.

It's a better practice to add a partition in a pool (even if this partition take the entire disk), not directly the whole disk.
 
Since I converted the whole computer to FreeBSD, SirDice's suggestion explained what had happened and his solution worked.
The idea of using the whole disk... is just what I did. I really can't give a reason for one way or another. Given the speed of computers, today, I don't think there is a performance gain either way.

-JJ
 
I didn't speak about performance, I spoke about the fact it's safer to have a GPT scheme to avoid what happened to you. Most softwares aren't zfs aware, but they understand what is a GPT scheme.

If you leave no scheme on a disk, some of them might behave badly.
 
  • Thanks
Reactions: a6h
If I'm running a pure FreeBSD computer, then wouldn't a non-GPT partition be okay. My problem was not cleaning the disk, if there is such a thing.
 
Back
Top