You are not logged in.

#1 2023-05-18 14:03:42

countrybooter
Member
Registered: 2023-04-25
Posts: 9

Are you an Expert with gdisk and know more than me?

DISCLAIMER: If you answer the topic question with "no," your response will most likely cause confusion.

The idea: detach myself from GUI tools and use the terminal, therefore I'm grateful that Arch exists and is maintained, thank you.

 2023-05-18 09:00:00 sudo gdisk /dev/sdX
GPT fdisk (gdisk) version 1.0.9.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!
Main header: OK
Backup header: ERROR
Main partition table: OK
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): /
b    back up GPT data to a file
c    change a partition's name
d    delete a partition
i    show detailed information on a partition
l    list known partition types
n    add a new partition
o    create a new empty GUID partition table (GPT)
p    print the partition table
q    quit without saving changes
r    recovery and transformation options (experts only)
s    sort partitions
t    change a partition's type code
v    verify disk
w    write table to disk and exit
x    extra functionality (experts only)
?    print this menu

Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): Y

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sdX.
The operation has completed successfully.
Command (? for help): v

No problems found. 7679999989 free sectors (28.6 TiB) available in 1
segments, the largest of which is 7679999989 (28.6 TiB) in size.
 2023-05-18 09:00:02 sudo partprobe /dev/sdX
Error: The backup GPT table is corrupt, but the primary appears OK, so that will be used.
 2023-05-18 09:00:04 sudo sgdisk -e /dev/sdX
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!
Main header: OK
Backup header: ERROR
Main partition table: OK
Backup partition table: OK

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

Seem's fixed, right... well, I would just like to understand what could be the reasons of why it's not fixed and what else could I try, because=

2023-05-18 09:00:05 sudo partprobe /dev/sdX
Error: The backup GPT table is corrupt, but the primary appears OK, so that will be used.
2023-05-18 09:00:06 sudo gdisk /dev/sdX 
GPT fdisk (gdisk) version 1.0.9.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!
Main header: OK
Backup header: ERROR
Main partition table: OK
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.
****************************************************************************

AFAIU, those are the low-level tools that are available, I've replaced /dev/nameofstoragedevice with /dev/sdX on purpose.

How do I use gdisk to repair the backup GPT table?


Thank you for your time, have a pleasant day.

PS: If someone can help me figure this out, I'll modify the title of the post to: 'Fix corrupted GPT table with sgdisk && gdisk' <3

Last edited by countrybooter (2023-05-19 08:44:46)

Offline

#2 2023-05-18 14:18:45

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: Are you an Expert with gdisk and know more than me?

No, I'm not an expert.  In fact, I'm not sure I've ever used gdisk.  But I am at least okay at googling:
https://www.rodsbooks.com/gdisk/repairing.html

I don't see any recovery attempts in your output despite being prompted to use them.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2023-05-19 08:47:20

countrybooter
Member
Registered: 2023-04-25
Posts: 9

Re: Are you an Expert with gdisk and know more than me?

Thank you for your response, my Lord.

Could I kindly request you to take a second look at the following two code snippets from my previous post.
AFAIU o/w should create a complete new GPT/backup the new GPT to the end of the disk and write a protective MBR for older systems.
Therefore if after gdisk itself writing the changes to the disk, gdisk itself still recognizes the newly created GPT/backup GPT as damaged, would it be worth posting about it?

Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): Y

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sdX.
The operation has completed successfully.

https://askubuntu.com/posts/1370440/revisions

 2023-05-18 09:00:04 sudo sgdisk -e /dev/sdX

As documented in the manual the -e option:

    -e, --move-second-header: Move backup GPT data structures to the end of the disk. Use this option if you've added disks to a RAID array, thus creating a virtual disk with space that follows the backup GPT data structures. This command moves the backup GPT data structures to the end of the disk, where they belong.

However, I fail to understand why neither of these two commands work in my case.

Therefore, even if it does not make sense to try to use the recovery options if not even starting from scratch helps (kind of why I named the title "Are you and Expert with gdisk", nevertheless...

 2023-05-19 09:00:00 sudo gdisk /dev/sdX 
GPT fdisk (gdisk) version 1.0.9.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!
Main header: OK
Backup header: ERROR
Main partition table: OK
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): x

Expert command (? for help): z
About to wipe out GPT on /dev/sdX. Proceed? (Y/N): y
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
Blank out MBR? (Y/N): y
 2023-05-19 09:00:01 sudo gdisk /dev/sdX
GPT fdisk (gdisk) version 1.0.9.1

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

Creating new GPT entries in memory.

Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): y

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdX.
The operation has completed successfully.
 2023-05-19 09:00:02 sudo gdisk /dev/sdX
GPT fdisk (gdisk) version 1.0.9.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!
Main header: OK
Backup header: ERROR
Main partition table: OK
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): r

Recovery/transformation command (? for help): /
b	use backup GPT header (rebuilding main)
c	load backup partition table from disk (rebuilding main)
d	use main GPT header (rebuilding backup)
e	load main partition table from disk (rebuilding backup)
f	load MBR and build fresh GPT from it
g	convert GPT into MBR and exit
h	make hybrid MBR
i	show detailed information on a partition
l	load partition data from a backup file
m	return to main menu
o	print protective MBR data
p	print the partition table
q	quit without saving changes
t	transform BSD disklabel partition
v	verify disk
w	write table to disk and exit
x	extra functionality (experts only)
?	print this menu

Recovery/transformation command (? for help): d

Recovery/transformation command (? for help): v

No problems found. 7679999989 free sectors (28.6 TiB) available in 1
segments, the largest of which is 7679999989 (28.6 TiB) in size.

Recovery/transformation command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdX.
The operation has completed successfully.
 
 2023-05-19 09:00:03
GPT fdisk (gdisk) version 1.0.9.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!
Main header: OK
Backup header: ERROR
Main partition table: OK
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): Love IT! 

I'm outnumbered.
Have a pleasant day.

EDIT: Thank you for your reply nl6720, sadly I've tried both already.

Last edited by countrybooter (2023-05-19 09:16:53)

Offline

#4 2023-05-19 09:11:11

nl6720
The Evil Wiki Admin
Registered: 2016-07-02
Posts: 592

Re: Are you an Expert with gdisk and know more than me?

If preserving the contents of the partition table is not a concern for you, then instead of repairing it, simply zap it all away:

# sgdisk -Z /dev/INSERT_DISK_HERE

Be warned that this command will not ask for confirmation!

Offline

Board footer

Powered by FluxBB