A curses menu for editing a GPT table beats gdisk's bare prompts, and cgdisk is exactly that. This guide inspects a disk, saves its current partition table, plans a small change, and writes it only after checking the result.
The examples are for cgdisk 1.0.10 from the Debian package gdisk 1.0.10-1build1. Allow about 20 minutes for an inspection and longer for any real change. You need a terminal, the gdisk package, a disk or raw disk image, and a verified backup of important data. Reading is normally unprivileged, but opening a block device and writing a partition table usually needs root. Never practise the write step on a disk holding data you cannot restore.
Warning: partition-table changes can make filesystems or an operating system inaccessible. A backup made by cgdisk protects partition metadata, not the files inside the partitions. Do not use these examples while partitions are mounted or the disk is in active use, unless you have confirmed your operating system and workload actually support it.
Check the package and binary before opening a device. These are ordinary, read-only commands:
$ dpkg-query -W -f='${Package} ${Version}\n' gdisk
gdisk 1.0.10-1build1
$ command -v cgdisk
/usr/sbin/cgdisk
cgdisk has no conventional --version option: the program shows its version inside the curses interface, so the package query is the reliable version check on this machine. The only documented command-line option is -a, followed by one device or raw disk image.
Checkpoint: confirm the device path twice. Substitute a real path for /dev/EXAMPLE_DISK; never paste that placeholder into a write command.
Identify the device with a separate inventory command first. This does not change partition data:
$ lsblk -o NAME,PATH,SIZE,TYPE,FSTYPE,MOUNTPOINTS
$ findmnt -rn -S /dev/EXAMPLE_DISK*
Check the output and make sure you have picked the whole disk, not a partition such as /dev/sda2. Stop if a partition is mounted and you are considering a change: unmounting a live filesystem can interrupt services and needs planning of its own. Open the whole disk with elevated privileges:
$ sudo cgdisk /dev/EXAMPLE_DISK
The top of the screen shows the device, size and detected partition-table type. The partition display lists partitions and free gaps, and the option area offers commands such as Backup, Info, Verify, Quit and Write.
For a screen reader or a limited terminal, use the documented accessibility mode:
$ sudo cgdisk -a /dev/EXAMPLE_DISK
With -a, the selected row is marked with a > instead of ncurses highlighting. Arrow keys move through partitions and options, and Enter activates the selected item. The capital letter shown in an option name also activates it, and here is the trap: the name option is displayed as naMe, so its shortcut is capital M, not N.
Select Verify before editing. It checks for problems including incorrect CRCs and disagreements between the primary and backup GPT data, but it does not automatically repair most problems it finds.
A healthy result reports that no problems were found, plus a summary of unallocated space; the exact wording depends on the terminal and build. If Verify reports an error, stop and investigate with gdisk documentation or a tested recovery plan. A successful partition edit afterwards is not the same thing as a repair.
Select a partition and use Info when you need exact start and end sectors or GUIDs: the main list is only a summary and can leave those out. Record the current layout before changing anything:
partition start sector end sector size type name
1 ... ... ... ... ...
The numbers above are a note-taking shape, not expected output. Copy the actual values from Info or a separate inventory tool, and check that the free space you intend to use is genuinely unallocated and does not overlap a partition.
Select Backup and give it a file on a different, reliable filesystem. This saves the protective MBR, both GPT headers and one partition-table copy into a binary file:
/safe/location/EXAMPLE_DISK-before-cgdisk.bin
cgdisk backs up whatever is currently in memory. If you have already made edits this session, the backup captures those edits, not the original on-disk state. For the cleanest recovery point, launch cgdisk, verify the disk, make the backup before editing anything, and keep the file somewhere that will survive a disk mistake:
$ ls -lh /safe/location/EXAMPLE_DISK-before-cgdisk.bin
$ file /safe/location/EXAMPLE_DISK-before-cgdisk.bin
Check that the backup exists and is not empty, in another terminal. This is metadata recovery, not a filesystem backup, so keep your ordinary file backup as well.
Choose New only once you have confirmed the free range and intended type. cgdisk asks for a starting sector, a size, a type code and a name; pressing Enter accepts the displayed default, which is the largest available block's start and its full available size.
Enter positions and sizes in sectors, or with K, M, G, T or P suffixes: for example, +2G is relative to the default starting range. Check every default before accepting it. A type code is not a filesystem format, and a GPT partition name is not a filesystem label.
linux rather than guessing.Destructive boundary: Delete removes the partition-table entry but does not erase the sectors it previously covered. That does not make the data safe. Do not create a new partition over those sectors unless you have a tested recovery reason and a separate backup.
If anything looks wrong, select Quit. It exits without saving your in-memory changes, and this is the undo path before writing:
Quit
changes discarded; on-disk partition table unchanged
That wording is a summary of the documented behaviour, not a promise of a fixed screen message. Reopen the device and run Verify again if you need to confirm you really abandoned the plan.
When the layout, start and end sectors, type and name are all correct, select Write. cgdisk asks you to confirm; read the warning and answer only when you intend to replace the on-disk table.
Destructive action: writing is the point of no return for the old table, and converting an MBR or BSD disklabel to GPT can make a system unbootable, especially with older GPT-unaware operating systems or unrecognised type codes.
After a successful write, leave cgdisk and ask the kernel and your inventory tools what they now see:
$ sudo partprobe /dev/EXAMPLE_DISK
$ lsblk -o NAME,PATH,SIZE,TYPE,FSTYPE,MOUNTPOINTS
$ sudo cgdisk /dev/EXAMPLE_DISK
partprobe is a separate Linux utility, not part of cgdisk's documented interface. If the kernel keeps an old partition view, a reboot may be needed before you can use the changed layout. Do not format or mount a newly changed partition until its boundaries and type have been checked again.
When cgdisk finds an MBR or BSD disklabel without valid GPT data, it tries to present it as GPT. Selecting Write then replaces the old table. Conversion can fail because there is not enough space at the start or end, and BSD conversions in particular can produce overlaps or incorrect values. Treat a conversion as a migration with a recovery plan, not a harmless display mode.
For new disks, GPT fdisk normally aims for 1 MiB alignment, which is 2048 sectors on a 512-byte-sector disk. On a pre-partitioned disk it tries to detect existing alignment, with documented behaviour that can fall back to 8-sector alignment on disks larger than 300 GB even when a smaller value is detected. The Align option changes this value and affects default end sectors, so check the actual sector size and workload before overriding it.
The EFI System Partition is GPT fdisk type 0xEF00, normally FAT32, with a documented recommended size of 100 to 300 MiB. A BIOS Boot Partition for GRUB is 0xEF02 and has no filesystem at all. Those are boot-loader requirements, not universal instructions to add partitions to an existing disk.