I made a foolish mistake and copied an *img file over my /boot/efi partition instead of an SD card.
System:
Dell XPS15
Kubuntu 19.10
1 TB SSD
My system was set up to multiboot Kubuntu 19.10, Kubuntu 20.04, and Windows 10. I made a copy of my 'disk' to an external USB drive to analyze.
I've tried examining the disk using testdisk and it was able to see the partition information:
Current partition structure:
Bad GPT partition, invalid signature.
Trying alternate GPT
1 P EFI System 2048 1026047 1024000 [EFI system partition]
No FAT, NTFS, ext2, JFS, Reiser, cramfs or XFS marker
2 P MS Reserved 1026048 1288191 262144 [Microsoft reserved partition]
2 P MS Reserved 1026048 1288191 262144 [Microsoft reserved partition]
No FAT, NTFS, ext2, JFS, Reiser, cramfs or XFS marker
3 P MS Data 1288192 206043135 204754944 [Basic data partition]
3 P MS Data 1288192 206043135 204754944 [Basic data partition]
4 P Linux filesys. data 206043136 245104639 39061504
5 P Linux filesys. data 245104640 284165186 39060547
6 P Linux filesys. data 284166144 1973938175 1689772032
7 P Windows Recovery Env 1974859776 1998145535 23285760
8 P Windows Recovery Env 1998145536 2000408575 2263040
Backup partition structure
The partition information looks correct to me. At this point I'm not sure what I should do try recovering my drive. Which tools should I use? I've obviously looked at testdisk. Would ddrescue be able to help?
The file I was copying was about 500 MB and I (inadvertantly) copied it over the first partition of the drive. Although I'm a long-time Linux user, I've never had to do disk recovery before. Other than making a full backup of the drive using dd and running testdisk to look at the drive, I have not made any changes to it yet. What are my next steps? What tools should I use?
I'd really like to at least recover my data partition (partition 6 in the table above).
Thanks for any assistance.
[edit to add:] I tried listing files in testdisk for each of the partitions without any success (no files found).
I tried running gdisk. It did not see the partitions. The output is below:
kubuntu@kubuntu:~$ sudo gdisk /dev/sdb
GPT fdisk (gdisk) version 1.0.5
Caution: invalid main GPT header, but valid backup; regenerating main header
from backup!
Warning: Invalid CRC on main header data; loaded backup partition table.
Warning! Main and backup partition tables differ! Use the 'c' and 'e' options
on the recovery & transformation menu to examine the two tables.
Warning! Main partition table CRC mismatch! Loaded backup partition table
instead of main partition table!
Warning! One or more CRCs don't match. You should repair the disk!
Main header: ERROR
Backup header: OK
Main partition table: ERROR
Backup partition table: OK
Partition table scan:
MBR: MBR only
BSD: not present
APM: not present
GPT: damaged
Found valid MBR and corrupt GPT. Which do you want to use? (Using the
GPT MAY permit recovery of GPT data.)
1 - MBR
2 - GPT
3 - Create blank GPT
Your answer: 2
Command (? for help): p
Disk /dev/sdb: 3906963456 sectors, 1.8 TiB
Model: My Passport 25E1
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 91626CE4-3C38-4BF1-A7DD-0B4FA3BC3A15
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 3906963422
Partitions will be aligned on 2048-sector boundaries
Total free space is 4029 sectors (2.0 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 3906961407 1.8 TiB 0700 My Passport
It just sees the entire drive.