Linux gdisk Command

GPT Disk Partitioning Tool

Overview

The gdisk command is an interactive GUID Partition Table (GPT) manipulator. It's designed for working with GPT partition tables, which are the modern replacement for the older MBR (Master Boot Record) partition scheme. GPT supports larger disks, more partitions, and provides better data integrity.

Key Features:
  • Interactive GPT partition management
  • Support for disks larger than 2TB
  • Up to 128 partitions by default
  • Built-in data integrity checks
  • Conversion between MBR and GPT
Warning: Partitioning operations can destroy data. Always backup important data before using gdisk and test operations carefully.

Syntax

gdisk [OPTIONS] device

Command Line Options

Option Description
-l List partition tables and exit
-i Show detailed partition information
-o Clear out all partition data
-g Convert MBR to GPT and exit
-m Convert GPT to MBR and exit
-A Show attributes for all partitions

Interactive Commands

Once inside gdisk, you can use these single-letter commands:

Command Description
p Print partition table
n Create new partition
d Delete partition
t Change partition type
i Show detailed partition information
w Write changes and exit
q Quit without saving changes
? Show help menu

Basic Examples

View Partition Table

# List partitions without entering interactive mode
sudo gdisk -l /dev/sda
GPT fdisk (gdisk) version 1.0.8

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

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 1953525168 sectors, 931.5 GiB

Start Interactive Mode

sudo gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.8

Command (? for help):

Related Commands

Partitioning Tools:
  • fdisk - MBR partition editor
  • parted - Universal partition editor
  • sgdisk - Script-friendly GPT editor
Filesystem Tools:
  • mkfs - Create filesystems
  • lsblk - List block devices
  • blkid - Locate/print block device attributes

Frequently Asked Questions

gdisk is a command-line tool for managing GPT (GUID Partition Table) disk partitions. It's the GPT equivalent of fdisk for MBR partitions, designed for modern systems that use UEFI firmware and support larger disks.

gdisk is safe when used carefully. Always backup important data before partitioning, and use the 'p' command to preview changes before writing with 'w'. The tool doesn't write changes until you explicitly use the 'w' command.

gdisk works with GPT partition tables while fdisk traditionally works with MBR partition tables. GPT supports larger disks (>2TB), more partitions (128 vs 4 primary), and provides better data integrity with backup partition tables.

gdisk can convert MBR to GPT non-destructively in many cases, but you should always backup your data first. The conversion preserves existing partitions but may require adjustments for UEFI booting.

If you haven't written changes yet, use 'q' to quit without saving. For written changes, you can use backup partition tables or tools like TestDisk. Always backup partition tables before making changes with sgdisk --backup.