accidentally deleted GPT table --(stupid stupid)

mickier

Renowned Member
Oct 27, 2015
4
0
66
GEORGIA
Today I was replacing one of eight 8TB drives on my proxmox ve server ZFS pool. I needed to swap /dev/sdd, and long story short, while comparing the GPT table with /dev/sda, I deleted the GPT table on /dev/sda... instead of /dev/sdd the new replacement drive.

I got the great error "disk is currently in use"... dang it and realized I hit it on the wrong drive! But the server's still running until I reboot or reload I guess(!)

Anyway - my question is this: I have the partition table from before the screwup, and in fact all 8 of the drives have the same partition table, isn't there a way to recreate the GPT table and PRESTO - I'm fine?

Otherwise, I'll just let /dev/sdd finish resilvering and then replace /dev/sda...

Was really hoping someone here would help me save myself...

FWIW it's Proxmox 8.4.1 on a DL730, and I used the proxmox ve installer to build the 8 drive RAIDZ2 array as the boot and main store.

not that anybody cares, but I usually use these steps to replace a bad drive
sgdisk /dev/sda -R /dev/sdd (assuming /dev/sda is good and /dev/sdd is the new drive)
sgdisk -G /dev/sdd
proxmox-boot-tool format /dev/sdd2
proxmox-boot-tool init /dev/sdd2
lsblk -dpo NAME,SERIAL,WWN (to get the WWN)
zpool replace rpool /dev/disk/by-id/(bad disk id-disk3) /dev/disk/by-id/(newdisk id-disk3)

(and the reason I was dorking around in fdisk was the new drive was 512e not 4Kn
and I got an error because partition2 was only 1/8th the needed size because the block size was 512)
That's another thing I need help working around if it's possible...but for now using another 4Kn to replace the bad drive...

But can I do sgdisk /dev/sdb -R /dev/sda and proxmox-boot-tool format and init to fix my mistake? or is there something else I have to do?
 
Short answer, in my opinion, yes, that's enough, but you have to do that before adding the disk again to the array. I've gone through this process several times.

You need to treat that disk as if it was new / formatted and removed from the array, then prepare it (and copy/re-create the partitions) again before adding ("replace") it into the array.

This blog post explains the process in detail, cross-check and compare with the steps you have, which seem correct.
 
  • Like
Reactions: Kingneutron