Need help recovering my partition table after using sgdisk

[EDIT]

I now only have that painful little “what if?” ember of hope left.

I think the writing is kind of on the wall at this point but in the hopes that my experience isn’t a total loss, I’d just like to share a few thoughts.

The first thing I want to say is that I didn’t lose my data because I made a mistake. I lost it because I made several mistakes, over the space of days, months, and even years. There’s only one person to blame for the lack of a backup… but I do find myself with renewed hope.

If there’s one thing I hope that comes out of this whole affair, it’s that I can serve as a cautionary tale. If you’re reading this and you don’t have your data backed up… I implore you to not put off setting up some form of backup! Even if it’s just an external HDD that you don’t backup to as often as you should!.. there’s a big difference between losing a month’s worth of data, and losing pretty much everything.

The thing that makes this whole thing doubly ironic is that literally just two days ago, the thought popped into my head that I really should sort out a backup for my boot disk. It wasn’t the first time that thought had popped into my head but I’m determined that it will be the last time.

After what I hope is a good night’s sleep, I’ll be creating a fresh install tomorrow. I’ll be writing a checklist of what needs installing and configuring. And right at the top, after I’ve created mirrored vdev (which if I had done with my now past install, probably would have saved my bacon), there will be setting up replication to my server.


Long story short… I have a Debian 12 install with root on ZFS, on a single disk (nvme0). The install was creating by following the OpenZFS documentation. I’m about 90% sure I followed the partitioning instructions exactly as they’re written but it is possible that I doubled the size of the UEFI and boot partitions.

I wanted to mirror this disk to another disk (nvme1) but have the second disk also be capable of booting. So I used the sgdisk --replicate= command to copy the EFI partition from one disk to the other… only I reversed the source and destinations in the sgdisk command. Which has rendered the system unbootable.

I’ve booted into a Debian 12 Live ISO and checked the nvme0 disk using gparted and there are no partitions present. I then started to scan nvme0 with testdisk, which did show an EFI partition but it also showed what it thought was NTFS partitions with the wrong cylinder (?) count. I stopped the testdisk scan and I am currently making dd images of both nvme0 and nvme1, to .ddimg files on a new (but tested) HDD.

I’ve read that testdisk doesn’t really support ZFS. I’ve also wondered whether there’s a way I could just recreate the partition table without destroying any data on my zpool… but I’m far too stupid to tackle this issue on my own.

So L1Ters, how screwed am I? How should I recover my data?

I think I might be screwed with a capital “F”…

I’ve made dd images of both the original install disk (nvme0) and the disk I tried copying the EFI to (nvme1). With the images created and having installed zfsutils, I then tried the following commands from the Debian Live ISO. Please note that I’ve used “XXXX” in place of the disk name because I just can’t be bothered to type it out.

lsblk -o NAME,SIZE,TYPE
ls -l /dev/disk/by-id/ | grep -E 'ata|nvme'

sudo zpool import
sudo zpool import -d /dev
sudo zpool import -d /dev/disk/by-id/XXXX
sudo zpool import -d /dev/disk/by-id/XXXX -o readonly=on -f
sudo zpool import -d /dev -o readonly=on -f
sudo zpool import -o readonly=on -f -R /mnt
sudo zpool import -o readonly=on -f -R /mnt rpool

ZFS label inspection

sudo zdb -l /dev/nvme0n1
sudo zdb -l /dev/nvme1n1
sudo zdb -l /dev/nvme0n1
sudo zdb -l /dev/nvme0n1p1
sudo zdb -l /dev/nvme0n1p2
sudo zdb -l /dev/nvme0n1p3

sudo zpool import -FX -o readonly=on -R /mnt rpool
sudo zdb -e rpool
sudo zdb -e -l /dev/nvme0n1

the zdb -l commands reported that no labels could be found. Which I’ve been told is game over.

As I have a dd image, I’m also giving testdisk a shot but I know it’s more than just a Hail Mary.

So I guess the only question left to ask now is, is professional data recovery a possibility?

I haven’t done this in many years but… *bump*… not so that I can get help (because at this point, I don’t think anyone can help) but so people can read the edit to my original post. I think it’s important that people read it.

I’m off to get a bowl of cereal and watch an episode of Star Trek.

P.S. The fan on my Icy Dock flexiDOCK MB830SP-B can go get bent.

Yes, most people think that won’t happen to me, I was one of them. :wink:
According to Murphy “Anything that can go wrong will go wrong.”
I had to learn this years ago, when I only had one backup copy of my data.
I lost four HDDs at once due to a short in a SAS backplane of my backup system, at a time when I had just destroyed the main zpool of my live system.
It wasn’t a complete data loss since only one Zpool was affected and most of it wasn’t irreplaceable.
But since then I’ve two backups of the important data and three of the irreplaceable data.
I would recommend separating the OS and data and use rotating ZFS snapshots.

And maybe this is something for you
https://www.urbackup.org/community.html