whoops I deleted my partition
- install testdisk for your OS. In my case it is Fedora
dnf install testdisk
* in root/sudo
* the command will return
* * ```
TestDisk 7.2, Data Recovery Utility, February 2024
Christophe GRENIER <[email protected]>
https://www.cgsecurity.org
TestDisk is free data recovery software designed to help recover lost
partitions and/or make non-booting disks bootable again when these symptoms
are caused by faulty software, certain types of viruses or human error.
It can also be used to repair some filesystem errors.
Information gathered during TestDisk use can be recorded for later
review. If you choose to create the text file, testdisk.log , it
will contain TestDisk options, technical information and various
outputs; including any folder/file names TestDisk was used to find and
list onscreen.
Use arrow keys to select, then press Enter key:
>[ Create ] Create a new log file
[ Append ] Append information to log file
[ No Log ] Don't record anything
- using the arrow keys hover over the
[ Create ] Create a new log file
option and hit enter to select it
- using the arrow keys hover over the disk that you accidentally deleted the partition on and hit enter to select it
- you’ll be greeted with this menu
-
TestDisk 7.2, Data Recovery Utility, February 2024
Christophe GRENIER [email protected]
https://www.cgsecurity.org
Disk /dev/sda - 4096 GB / 3815 GiB - T-FORCE T253TY00
Please select the partition table type, press Enter when done.
[Intel ] Intel/PC partition
[EFI GPT] EFI GPT partition map (Mac i386, some x86_64…)
[Humax ] Humax partition table
[Mac ] Apple partition map (legacy)
[None ] Non partitioned media
[Sun ] Sun Solaris partition
[XBox ] XBox partition
[Return ] Return to disk selection
Hint: None partition table type has been detected.
* using the arrow keys hover over to `[Intel ] Intel/PC partition` and hit enter to select it. If you are using a different partition type, make sure to check if the other partition types are relevant
* after selecting the partition type, you’ll be prompted with this menu
* * ```
TestDisk 7.2, Data Recovery Utility, February 2024
Christophe GRENIER <[email protected]>
https://www.cgsecurity.org
Disk /dev/sda - 4096 GB / 3815 GiB - T-FORCE T253TY00
CHS 498074 255 63 - sector size=512
>[ Analyse ] Analyse current partition structure and search for lost partitions
[ Advanced ] Filesystem Utils
[ Geometry ] Change disk geometry
[ Options ] Modify options
[ MBR Code ] Write TestDisk MBR code to first sector
[ Delete ] Delete all data in the partition table
[ Quit ] Return to disk selection
Note: Correct disk geometry is required for a successful recovery. 'Analyse'
process may give some warnings if it thinks the logical geometry is mismatched.
- using the arrow keys hover over to
[ Analyse ] Analyse current partition structure and search for lost partitions
and hit enter to select it.
- after selecting the partition type, you’ll be prompted with this menu
-
TestDisk 7.2, Data Recovery Utility, February 2024
Christophe GRENIER [email protected]
https://www.cgsecurity.org
Disk /dev/sda - 4096 GB / 3815 GiB - CHS 498074 255 63
Current partition structure:
Partition Start End Size in sectors
*=Primary bootable P=Primary L=Logical E=Extended D=Deleted
[Quick Search] [ Backup ]
* using the arrow keys hover over to `[Quick Search] ` and hit enter to select it.
* let testdisk scan for the partitions
* if the data is recoverable, you’ll see this menu
1. * ```
TestDisk 7.2, Data Recovery Utility, February 2024
Christophe GRENIER <[email protected]>
https://www.cgsecurity.org
Disk /dev/sda - 4096 GB / 3815 GiB - CHS 498074 255 63
Partition Start End Size in sectors
>* Linux 0 32 33 121601 25 24 1953519616 [MassStorage]
P HPFS - NTFS 121601 25 25 124032 144 16 39061504
P HPFS - NTFS 124032 144 17 131344 239 31 117473280
* the first entry is the partition I am trying to recover, so using the arrow keys hover over to `>* Linux 0 32 33 121601 25 24 1953519616 [MassStorage]` and hit enter to select it.
context
while working on the previous to expand my drive, I wanted to remove the ntfs partition. I didn’t realize that as part of the migration, the ntfs partition wasn’t cleared from the disks, so when I tried to remove it I accidentally deleted the btrfs partition.