Categories: Disks and Partitions

Linux gdisk command (partitioning disk) [Basic Guide]

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 
GPT fdisk (gdisk) version 0.8.6
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? for help): n
Partition 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): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): And
OK; writing new GUID partition table (GPT) to /dev/xvdb.
The operation has been successfully completed.

Uirá Endy Ribeiro

Uirá Endy Ribeiro is a Software Developer and Cloud Computing Architect with a 23-year career. He has master's degrees in computer science and fifteen IT certifications and is the author of 11 books recognized in the IT world market. He is also Director at Universidade Salgado de Oliveira and Director of the Linux Professional Institute - LPI Director's Board.

Uirá Endy Ribeiro

Uirá Endy Ribeiro is a Software Developer and Cloud Computing Architect with a 23-year career. He has master's degrees in computer science and fifteen IT certifications and is the author of 11 books recognized in the IT world market. He is also Director at Universidade Salgado de Oliveira and Director of the Linux Professional Institute - LPI Director's Board.

Recent Posts

Sudo command on Linux (privilege scale) [Basic Guide]

The sudo command on Linux executes a given command as if it were another user.…

2 years ago

SS command on Linux (investigate the network) [Basic Guide]

The ss command on Linux is extremely useful for investigating sockets, providing various information about…

2 years ago

Free Linux command (memory usage) [Basic Guide]

Free Linux command shows the amount of total memory in use and available, as well…

2 years ago

Linux while command (loop – while) [Basic Guide]

The shell has structures for testing conditions and executing certain program sequences several times (loop),…

2 years ago

Linux fstab file (disk mount setup) [Basic Guide]

The /etc/fstab file stores the configuration of which devices should be mounted and what is…

2 years ago

Netcat command on Linux (Swiss network knife) [Basic Guide]

The Netcat Command in Linux or nc is a utility used to do “almost anything”…

2 years ago

This website uses cookies.