Recovering data from zfs pool with deleted partition tables
I was consolidating the hard drives from two nas's into one nas and when I put the hard drives from the second nas into the new enclosure, my raid card wiped the partition tables for all the connected drives. The 5 drives I was adding had previously been hardware raid-5 formatted with ext4 The 5 drives that were already in the nas had been zfs raidz. Both sets of drives had nearly identical data as I had mirrored them before doing this. The system is running Ubuntu Server. Is there any way to recover the data on either set of drives? I figure that recovering the partition table's on the zfs pool should be possible but I can't find a resource on how.
I ended up finding a reddit thread covering how to do this.
It involved rebuilding the partition tables using sgdisk
after figuring out where all the partitions should have gone. this was done by looking at the partition table for a zfs drive of the same model since it seems that zfs partitions drives in a very predictable manner.
In my case, the command was:
sgdisk -n1:2048:15628036095 -t1:BF01 -n9:15628036096:15628052479 -t9:BF07 <device>
which had to be run on every drive that had been part of the array after which zpool import <pool name>
was able to work and restore the array.
credit to fields_g on reddit: https://www.reddit.com/r/zfs/comments/d6v47t/deleted_disk_partition_tables_of_a_zfs_pool/f17yt5s/