gdisk Command in Linux: Create and Manage GPT Partitions in Terminal
The gdisk command in Linux is similar to fdisk and allows you to manipulate and create partitions. It was especially created to work with 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, 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 fitting the boot manager in the first 1024 cylinders.
The gdisk menus, although with more options, are very similar to fdisk's. The gdisk options are:
- b Save GPT backup to a file
- c Change partition name
- d Delete a partition
- i Show detailed information about a partition
- l List partition types
- n Create a new partition
- o Create empty GUID partition table (GPT)
- p Show partition data
- q Quit without saving
- r Recovery and transformation (for experts)
- s Sort linux partitions
- t Change partition type
- v Verify disk
- w Write partition table
- x Extra functionality (for experts)
- ? Print this menu
In this example, a GPT-type partition was created on the /dev/xvdb disk. If nothing is typed at the interactive prompt, it will assume the default options:
# gdisk /dev/xvdbGPT fdisk (gdisk) version 0.8.6Partition table scan: MBR: protective BSD: not present APM: not present GPT: presentFound valid GPT with protective MBR; using GPT.Command (? for help): nPartition number (1-128, default 1): First sector (34-16777182, default = 2048) or {+-}size{KMGTP}: Last sector (2048-16777182, default = 16777182) or {+-}size{KMGTP}: Current type is 'Linux filesystem'Hex code or GUID (L to show codes, Enter = 8300): Changed type of partition to 'Linux filesystem'Command (? for help): wFinal checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTINGPARTITIONS!!Do you want to proceed? (Y/N): YOK; writing new GUID partition table (GPT) to /dev/xvdb.The operation has completed successfully.
Learn much more about Linux in our online course. You can enroll here. If you already have an account, or want to create one, just log in or create your user here.
Like it? Share
That was just one piece. The course teaches the whole path — from your first command to exam day.