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
sudo apt install gdiskFlags
Examples
cgdisk [ -a ] devicecgdisk /dev/sdafixparts devicefixparts /dev/sdaman cgdiskman fixpartsgdisk deviceroot@kali:~# man cgdisk