Forensicsgptpartitioningdiskmbrfdiskrepair

gdisk

GPT fdisk (gdisk) is a text-mode partitioning tool for manipulating GUID Partition Table (GPT) disks. It supports editing partition tables, conversions between MBR/GPT/BSD formats, and repairing damaged structures.

Description

gdisk provides utilities for managing GPT disks, including editing partition table definitions, converting BSD disklabels or MBR to GPT in place, creating hybrid MBR/GPT layouts, and repairing damaged GPT or MBR data structures. It also allows backing up GPT data to files for restoration. The package includes related tools like cgdisk (curses-based GPT manipulator) and fixparts (MBR repair utility).

Use cases include disk partitioning on modern systems using GPT, converting legacy MBR or BSD disks to GPT without data loss, repairing corrupted partition tables, and preparing disks for EFI-based booting or specific OS requirements like Windows or GRUB. It operates on disk devices or raw disk images but not compressed formats.

cgdisk offers a menu-driven interface similar to cfdisk for GPT modifications, with options like Align, Backup, Delete, New, Type, Verify, and Write. fixparts specializes in MBR repairs, such as removing stray GPT data, fixing mis-sized extended partitions, and toggling primary/logical status.

How It Works

gdisk manipulates GPT structures by loading disk data into memory, allowing non-destructive edits until changes are explicitly written with 'w'. It detects partition types (GPT, MBR, BSD) on startup, converting MBR/BSD to GPT if needed while preserving data. Features include CRC checks, sector alignment (default 1 MiB), hybrid MBR creation, and backup/restore of GPT headers and tables. cgdisk uses ncurses menus for interactive selection via arrow keys and Enter. fixparts scans for GPT signatures in MBR disks, auto-repairs extended partitions, and regenerates extended partition containers for logical partitions.

Installation

bash
sudo apt install gdisk

Flags

-aAlters highlighting in cgdisk using '>' symbol instead of ncurses, for limited displays like teletypes or screen readers.

Examples

Launches curses-based GPT manipulator on the specified disk device or image, with -a for alternate highlighting.
cgdisk [ -a ] device
Loads GPT data on /dev/sda, converts MBR/BSD if detected, and provides menu for editing partitions.
cgdisk /dev/sda
Starts MBR repair utility on the target device, scans for stray GPT data, and offers menu-driven fixes.
fixparts device
Repairs mis-sized extended partitions or removes leftover GPT signatures on an MBR disk.
fixparts /dev/sda
Displays the full manual for cgdisk, detailing all interactive options and GPT terminology.
man cgdisk
Displays the manual for fixparts, covering MBR repair functions like toggling active flags or changing types.
man fixparts
Launches the primary text-mode GPT fdisk tool for advanced partitioning operations (refer to man page).
gdisk device
As shown in docs, accesses cgdisk manual from Kali shell for detailed usage.
root@kali:~# man cgdisk
Updated 2026-04-16kali.org ↗