sgdisk
Scriptable GPT partition table manager
TLDR
Show partition table
SYNOPSIS
sgdisk [-n part:start:end] [-t part:type] [options] device
DESCRIPTION
sgdisk is the command-line, scriptable counterpart to the interactive gdisk partitioning tool, designed for manipulating GUID Partition Table (GPT) disk layouts. It performs all operations through flags and arguments rather than an interactive menu, making it ideal for use in scripts, automated provisioning, and disk imaging workflows.
Partition creation uses flexible notation where sizes can be specified with + prefixes for relative sizing and 0 to fill remaining space. Type codes such as 8300 (Linux filesystem), EF00 (EFI System Partition), and 8200 (Linux swap) identify the purpose of each partition. Multiple operations can be chained in a single command to build complete partition layouts atomically.
The tool also supports backing up and restoring entire partition tables, converting MBR disks to GPT, and verifying table integrity. All changes are written in a single operation when the command completes successfully.
PARAMETERS
-p, --print
Print partition table.-o, --clear
Create new GPT.-n, --new PART:START:END
Create partition.-d, --delete PART
Delete partition.-t, --typecode PART:TYPE
Set type code.-c, --change-name PART:NAME
Set name.-b, --backup FILE
Backup table.-l, --load-backup FILE
Restore table.-L, --list-types
List type codes.
CAVEATS
Destructive operations are immediate. Wrong device destroys data. No MBR support.
HISTORY
sgdisk is part of GPT fdisk by Rod Smith. It provides scriptable GPT partition management.
