Quick Guide: How to Use GPT fdisk to Convert MBR to GPT

Quick Guide: How to Use GPT fdisk to Convert MBR to GPT

Converting an MBR disk to GPT with GPT fdisk (gdisk) is a common task when preparing drives for modern OS installs or UEFI boot. This guide gives a concise, safe, step-by-step procedure for Linux, macOS, and Windows (gdisk available cross-platform). Always back up important data before changing partition tables.

Before you begin

  • Backup: Copy any important files to another drive or cloud storage. Converting partition tables can risk data loss.
  • Check OS/firmware: To boot from GPT, modern systems typically need UEFI. Older BIOS-only systems may require a BIOS-boot partition for GRUB.
  • Install gdisk:
    • Linux: install via your package manager (e.g., apt install gdisk or yum install gdisk).
    • macOS: brew install gptfdisk
    • Windows: download gdisk (gdisk64.exe) from the project page and run as Administrator.

Quick checklist

  • Identify target disk (device name, e.g., /dev/sda on Linux, .\PhysicalDrive0 on Windows).
  • Note existing partitions and sizes.
  • Decide whether you need an EFI System Partition (ESP) for UEFI boot (FAT32, ~100–512 MB) or a BIOS-boot partition for legacy BIOS+GRUB (~1–2 MB–1 GB as needed).
  • Ensure you have recovery media (live USB) in case the system becomes unbootable.

Step-by-step conversion (preserve partitions where possible)

  1. Identify the disk

    • Linux: sudo lsblk -f or sudo fdisk -l
    • macOS: diskutil list
    • Windows: diskpart -> list disk (or use Disk Management)
  2. Launch gdisk on the target disk

    • Linux/macOS: sudo gdisk /dev/sdX
    • Windows: run gdisk64.exe and enter the disk number (e.g., 0) or use the device path.
  3. let gdisk read the disk

    • gdisk will detect an MBR and report the protective GPT status. It may offer to convert MBR to GPT automatically.
  4. Convert MBR to GPT

    • From gdisk main prompt:
      • If gdisk offers the automatic conversion, follow prompts.
      • Or use the recovery & transformation menu: press r then enter, then press f to “load MBR and build fresh GPT from it”. This imports existing MBR partitions into the GPT partition table.
    • Verify the partition layout with p (print table). Ensure partitions and start/end sectors match expectations.
  5. Create or set an EFI System Partition if needed

    • If you need UEFI boot and there is no FAT32 ESP:
      • Use gdisk to create a new partition in free space (n), choose the size (e.g., +512M), then set its type code to EF00 (EFI System).
      • Alternatively, convert an existing small FAT32 partition to type EF00.
    • For BIOS-only systems using GRUB on GPT, create a small BIOS boot partition type EF02 (if required by your bootloader).
  6. Write changes to disk

    • When the partition table looks correct, press w to write the new GPT to disk and exit. Confirm when prompted.
    • If you made a mistake or want to cancel, press q to quit without saving.
  7. Post-conversion tasks

    • If you created an ESP, format and mount it:
      • Linux: mkfs.vfat -F32 /dev/sdXn and mount to /boot/efi for bootloader installation.
      • Windows: Windows will recognize an ESP when installing to GPT; otherwise, use Disk Management to format.
    • Reinstall or repair the bootloader if the system doesn’t boot:
      • Linux: reinstall GRUB (in UEFI mode use grub-install –target=x8664-efi –efi-directory=/boot/efi).
      • Windows: if converting a Windows system disk, use Windows repair tools (bootable installer -> Repair -> Command Prompt -> use bcdboot or diskpart + bootrec as needed). Note: converting system disks may require additional steps; many prefer Microsoft’s MBR2GPT tool for Windows system disks.
    • Reboot and select UEFI boot if applicable.

Common pitfalls and how to avoid them

  • No backup: always back up.
  • Wrong disk chosen: double-check device names; selecting the wrong disk destroys data.
  • Missing ESP after conversion: create and format an EFI System Partition before attempting to boot in UEFI mode.
  • Windows system disk: Windows boot configuration may need repair. Microsoft provides MBR2GPT for in-place conversions of Windows system disks; consider it for Windows-only workflows.
  • Hybrid MBRs or odd partition layouts: inspect with gdisk’s p and v commands and use expert/recovery options only when you understand them.

Quick recovery tips

  • If you wrote changes and something’s wrong, boot from a live USB and use gdisk to inspect and restore backup header (recovery & transformation menu options b/c/d as appropriate).
  • If partitions are present but OS won’t boot, rebuild or reinstall the bootloader (GRUB for Linux; Windows repair for Windows).

Example gdisk session (Linux)

bash

sudo gdisk /dev/sda # at prompt: p# print partition table r # recovery & transformation menu f # load MBR and build fresh GPT from it p # verify partitions w # write changes and exit

Final notes

  • Converting non-system data disks is usually straightforward; system disks are more complex.
  • If you’re uncomfortable with partitioning tools, use graphical utilities (gparted) or OS-specific tools (Windows MBR2GPT) and keep backups.

If you want, I can produce a checklist tailored to Windows system disks or provide exact commands for reinstalling GRUB or repairing Windows boot after conversion.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *