Score:0

How to restore GPT table from backup table?

co flag

I'm not sure if my disk is actually broken or just has some corrupt GPT data

fdisk /dev/sda

Welcome to fdisk (util-linux 2.36.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

fdisk: cannot open /dev/sda: Input/output error

This message saying "The primary GPT table is corrupt, but the backup appears OK, so that will be used." is confusing me since it can read the backup table but won't open it?

fdisk -l /dev/sda
The primary GPT table is corrupt, but the backup appears OK, so that will be used.
Disk /dev/sda: 10.91 TiB, 12000138625024 bytes, 23437770752 sectors
Disk model: ST12000NM001G-2M
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier:

Device           Start         End     Sectors  Size Type
/dev/sda1         2048 23437752319 23437750272 10.9T Solaris /usr & Apple ZFS
/dev/sda9  23437752320 23437768703       16384    8M Solaris reserved 1

I tried doing an fsck and it says Bad magic number in super-block

fsck /dev/sda
fsck from util-linux 2.36.1
e2fsck 1.46.2 (28-Feb-2021)
ext2fs_open2: Bad magic number in super-block
fsck.ext2: Superblock invalid, trying backup blocks...
fsck.ext2: Bad magic number in super-block while trying to open /dev/sda

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem.  If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>
 or
    e2fsck -b 32768 <device>

Found a gpt partition table in /dev/sda

I tried restoring the superblocks with mke2fs -n /dev/sda and e2fsck -b Doesn't seem to fix it either

e2fsck -b 819200 /dev/sda
e2fsck 1.46.2 (28-Feb-2021)
e2fsck: Bad magic number in super-block while trying to open /dev/sda

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem.  If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>
 or
    e2fsck -b 32768 <device>

Found a gpt partition table in /dev/sda
sfdisk -d /dev/sda > sda.dump
sfdisk: cannot open /dev/sda: Input/output error

There's a few errors appearing in dmesg

[ 5628.059240] ata9.00: exception Emask 0x0 SAct 0x4 SErr 0x0 action 0x0
[ 5628.059248] ata9.00: irq_stat 0x40000008
[ 5628.059250] ata9.00: failed command: READ FPDMA QUEUED
[ 5628.059252] ata9.00: cmd 60/08:10:20:00:00/00:00:00:00:00/40 tag 2 ncq dma 4096 in
                        res 43/40:08:20:00:00/00:00:00:00:00/00 Emask 0x409 (media error) <F>
[ 5628.059259] ata9.00: status: { DRDY SENSE ERR }
[ 5628.059261] ata9.00: error: { UNC }
[ 5628.142004] ata9.00: configured for UDMA/133
[ 5628.142012] sd 8:0:0:0: [sda] tag#2 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE cmd_age=4s
[ 5628.142014] sd 8:0:0:0: [sda] tag#2 Sense Key : Medium Error [current]
[ 5628.142016] sd 8:0:0:0: [sda] tag#2 Add. Sense: Unrecovered read error - auto reallocate failed
[ 5628.142017] sd 8:0:0:0: [sda] tag#2 CDB: Read(16) 88 00 00 00 00 00 00 00 00 20 00 00 00 08 00 00
[ 5628.142018] blk_update_request: I/O error, dev sda, sector 32 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
[ 5628.142023] Buffer I/O error on dev sda, logical block 4, async page read
[ 5628.142030] ata9: EH complete

The drive is part of a ZFS mirror, failing to restore the GPT table/superblocks I'd like to know if there's a way for me to wipe the drive so ZFS can resilver. Or should I just get a new drive?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.