Deleting accidental GPT partition and writing restored Intel partition table

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
Post Reply
Message
Author
kmlmkm
Posts: 2
Joined: 25 Sep 2019, 11:44

Deleting accidental GPT partition and writing restored Intel partition table

#1 Post by kmlmkm » 25 Sep 2019, 13:19

I'm using Debian Stable.

I was using the root account to wipe some drives and was using sgdisk to copy over the GPT partition table from

Code: Select all

/dev/sdc 
to

Code: Select all

/dev/sdd
.

The command was

Code: Select all

sgdisk -R /dev/sdd /dev/sdc
and then

Code: Select all

sgdisk -G /dev/sdd
. My primary hard disk is sda and I have another hard disk, sdb. sgdisk told me that I should probably do something something because kernel something and then that i should look into partprobe and kpartx. So I in my blind stupor just entered partprobe and pressed enter and it showed that I had something like 9xxxxxxxx ish space and that it should be done something to and then I just C-c'ed it because I was spooked. And then the entire system just exited X and threw me back on the tty and then I turned it off from the UPS and then turned it on again, and there's nothing there, just an oversized underline cursor on the left of my screen.

It turns out that the partition that was to be written to /dev/sdd is now written on /dev/sda.

I found my old partition (Intel-type) through testdisk and wrote it to the disk and after a reboot, testdisk still identifies it as gpt, and not intel. I tried writing it again, and it gave me the same result.

gpt table, still on the disk:

Code: Select all

https://i.imgur.com/cw8DZn3.jpg
the required table, from the Intel submenu:

Code: Select all

https://i.imgur.com/6ZajNbG.jpg
Any ideas? There's no delete option on the gpt submenu, but there is one on the intel submenu. I would like to make my disk bootable again. A cursory inspection shows that no data is lost.

I also tried flashing the testdisk MBR, but no dice, it gave me no result on any of the four numbers.

Sponsored links

User avatar
cgrenier
Site Admin
Posts: 4972
Joined: 18 Feb 2012, 15:08
Location: Le Perreux Sur Marne, France
Contact:

Re: Deleting accidental GPT partition and writing restored Intel partition table

#2 Post by cgrenier » 26 Sep 2019, 05:53

Run TestDisk, select /dev/sdc, PC Intel or EFI GPT, select the partition table type you want,
Analyze, Quick Search.
If all your partitions are listed, choose Write, confirm, Quit, restart your computer.
If you have problems, please copy and paste the testdisk.log file content.

kmlmkm
Posts: 2
Joined: 25 Sep 2019, 11:44

Re: Deleting accidental GPT partition and writing restored Intel partition table

#3 Post by kmlmkm » 26 Sep 2019, 12:42

Thanks for the reply!

I'm using an external bootable flash drive with Arch Linux at the moment. It is /dev/sdc. /dev/sdb is a secondary, storage drive and /dev/sda is the drive which needs to be fixed.

Code: Select all

~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 931.5G  0 disk 
├─sda1   8:1    0 915.8G  0 part 
└─sda2   8:2    0  15.8G  0 part 
sdb      8:16   0   1.8T  0 disk 
└─sdb1   8:17   0   1.8T  0 part 
sdc      8:32   1   7.5G  0 disk 
├─sdc1   8:33   1    10M  0 part 
├─sdc2   8:34   1   500M  0 part /boot
└─sdc3   8:35   1   6.9G  0 part /
testdisk.log:

Code: Select all

~$ cat testdisk.log 
/dev/sda: LBA, HPA, LBA48, DCO support
/dev/sda: size       1953525168 sectors
/dev/sda: user_max   1953525168 sectors
/dev/sda: native_max 1953525168 sectors
Using locale 'en_US.UTF-8'.


Thu Sep 26 16:54:11 2019
Command line: TestDisk /log /dev/sda

TestDisk 7.0, Data Recovery Utility, April 2015
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
OS: Linux, kernel 5.2.5-arch1-1-ARCH (#1 SMP PREEMPT Wed Jul 31 08:30:34 UTC 2019) x86_64
Compiler: GCC 8.2
Compilation date: 2018-10-03T23:07:17
ext2fs lib: 1.45.3, ntfs lib: libntfs-3g, reiserfs lib: 0.3.0.5, ewf lib: none, curses lib: ncurses 6.1
Hard disk list
Disk /dev/sda - 1000 GB / 931 GiB - CHS 121601 255 63, sector size=512 - WDC WD10EZEX-00WN4A0, S/N:WD-WMC6Y0J29XFR, FW:01.01A01

Partition table type (auto): EFI GPT
Disk /dev/sda - 1000 GB / 931 GiB - WDC WD10EZEX-00WN4A0
Partition table type: Intel

Analyse Disk /dev/sda - 1000 GB / 931 GiB - CHS 121601 255 63
Geometry from i386 MBR: head=255 sector=63
Current partition structure:
 1 * Linux                    0  32 33 119544 174 54 1920483328
 2 P Linux Swap           119544 207 24 121601  57 56   33036288

search_part()
Disk /dev/sda - 1000 GB / 931 GiB - CHS 121601 255 63
     Linux                    0  32 33 119544 174 54 1920483328
     ext4 blocksize=4096 Large_file Sparse_SB Recover, 983 GB / 915 GiB
     Linux Swap           119544 207 24 121601  57 40   33036272
     SWAP2 version 1, pagesize=4096, 16 GB / 15 GiB

interface_write()
 1 * Linux                    0  32 33 119544 174 54 1920483328
 2 P Linux Swap           119544 207 24 121601  57 56   33036288
write!
No extended partition
You will have to reboot for the change to take effect.

TestDisk exited normally.
I followed your steps and I only saw the testdisk MBR (1234F:), which I wrote earlier. Pressing any of the four numbers had no effect. No boot.

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests