2

So, today I have managed to accidentally overwrite my GPT. None of my files were touched, but the partitions don't exist anymore.

I booted a USB to do an update, but as it turns out, the USB was meant to reinstall the system and created a new GPT in the process. Cos, why not?

Anyway, as soon as diskpart said that it had created a new GPT I stopped the script.

The disk in question fairly small and had a very simple partition table, with just an EFI partition, a windows partition and an OEM recovery partition (which I obviously don't have a copy of. I mean, who on earth makes backups?).

So, is there any bootable software that can restore my GPT somehow?

6
  • See this page....easeus.com/resource/drive/gpt-disk.htm
    – Moab
    Commented Jul 4, 2018 at 14:23
  • 2
    "who on earth makes backups" anyone who cares about their data.....
    – Moab
    Commented Jul 4, 2018 at 14:26
  • @Moab Yep, that's the joke. The link looks rather promising, would you like to post it as an answer? Commented Jul 4, 2018 at 14:28
  • Its is frowned upon at SU to use software links (recommendations) as answers. This is why they have the comments section. I'm sure there is a command line solution but that is way beyond my skill level, that's why they make software for this.
    – Moab
    Commented Jul 4, 2018 at 14:39
  • @DividedByZero - There are already existing questions which recommend that particular software package. The company has a history of advertising their products here. Given their history an answer would unlikely be well received. Despite having used their software in the past I don't typically find any answer which recommends their software to be helpful.
    – Ramhound
    Commented Jul 4, 2018 at 14:40

3 Answers 3

3

Here's what I did, step by step:

  1. Create a GParted Live USB
  2. Boot the USB and run testdisk in a terminal
    i. You will be asked about a log file, select [ Create ]

    ii. Select the drive you want to recover. The Live USB will also be in this list.

    iii. You will be asked to select the partition table type that was used for your disk. The default option is what TestDisk thinks it is, and in my case was right too, but it may be wrong so be careful

    iv. Select [ Analyse ], then [ Quick Search ].

    v. Now at this point you should be shown a list of partitions that TestDisk found.
    Something like this: enter image description here Screenshot stolen from this question
    Now, if you're lucky, all of your partitions will be found and highlighted green. In my case they were all found, but there were more partitions listed than I had, so only the one that didn't conflict with the others was green.
    You can go through the files in each partition to verify they are the correct ones, and then press the left arrow button to highlight them. Green partitions will be restored, grey ones deleted.
    If TestDisk couldn't find all of your partitions, continue to the next step anyway.

    vi. If all of your partitions were found and you have marked the ones you want to keep, select [ write ] to write the changes to disk. If partitions were missing, select [ Deeper Search ] then select partitions as above and [ write ] them to disk.

  3. Now that our disk has a GPT again, we can read it, but it still won't boot. Open GParted and right click on the ~100MB Fat32 partition (which should also be the first partition). Click on 'Manage Flags' and check the box next to 'boot'. ESP will automatically be selected too.

  4. Try booting. At this point your disk has a GPT and a bootable EFI partition, so if no files were lost everything should be working now. If not, keep reading.

  5. So something important is missing from your EFI or Windows partition. Get a hold of another PC running the same edition of windows as you, type 'Recovery Drive' into the start menu search bar and click on 'Recovery Drive'.

  6. Create a recovery drive without the system files (if that's an option - if not don't worry) and boot your PC from the recovery drive.

  7. Once your computer has booted, click on 'Troubleshoot', 'Advanced Options' and then either 'Startup Repair' or 'Automatic Repair', whichever is available. If this works, everything should return to normal. If you are told 'Automatic/Startup repair couldn't repair your PC', then click on 'Advanced Options' again and continue to the next step.

  8. Open a command prompt and type in diskpart, then list disk.

  9. Look for your disk, and note the number next to it. Type in sel disk <number> where <number> is the number you just noted down.
  10. Type list vol, identify the partition you just marked as the boot partition and it's number, and then type sel vol <number>
  11. Finally, type in assign letter=w: and then exit.
  12. Type in the following commands in order:
    • cd /d w:\EFI\Microsoft\Boot\
    • bootrec /fixboot
    • ren BCD BCD.backup
    • bcdboot c:\Windows /s w: /f ALL
  13. Try to boot.

If after all of these steps you are still unable to boot, it is very likely that you will have to reinstall Windows. But since you've recovered your personal files, hopefully that shouldn't be too much of an issue

2
  • "If after all of these steps you are still unable to boot..." -- For the record: were you able to boot? Commented Jul 5, 2018 at 7:31
  • @KamilMaciorowski Yes, but only after the twelfth step Commented Jul 5, 2018 at 13:05
1

For GPT disks, there is a backup GPT at the end of the disk. You can copy the backup GPT to replace the primary GPT using WinHex. However, this method is complicated. So, you'd better do partition recovery or data recovery.

1
  • Unfortunately, because the script used diskpart to create a new GPT, the backup was also overwritten, so this wasn't an option. But I am sure this would be helpful to anyone that damaged their GPT some other way. Commented Jul 6, 2018 at 14:01
0

Have you tried the Bootable Minitool Partition Tool. It says that it can rebuild MBR. The pro version can also convert GPT to MBR (Not sure about the free one).

So maybe you can convert your damaged GPT to MBR and then rebuild it. Or maybe it has an option to rebuild GPT right away.

1
  • Converting to MBR (more accurately "dos") partition tables would leave the system unbootable and possibly damage the files on the filesystems within the partitions (depending on how close the gpt partitions are to meeting the requirements of the dos partition scheme. These are not insurmountable problems... but will require additional research on the asker's part to fully solve the problem. Commented Jul 4, 2018 at 16:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .