I unmounted ext4 (Ubuntu OS) with gparted. Now it is unallocated. Testdisk shows 1 partition.

How to use TestDisk to recover lost partition
Forum rules
When asking for technical support:
- Search for posts on the same topic before posting a new question.
- Give clear, specific information in the title of your post.
- Include as many details as you can, MOST POSTS WILL GET ONLY ONE OR TWO ANSWERS.
- Post a follow up with a "Thank you" or "This worked!"
- When you learn something, use that knowledge to HELP ANOTHER USER LATER.
Before posting, please read https://www.cgsecurity.org/testdisk.pdf
Locked
Message
Author
xfaa
Posts: 1
Joined: 10 Oct 2021, 23:14

I unmounted ext4 (Ubuntu OS) with gparted. Now it is unallocated. Testdisk shows 1 partition.

#1 Post by xfaa »

Hello,
A quick summary:
I wrote onto EFI System Partition with dd command. I started Ubuntu with usb and check the partition with gparted.
It was like the following image.
Image

After that I deleted the /dev/sda1 EFI with gparted.
/dev/sda2 ext4(ubuntu) was okay and still there.
And then I unmounted /dev/sda2 ext4(ubuntu) with gparted.
After I unmounted the partitions (3 of them) collapsed into 1 filesystem. And it has become unallocated (following image).

Image

Image

sudo gdisk -l /dev/sda' Outputs:

Code: Select all

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)


testdisk log:

Code: Select all

Tue Oct 12 14:21:50 2021
Command line: TestDisk /debug

TestDisk 7.1, Data Recovery Utility, July 2019
Christophe GRENIER <grenier@cgsecurity.org>
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.
Unfortunately I don't have a back up.
With "quick search" option I was able to reach my files.
Should I take image of a disk with testdisk? or Should I copy my files to external HDD immediately?

How can I fix this problem?
I seek your help and expertise.
Thank you,

(I've also posted on https://askubuntu.com/questions/1368452 ... -is-happen)

Locked