ZFS and GPT Corrupted

Here is the background to the problem, and yes there was a user error in the process, but the data on the disk should be intact and recoverable. I'm looking for some experts on ZFS to help me with that.

I created a single whole disk zfs storage, but before doing this there was a GPT partition created with a freebsd-zfs partition. I realize this was probably not needed, but this where the steps while creating new storage pool.

$ gpt create -a 4k -b 2048 -t freebsd-zfs ada3
$ zpool create -f storage /dev/ada3

A few months later my root partition, not on ada3 was corrupted and I had to reinstall the system. During the re-installation process, I noticed a GPT trace during the boot complaining about GPT partition being corrupted, but could be recoverable.

I understand now that this was the mistake, however I ran gpt recover /dev/ada3, the system stopped complaining about the corrupted GPT partition and showed a single partition with freebsd-zfs on it as created above.

Once the installation finished I noticed that my zfs pool is not here, and so I started the investigation. zfs import was failing, However zdb -l /dev/ada3 shows 3 of the 4 labels intact.

I suspect the data on the disk should still be intact, does anyone have the inside on how to recover this state of the ZFS filesystem.
 
GPT metadata (partition tables) were written to the start and end of the disk. Then ZFS metadata overwrote one of those. At boot, if GPT tables are found, they are compared, and an error is shown if they do not match. gpart recover just copies the existing GPT to the missing one. In this case, that overwrote the ZFS metadata.

This is even more tragic because the GPT partition was not used.

If you have an identical disk, creating an identical ZFS setup on it and copying the metadata might work. I don't know exactly where or how big that metadata is. Make a binary backup of the damaged disk first.
 
Back
Top