How can I detect whether my disk is using GPT or MBR from a terminal?

To find whether your disk is GPT or MBR in ubuntu,you have to install gdisk utility.

sudo apt-get install gdisk

Then run the below command,

sudo gdisk -l /dev/sda
  • If the output of the above command shows like this,then you have MBR disk,

    Partition table scan:
    MBR: MBR only
    BSD: not present
    APM: not present
    GPT: not present
    
  • If the output shows like this then you have GPT disk,

    Partition table scan:
    MBR: protective
    BSD: not present
    APM: not present
    GPT: present
    

Using parted

You can use this command, replace /dev/sda with your device:

parted /dev/sda print | grep -i '^Partition Table'

You may need to install it first:

sudo apt-get install parted

Example output for an MBR disk:

Partition Table: msdos

Using gdisk

Install it first:

sudo apt-get install gdisk

Then, you can use this command, replace /dev/sda with your device:

gdisk -l /dev/sda | grep -A4 '^Partition table scan:'

Example output for an Mbr disk:

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: not present

Using fdisk

Run this command, replacing /dev/sda with your device:

fdisk -l /dev/sda

It will show a warning if the device uses GPT:

WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.

No need to install anything:

sudo ls                              # Prevent hang
sudo fdisk -l | grep -B 5 Disklabel  # Focus

Tags:

Partitioning