I have a bit of an unusual case that I don't think TestDisk covers currently but may be able to cover in the future possibly.

As I was trying to install a new distribution I accidentally gdisk'd /dev/sda instead of /dev/sdc and deleted all of the partitions off of my data drive. I also wrote to the device a new GPT partition table label with a 2G EFI partition and a Linux Filesystem partition that filled the rest of the disk. I later then deleted the two partitions and made an ext4 partition that filled the rest of the device. At this point forward I have done a complete dd backup of the 1.8TiB drive and am working on the backed up identical drive (also 1.8TiB). I never mkfs'ed the device so the data should all be there.

Using TestDisk, I am shown scrambled partitions like MS Dos or Mac as the Filesystem when I select Intel/PC or EFI GPT. However, when I select "None" TestDisk happily reveals to me my ext4 filesystem but 'p' shows no files due to corruption and I am also unable to write to disk due to the previous "None" option. At first I was confused but later I realized I must have formatted the Data drive with Gnome's Disk Utility and with no partitioning and just an ext4 filesystem. Successful mountings of the device itself on the superblock backups 65536, 131072, etc (but not 32768) confirm to me that this is in fact the case.

However, after mounting, while the first directory of folders exists, when I entered those directories I was given a "Structure needs cleaning" error for the majority of the files and folders. Running e2fsck with the superblock backups failed to fix the problem but left me with 29GiB of the original 1TiB of data (the folders & files without "Structure needs cleaning" errors) of the 1.8TiB drive. Lost+Found did not contain any of the remaining data either.

A friend on IRC tried reproducing my steps on his own setup and also came to the same error of "Structure needs cleaning". So far this is as far as we have got. Does anyone have any ideas on how I could salvage the rest of the data? I'll be posting our further attempts below for anyone that happens to chance upon this post in the future!

If fsck now find the filesystem in a clean state and your files are still missing (files not listed and not present in lost+found), you can try PhotoRec to recover them but it will not recover the original filenames.

We have tried PhotoRec and it has restored all files but without their names. It would really be impossible for us to sort out all of the files for our various code and piece them together however we are planned to do that as a last resort.

From my own investigations I realize I have deleted the first 33792 bytes of the EXT4 filesystem with gdisk. The ext4 feature flex_bg was activated previously on the ext4 filesystem but 1024 blocks of GDT were also written so i'm hoping no data bitmaps, inode bitmaps, or inode tables were overwritten. As we have not ever resized the disk.

Is there nothing else that can be done? Also should I be using the Allow partial last cylinder in my case for PhotoRec?