Modern Linux installations and UEFI-based systems heavily rely on the GUID Partition Table (GPT) format rather than legacy Master Boot Record (MBR) partitioning. GPT overcomes the strict limitations of MBR, such as the 2TB physical drive capacity ceiling and the restriction of four primary partitions. Using the gdisk (GPT fdisk) utility, you can convert an existing MBR partition scheme to GPT in place without formatting or destroying your underlying data.
Understanding the Conversion Process and Precautions
While gdisk is engineered to convert partition structures non-destructively, modifying low-level disk headers always carries inherent risks. Take note of the following pre-requisites before proceeding:
- Back Up Critical Data: Always create a complete external backup of your files before executing partitioning commands.
- Ensure Free Space at Drive Ends: GPT requires 34 sectors at the beginning of the drive for the primary partition table and 33 sectors at the very end of the drive for the backup header. If an existing MBR partition stretches to the absolute final sector,
gdiskmay require adjusting boundaries. - UEFI vs BIOS Booting: If converting a bootable OS drive, you must ensure your system motherboard supports UEFI mode and that you install a UEFI-compatible bootloader (such as GRUB-EFI) and configure an EFI System Partition (ESP) post-conversion.
Installing gdisk on Your Linux Distribution
On most modern distributions, gdisk is packaged within the gdisk or gptfdisk suite. Install it using your distribution package manager:
For Ubuntu and Debian-based systems:
sudo apt update && sudo apt install -y gdisk
For Fedora, RHEL, or AlmaLinux:
sudo dnf install -y gdisk
For Arch Linux:
sudo pacman -S gptfdisk
Identifying the Target Drive
Before initiating the conversion, identify the exact device node corresponding to your disk using lsblk or fdisk -l:
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT
For this demonstration, assume the drive is identified as /dev/sdb. Never run partition conversion tools on active, mounted root filesystems without booting into a live rescue environment.
Converting MBR to GPT Non-Destructively with gdisk
The gdisk tool automatically detects legacy MBR partition tables and holds an in-memory draft of the GPT translation. Changes are only written to the disk when you explicitly command the tool to write.
- Launch
gdisktargeting your specific storage device:sudo gdisk /dev/sdb - When opened,
gdiskwill output a partition table scan indicating:Partition table scan: MBR: MBR only BSD: not present APM: not present GPT: not present Found valid MBR; converting to GPT in memory. All logical partitions will become primary partitions. - Type
pand press Enter to preview the in-memory converted partition table. Verify that all existing partitions, start sectors, end sectors, and sizes match your expected layout. - If you need to verify the structural integrity of the generated GPT table, press
v. The tool will check for overlapping sectors or alignment problems. - Once satisfied that all partition entries are intact, write the new GUID Partition Table to disk by pressing
w. - Confirm the prompt by typing
Yand pressing Enter:Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): Y OK; writing new GUID partition table (GPT) to /dev/sdb. The operation has completed successfully.
Verifying the New GPT Structure
After gdisk writes the changes and forces the kernel to reload the partition table, verify that the storage device is now officially recognised as GPT:
sudo parted /dev/sdb print
Inspect the Partition Table field in the output. It should now display gpt instead of msdos, confirming that the conversion completed successfully while preserving all existing files and filesystem hierarchies.