A quick summary:
I have 500 GB SSD. There is only Ubuntu 20.04 installed in it.
I wrote win10.iso file inside of its EFI System Partition with dd command. After that I couldn't boot. Then I boot Ubuntu from usb. boot-repair told me to open 1mb (or something like that) space. I followed some instructions yet I failed. I would like the save the at least home folder. Half of the SSD was used. EFI part already overwritten but ext4 section where Ubuntu is installed is not overwritten.
Image (gparted): Initial situation. Before doing any gparted process.
Image (gparted): Information about EFI System Partition /dev/sda1
Image (gparted): After deleting EFI and Unmounting ext4
Here is what I did:
- I opened gparted.
- I delete the EFI system partition (
/dev/sda1
)
(For a second I thought it is better to unmount the ext4 to prevent some mistakes. It was late night.)
- I unmounted ext4 on gparted (
/dev/sda2
)
Right after I unmounted dev/sda2 partition -> /dev/sda1, /dev/sda2, unallocated (1.02MiB), collapsed into 1 unallocated file system.
I didn't write anything on the ssd (as far as I know) after this happened.
I only used fdisk -l
, lsblk -s
, df
, mount
/umount
commands.
Terminal Output (ubuntu-usb): fdisk -l
output -> sdb. , File system name was changed to sdb after booting from usb(ubuntu)
Terminal Output (ubuntu-usb): fsck - N /dev/sdb
output
Terminal Output (ubuntu-usb): Disk /dev/sdb specs, fdisk -l
output
After a lot of anxious reading I have some ideas, questions ...
Here is what I derived:
- I may have deleted the thing that called partition table.
- People offer using testdisk. But before testdisk -> Should or Shouldn't I use dd or ddrescue or dd_rescue to copy the disk. Some people suggest take the copy of SSD. Then take the copy of that copy and work on it.
I seek your help and your experience in order to understand what happened.
How can I pick a safe approach.
Thank you,
UPDATES:
- I am able to see my files with testdisk.
- gdisk output shows that
MBR:protective, GPT:present
- There is only 1 partition. testdisk output is:
Linux start(65 101 37) end(60801 47 46) size_in_sector(975720448)
- Before doing anything you can take a exact copy of your disk with ddrescue. Please read the part about ddrescue in testdisk documentation.
- After taking a copy of your disk, It is a useful practice to take the copy of that copy and work on the latter copy.
- I run testdisk on latest copy and made many experiment on it.
- By following the testdisk documentation I saved my datas.
Command Outputs:
sudo gdisk -l /dev/sda
:
GPT fdisk (gdisk) version 1.0.5
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 976773168 sectors, 465.8 GiB
Model: Samsung SSD 860
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): xxxxx
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 976773134
Partitions will be aligned on 2048-sector boundaries
Total free space is 976773101 sectors (465.8 GiB)
Number Start (sector) End (sector) Size Code Name
testdisk Outputs:
Image (testdisk): Partition output
Tue Oct 12 14:21:50 2021
Command line: TestDisk /debug
TestDisk 7.1, Data Recovery Utility, July 2019
Christophe GRENIER <[email protected]>
https://www.cgsecurity.org
OS: Linux, kernel 5.8.0-43-generic (#49~20.04.1-Ubuntu SMP Fri Feb 5 09:57:56 UTC 2021) x86_64
Compiler: GCC 9.2
ext2fs lib: 1.45.5, ntfs lib: libntfs-3g, reiserfs lib: none, ewf lib: none, curses lib: ncurses 6.1
/dev/sda: LBA, HPA, LBA48, DCO support
/dev/sda: size 976773168 sectors
/dev/sda: user_max 976773168 sectors
/dev/sda: native_max 976773168 sectors
Warning: can't get size for Disk /dev/mapper/control - 0 B - 0 sectors, sector size=512
Warning: can't get size for Disk /dev/loop6 - 0 B - 0 sectors, sector size=512
Warning: can't get size for Disk /dev/loop7 - 0 B - 0 sectors, sector size=512
Hard disk list
Disk /dev/sda - 500 GB / 465 GiB - CHS 60801 255 63, sector size=512 - Samsung SSD 860
Disk /dev/sdb - 15 GB / 14 GiB - CHS 14664 64 32, sector size=512 - SanDisk Cruzer Force, FW:1.00
Disk /dev/loop0 - 2109 MB / 2012 MiB - 4120632 sectors (RO), sector size=512
Disk /dev/loop1 - 53 MB / 51 MiB - 104536 sectors (RO), sector size=512
Disk /dev/loop2 - 32 MB / 31 MiB - 63664 sectors (RO), sector size=512
Disk /dev/loop3 - 229 MB / 218 MiB - 448496 sectors (RO), sector size=512
Disk /dev/loop4 - 58 MB / 55 MiB - 113592 sectors (RO), sector size=512
Disk /dev/loop5 - 67 MB / 64 MiB - 132648 sectors (RO), sector size=512
Partition table type (auto): Intel
Disk /dev/sda - 500 GB / 465 GiB - Samsung SSD 860 EVO 500GB
Partition table type: Intel
Interface Advanced
Geometry from i386 MBR: head=256 sector=63
check_part_i386 1 type EE: no test
1 P EFI GPT 0 0 2 60801 80 63 976773167
Analyse Disk /dev/sda - 500 GB / 465 GiB - CHS 60801 255 63
Geometry from i386 MBR: head=256 sector=63
check_part_i386 1 type EE: no test
Current partition structure:
1 P EFI GPT 0 0 2 60801 80 63 976773167
Warning: Bad ending head (CHS and LBA don't match)
No partition is bootable
search_part()
Disk /dev/sda - 500 GB / 465 GiB - CHS 60801 255 63
recover_EXT2: s_block_group_nr=0/3722, s_mnt_count=206/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8192
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 121965056
recover_EXT2: part_size 975720448
Filesystem created: Sun Jun 21 00:15:40 2020
Last mount time: Sat Oct 9 21:29:00 2021
Linux 65 101 37 60801 47 46 975720448
ext4 blocksize=4096 Large_file Sparse_SB, 499 GB / 465 GiB
Results
* Linux 65 101 37 60801 47 46 975720448
ext4 blocksize=4096 Large_file Sparse_SB, 499 GB / 465 GiB
Hint for advanced users: dmsetup may be used if you prefer to avoid rewriting the partition table for the moment:
echo "0 975720448 linear /dev/sda 1050624" | dmsetup create test0
interface_write()
1 * Linux 65 101 37 60801 47 46 975720448
simulate write!
write_mbr_i386: starting...
write_all_log_i386: starting...
No extended partition
TestDisk exited normally.