Skip to content

Linux gdisk command (partitioning disk)

The gdisk command in Linux is similar to fdisk and allows you to manipulate and create partitions. It was specially created to handle GPT partitions.

It automatically converts the Master Boot Record (MBR) to the new format called Globally Unique Identifier Partition Table (GPT).

This new partition allocation table scheme was created to work with the new EFI and UEFI motherboard firmwares. Windows XP 32-bit and earlier versions of Windows cannot normally read or write to drives formatted with a GUID partition table, however, Windows Vista and Windows 7 and Windows 8 have this capability.

This new standard uses logical block addressing (LBA) instead of the old cylinder-head-sector addressing. This addressing system does not have the limitation of placing the boot loader within the first 1024 cylinders.

The gdisk menus, although with more options, are very similar to that of fdisk. The gdisk options are:

  • b Backs up the GPT to a file

  • c Change the partition name

  • d Delete a partition

  • i Show detailed information for a partition

  • l List partition types

  • n Create a new partition

  • o Create an empty GUID partition table (GPT)

  • p Show data from partition that

  • q leaves without saving

  • r Recovery and transformation (for experts)

  • s Sort the Linux partitions

  • t Change the partition type

  • v Check the disk

  • w Save the partition table

  • x Extra features (for experts)

  • ? Print this menu

In this example, a GPT-type partition was created on the /dev/xvdb disk. If nothing is entered at the interactive prompt, it will assume the default options:

# gdisk /dev/xvdb <br></br>GPT fdisk (gdisk) version 0.8.6 <br></br>Partition table scan: <br></br>MBR: protective <br></br>BSD: not present <br></br>APM: not present <br></br>GPT: present <br></br>Found valid GPT with protective MBR; using GPT. <br></br>Command (? for help): n <br></br>Partition number (1-128, default 1): <br></br>First sector (34-16777182, default = 2048) or {+-} size {KMGTP}: <br></br>Last sector (2048-16777182, default = 16777182) or {+-} size {KMGTP}: <br></br>Current type is 'Linux filesystem' <br></br>Hex code or GUID (L to show codes, Enter = 8300): <br></br>Changed type of partition to 'Linux filesystem' <br></br>Command (? for help): w <br></br>Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING <br></br>PARTITIONS!! <br></br>Do you want to proceed? (Y/N): And <br></br>OK; writing new GUID partition table (GPT) to /dev/xvdb. <br></br>The operation has been successfully completed.