How to Convert MBR to GPT During Windows Installation Without Wiping Disk

gdiskgptmbrpartitioningwindows-pe

I get an old laptop with Windows 7 installed. Wishing to just clean install Windows 10 while keeping the data on non-system partition, I made a mistake by booting from Windows 10 installer USB drive, removing the system partition right before trying to start the installation. The installer complaint about booting from UEFI and can't install on non-GPT disk. If I haven't remove the system partition, I can easily boot to Windows 7 and use third party tools to convert from there. Since I don't have a working OS right now, Windows PE is my only hope. FDISK can easily convert MBR disk to GPT, but only if the disk is empty, while I need to keep the data on other partition, and don't have enough time nor space to back them up first.

I can download small files from my phone and copy them to the USB drive, but the connection isn't stable enough for downloading a Linux Live USB or paid bootable partition manager. How do I convert the disk losslessly to GPT without downloading large files, and preferably right from Windows PE?

Best Answer

GPT fdisk can convert GPT disk to MBR without data loss, by utilizing the inefficiencies in MBR partition scheme. The Windows binary (less than 1 MB download) can also run on Windows PE, so there's no need to get a live CD or custom bootable drive. To use gdisk on Windows PE :

  • Copy gdisk64.exe or gdisk32.exe to the root of the USB drive containing Windows installer
  • Boot from the USB drive, press Shift-F10 on the Language selection screen to launch the command prompt
  • Change the drive to C: (could be different letter) where the gdisk is located.
  • Run gdisk to start the interactive prompt
  • Type \\.\physicaldrive# on the prompt, replace # with number, usually 0 for a system with single drive.
  • There should be a message about valid MBR and invalid GPT. Confirm that the selected drive is indeed the drive where Windows is going to be installed instead of the removable drive or different internal drive.
  • Type t to start the code change menu.
  • Normally "1" will be selected as the system partition. If this partition isn't a FAT32, Windows installer will complaint, but this can be fixed later.
  • Type EF00 to change to EFI
  • Type w to write the change
  • Type q to exit gdisk.

Exit the command prompt and reboot the PC (or maybe just go back to X:\Sources and run setup). Windows installer will now recognize the disk as GPT disk and allow installation.