How to format a disk from MBR to GPT.

Here’s how to do it with fdisk:

  1. Install Required Tools: If you don’t have gdisk, you can use fdisk instead. It should be already installed on most Arch Linux systems. If you prefer a more user-friendly interface, you can also use cfdisk.

  2. Identify the Disk: Use the lsblk command to identify the disk you want to convert. Make sure you note down the device name (e.g., /dev/sda) of the disk you want to convert.

  3. Unmount Partitions: If any partitions on the disk are mounted, unmount them using the umount command.

  4. Run fdisk: Launch fdisk with the device name of the disk you want to convert:

sudo fdisk /dev/sdX

Replace /dev/sdX with the device name of your disk.

  1. Convert to GPT: Once in fdisk, type g to create a new empty GPT partition table.

  2. Write Changes: After creating the GPT partition table, type w to write the changes to the disk.

  3. Confirm: Confirm the action when prompted.

  4. Recreate Partitions (if necessary): You may need to recreate partitions on the disk using fdisk, cfdisk, or any other partitioning tool you prefer.

Remember, converting the disk from MBR to GPT will erase all data on it, so make sure to back up any important data before proceeding. Also, be very careful when selecting the correct disk to avoid accidentally overwriting data on the wrong disk.


Reformatting a disk from MBR (Master Boot Record) to GPT (GUID Partition Table) involves several steps, and it will erase all data on the disk. Be sure to back up any important data before proceeding.

Steps to Reformat a Disk from MBR to GPT

  1. Identify the Disk Use lsblk or fdisk -l to identify the disk you want to convert. Let’s assume the disk is /dev/sdx.

    lsblk
    
  2. Backup Important Data Ensure that any important data on the disk is backed up, as the conversion process will erase all data on the disk.

  3. Delete Existing Partitions Use fdisk to delete all existing partitions on the disk.

    fdisk /dev/sdx
    

    Inside fdisk, use the following commands:

    • p to print the current partition table.
    • d to delete a partition (repeat this for each partition).
    • w to write the changes and exit.
  4. Convert the Disk to GPT Using gdisk Use gdisk to convert the disk to GPT. gdisk is a GPT-aware partitioning tool.

    gdisk /dev/sdx
    

    Inside gdisk, use the following commands:

    • o to create a new empty GUID partition table (GPT).
    • w to write the new GPT partition table to the disk and exit.

    Example:

    Command (? for help): o
    This option deletes all partitions and creates a new protective MBR.
    Proceed? (Y/N): y
    Command (? for help): w
    Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!!
    Do you want to proceed? (Y/N): y
    
  5. Create New Partitions Using gdisk You can now create new partitions on the GPT disk using gdisk.

    gdisk /dev/sdx
    

    Inside gdisk, use the following commands to create partitions:

    • n to create a new partition.
    • Specify the partition number, start sector, and size.
    • Set the partition type (e.g., 8300 for Linux filesystem).

    Example:

    Command (? for help): n
    Partition number (1-128, default 1): 1
    First sector (34-234441614, default = 2048) or {+-}size{KMGTP}: <press Enter for default>
    Last sector (2048-234441614, default = 234441614) or {+-}size{KMGTP}: +512M
    Current type is 'Linux filesystem'
    Hex code or GUID (L to show codes, Enter = 8300): ef00
    Changed type of partition to 'EFI System'
    
    Command (? for help): n
    Partition number (1-128, default 2): 2
    First sector (34-234441614, default = 1050624) or {+-}size{KMGTP}: <press Enter for default>
    Last sector (1050624-234441614, default = 234441614) or {+-}size{KMGTP}: +16G
    Current type is 'Linux filesystem'
    Hex code or GUID (L to show codes, Enter = 8300): 8200
    Changed type of partition to 'Linux swap'
    
    Command (? for help): n
    Partition number (1-128, default 3): 3
    First sector (34-234441614, default = 34603008) or {+-}size{KMGTP}: <press Enter for default>
    Last sector (34603008-234441614, default = 234441614) or {+-}size{KMGTP}: <press Enter for default>
    Current type is 'Linux filesystem'
    Hex code or GUID (L to show codes, Enter = 8300): 8300
    
    • w to write the new partition table to the disk and exit.
    Command (? for help): w
    
  6. Format the New Partitions Format the new partitions with the desired filesystem. For example, to format the EFI System Partition (ESP) as FAT32 and the Linux filesystem partition as ext4:

    mkfs.fat -F32 /dev/sdx1
    mkfs.ext4 /dev/sdx3
    mkswap /dev/sdx2
    

Summary of Commands

  • Identify the disk: lsblk or fdisk -l
  • Delete existing partitions: fdisk /dev/sdx
  • Convert to GPT: gdisk /dev/sdx
  • Create new partitions: gdisk /dev/sdx
  • Format the new partitions: mkfs.fat -F32 /dev/sdx1, mkfs.ext4 /dev/sdx3, mkswap /dev/sdx2

By following these steps, you will have successfully converted your disk from MBR to GPT and created new partitions on the GPT disk.