gdisk
Manage GPT (GUID Partition Table) disks
TLDR
List partitions
Start the interactive partition manipulator
Open a help menu
Print the [p]artition table
Add a [n]ew partition
Select a partition to [d]elete
[w]rite table to disk and exit
[q]uit without saving changes
SYNOPSIS
gdisk [-C newalignments] [-F] [-f firstalign] ... device
PARAMETERS
-C, --set-alignment=NEWALIGN
Change default alignment boundary (sectors)
-F, --fix
Force disk scan and fix issues
-f, --first-aligned=SECTORS
Align first partition to specified sectors
-g, --mbrtogpt
Convert MBR to GPT (destructive)
-G, --randomize-guids
Randomize disk and partition GUIDs
-h, --help
Display help and exit
-i, --show-mbr
Show MBR partitioning details
-l, --list-types
List partition types and exit
-L, --label=DISK-LABEL
Set disk label
-m, --transform-mbr=MBR-TYPE
Transform MBR to specified type
-n, --new=PARTNUM[:FIRSTSECTOR[+SIZE]]
Recover GPT from backup
-o, --use-zeros
Use zeroed main header copy
-P, --attributes=ATTRS
Change partition attributes
-r, --use-raid
Set RAID metadata
-R, --recompute-chs
Recalculate CHS values
-s, --size=SIZELIMIT
Set device size limit (sectors)
-S, --sectors=NUMSECTORS
First usable LBA
-t, --typecode=TYPECODE
Set partition type
-u, --partition-guid=GUID
Set partition GUID
-U, --disk-guid=GUID
Set disk GUID
-V, --verify
Verify disk and exit
-v, --version
Show version and exit
-x, --expert
Enable expert mode
-X, --extra-args
Extra arguments for scripts
-z, --zap
Zap (clear) MBR and GPT data
-Z, --zap-all
Zap all partition table data
DESCRIPTION
gdisk is a menu-driven utility for manipulating GPT (GUID Partition Table) partition tables on disks. Part of the GPT fdisk suite, it excels with modern large disks (>2TiB), UEFI systems, and supports up to 128 primary partitions per disk, unlike legacy MBR tools like fdisk.
It offers an interactive interface for creating, deleting, resizing, moving partitions; setting types, names, GUIDs, attributes (e.g., bootable, hidden); verifying tables; converting MBR to GPT; and recovery options. gdisk detects and repairs corruption, aligns partitions optimally (usually 1MiB), and handles hybrid MBR setups.
Key advantages: non-destructive edits until write, expert mode for advanced features, scripting via sgdisk. Run as root on block devices (e.g., /dev/sda). Always back up data first, as errors can cause irrecoverable loss. Ideal for Linux, but cross-platform.
CAVEATS
Extremely dangerous: modifies disk directly, risking total data loss.
Run as root only on correct device.
Backup GPT data first with -b. Not for MBR-only disks without conversion.
UEFI requires <2.2TiB ESP partition.
INTERACTIVE MODE
Launches menu: new, delete, print, type, label, verify, write, quit. Expert mode (x) unlocks advanced ops like GUID edits.
PARTITION TYPES
Use hex codes or aliases (e.g., af00 for Linux filesystem, ef00 for EFI). List with -l or l in menu.
RECOVERY
Alternate headers for redundancy. Use r > e > recover to load backup copies.
HISTORY
Developed by Roderick W. Smith in 2009 as part of GPT fdisk suite to address MBR limitations. Supports GPT since EFI/UEFI era; actively maintained, latest versions handle modern filesystems, NVMe.


