| Tested on | Ubuntu 26.04 LTS (Resolute Raccoon) |
|---|---|
| Package | gpart 1:0.3-10build1 (Universe) |
| Applies to | Ubuntu 22.04 LTS, 24.04 LTS, and 26.04 LTS |
| Privilege | sudo or root to read raw block devices; normal gpart scan is read-only unless you use write options such as -W |
| Scope | Install the legacy gpart CLI (not GParted), decide whether an MBR disk fits this beta-era tool, run a read-only scan with sudo, and interpret heuristic guesses without writing -W. Does not cover GUI editing, GPT table reconstruction, TestDisk walkthroughs, or copy-paste write-back. |
| Related guides | Check Ubuntu version |
gpart is a command-line utility that guesses lost PC-style MBR partition layouts when the primary partition table was damaged or overwritten. It is not GParted (gparted): the graphical editor most install guides cover is for creating, resizing, and formatting partitions, while gpart is for partition-recovery guessing on legacy MBR disks.
The steps below were run on Ubuntu 26.04 with package 1:0.3-10build1. The same apt install gpart workflow applies on 24.04 and 22.04; always confirm MBR vs GPT before you scan. Ubuntu systems installed in UEFI mode commonly use GPT, where gpart is not the right first tool.
Quick answer
gpart is a partition-recovery CLI, not the GParted graphical partition editor.
On Ubuntu 26.04, 24.04, and 22.04, install it from Universe:
Refresh indexes before installing from Universe:
sudo apt updateInstall the gpart package:
sudo apt install gpartConfirm the binary responds:
gpart -VSample output:
gpart v0.2.3-devThe program's embedded -V string is old and does not match Ubuntu's Debian package revision—use apt-cache policy gpart when you need the installed package version.
/dev/sdX is a placeholder for the whole disk, not a name to type literally. Your device may be /dev/sda, /dev/vda, /dev/nvme0n1, or /dev/mmcblk0. Use lsblk to identify it.
Before scanning, check whether the disk uses MBR (dos) or GPT (substitute your whole-disk path for /dev/sdX):
sudo fdisk -l /dev/sdXLook for Disklabel type: dos (MBR) or Disklabel type: gpt. gpart targets PC-type MBR recovery; for GPT, start with gdisk or TestDisk before spending time on gpart. The check disk type in Linux guide walks the same fdisk -l and parted checks when you need a fuller storage picture.
A normal gpart scan is read-only, but reading a raw block device usually requires root—use the sudo command if your account cannot open /dev/sdX yet:
sudo gpart /dev/sdXDo not write a guessed partition table until you have independently verified sector boundaries. This guide does not include a copy-paste -W write-back command.
Before you begin
Partition recovery works directly with disk devices, so identify the target carefully before you run any command.
In this guide:
- MBR (Master Boot Record) is the older PC partition-table format that
fdiskreports asdos. - GPT (GUID Partition Table) is the newer format commonly used on UEFI systems.
- A partition table is the on-disk map that records where each partition starts and ends.
/dev/sdXmeans the whole target disk (placeholder)./dev/sda1or/dev/nvme0n1p1is a partition on that disk—not the whole device. For NVMe,/dev/nvme0n1is the disk and/dev/nvme0n1p1is partition 1.- A heuristic guess is an educated guess from filesystem signatures; it is not authoritative partition-table metadata.
- A disk image is a sector-level copy of a drive on healthy storage so tools can analyze the copy instead of re-reading failing hardware.
- A normal
gpartscan only reads the device.-Wwrites a guessed table and is intentionally not used in this guide. sudois normally required to read raw block devices such as/dev/sda.
If dmesg reports I/O errors or the disk may be failing, image it before repeated recovery scans. Avoid writing partition-table changes while filesystems from the target disk are mounted; for the system disk, use a live session or work from an image.
gpart vs GParted: which one do you need?
Google often mixes up gpart and gparted. The packages are unrelated:
gpart (this guide) |
gparted (GUI editor) |
|
|---|---|---|
| Package | gpart (universe) |
gparted (main) |
| Interface | Terminal | Graphical (GTK) |
| Job | Guess lost or corrupt MBR-style tables | Create, resize, move, delete, format partitions |
| Install | sudo apt install gpart |
sudo apt install gparted |
| Typical launch | sudo gpart /dev/sdX |
gparted or Activities → GParted |
Need to resize /home or lay out dual boot? Use GParted or the parted command, not gpart. Need to investigate a missing MBR partition table on a secondary disk? Install gpart, identify the correct /dev/sdX with lsblk, and scan read-only first.
Is gpart the right recovery tool?
Upstream describes gpart as guessing partitions on PC-type, MBR-partitioned disks by scanning for filesystem signatures. The Debian man page still labels gpart beta software and warns that guesses can be wrong.
gpart is a legacy MBR-oriented recovery utility, not the default partition tool for every modern disk. Ubuntu keeps packaging it because reconstructing old PC-style MBR layouts can still help—but on GPT disks or broad recovery jobs, start elsewhere.
Use gpart for MBR partition recovery
gpart can help when an MBR (DOS) disk label is missing or corrupt and you need possible start/end locations for lost partitions before deeper recovery work.
Use GPT-aware tools for GPT disks
On GPT, partition metadata lives in primary and backup headers. Recovery is different from reconstructing an MBR table. If fdisk -l reports Disklabel type: gpt, start with gdisk or TestDisk. sgdisk helps with scripted GPT backup, restore, and repair when you already know what to change—it is not usually the first interactive discovery step.
Choose a starting tool
| Problem | Better starting tool |
|---|---|
| Lost or damaged MBR partition table | gpart or TestDisk |
| Damaged GPT metadata | gdisk or TestDisk (sgdisk for scripted GPT repair) |
| Resize, create, or format partitions | GParted |
| Failing disk / I/O errors | ddrescue (image first) |
| Lost individual files | TestDisk, PhotoRec, or filesystem tools |
Clone a failing disk before scanning
gpart scans across the disk looking for filesystem signatures (not a single sequential read of every sector in all modes). On a physically failing drive, repeated scans can still stress the media. If dmesg shows I/O errors or SMART reports failure, stop and image the disk (for example with ddrescue) before more reads. Work from the image when you can—gpart can scan a plain file with -g when you pass a disk image path instead of /dev/sdX.
┌──────────────────────────┐
│ Partition table missing │
│ or MBR table damaged? │
└────────────┬─────────────┘
│
┌────────────▼─────────────┐
│ Healthy disk (no I/O │
│ errors in dmesg)? │
└────────────┬─────────────┘
no │ yes
┌─────┴─────┐
▼ ▼
┌────────────┐ ┌──────────────┐
│ ddrescue │ │ MBR or GPT? │
│ image first│ └──────┬───────┘
└─────┬──────┘ │
│ ┌────┴────┐
│ ▼ ▼
│ ┌─────────┐ ┌──────────────┐
│ │ gpart │ │ gdisk / │
│ │ (MBR) │ │ TestDisk GPT │
│ └────┬────┘ └──────────────┘
└───────────┤
▼
┌───────────────────┐
│ Verify guesses; do │
│ not auto-write -W │
└───────────────────┘Partition recovery and physical disk recovery are different problems—image failing hardware first, then analyze.
-W to the wrong device can make recovery harder. See backup a Linux partition before destructive steps.
gpart versions on Ubuntu 26.04, 24.04, and 22.04
| Ubuntu | gpart package (Universe) |
|---|---|
| 26.04 LTS | 1:0.3-10build1 |
| 24.04 LTS | 1:0.3-10 |
| 22.04 LTS | 1:0.3-9 |
Installation is the same on all three: sudo apt install gpart after universe is enabled.
Install gpart on Ubuntu
Enable Universe if the package is missing
gpart lives in universe. If apt cannot find the package:
sudo add-apt-repository universeIf add-apt-repository is missing on a minimal image, install software-properties-common first.
Refresh indexes after enabling the repository:
sudo apt updateInstall and verify gpart
Check the candidate version before you install:
apt-cache policy gpartOn Ubuntu 26.04 the lab showed:
gpart:
Installed: (none)
Candidate: 1:0.3-10build1
Version table:
1:0.3-10build1 500
500 http://in.archive.ubuntu.com/ubuntu resolute/universe amd64 PackagesInstall with apt:
sudo apt install gpartSample install summary:
The following NEW packages will be installed:
gpart
Need to get 36.2 kB of archives.
After this operation, 82.9 kB of additional disk space will be used.Confirm the version string and binary location:
gpart -Vgpart v0.2.3-devThe binary should live under /usr/sbin:
command -v gpart/usr/sbin/gpartgpart installs under /usr/sbin. If a normal user shell does not include /usr/sbin on PATH, run scans with sudo gpart ... rather than assuming the package failed to install.
Install gpart in an Ubuntu live session
When the boot disk's partition table is damaged, recovery often happens from Ubuntu Desktop live media—boot the ISO and choose Try Ubuntu (run Ubuntu from USB without installing it), not the broken install. If you still need installable media, follow create bootable USB from ISO on Linux first, then add gpart from the live session terminal.
Boot the ISO, open a terminal, and install gpart if it is not already present. Live images may not include gpart; with networking available, use the same sudo apt update and sudo apt install gpart commands as on an installed system.
Identify disks before you scan—never guess /dev/sdX on a machine with multiple drives. If the disk is physically failing, image it before repeated installs and scans from the live environment.
Identify the correct disk before scanning
Check the disk with lsblk
List whole disks with model and transport so you do not pick the wrong device:
lsblk -o NAME,SIZE,MODEL,TRAN,TYPE,FSTYPE,MOUNTPOINTSSample lines from the 26.04 lab:
NAME SIZE MODEL TRAN TYPE FSTYPE MOUNTPOINTS
sda 30.8G VBOX HARDDISK sata disk
├─sda1 1M part
├─sda2 2G part ext4 /boot
└─sda3 28.8G part LVM2_memberScan the whole disk (/dev/sda), not a partition (/dev/sda1) or an LVM logical volume, when you are hunting for a lost MBR layout. /dev/sda is the disk; /dev/sda1 is one partition on it.
Check whether the disk uses MBR or GPT
Read the disk label before you run gpart:
sudo fdisk -l /dev/sdaOn a GPT lab disk, output includes:
Disklabel type: gptIf you see Disklabel type: dos, the disk uses MBR and gpart is in scope. For gpt, switch to gdisk or TestDisk first.
sudo parted -l is another way to inspect disk labels across all devices.
Scan a disk with gpart
Run a read-only scan
With no device argument, gpart prints usage (same text as man gpart overview):
sudo gpartUsage: gpart [options] device
Options: [-b <backup MBR>][-C c,h,s][-c][-d][-E][-e][-f][-g][-h][-i]
[-K <last sector>][-k <# of sectors>][-L][-l <log file>]
...
[-V][-v][-W <device>][-w <module-name,weight>]
gpart v0.2.3-dev (c) 1999-2001 Michail Brzitwa <michail@brzitwa.de>.
Guess PC-type hard disk partitions.Run a scan against the whole disk (read-only by default):
sudo gpart /dev/sdXReplace /dev/sdX with your target disk. On a GPT system disk, gpart may still report Possible partition lines from stale filesystem signatures—that is why label checks matter. A truncated lab scan on /dev/sda (GPT) showed:
Begin scan...
Possible partition(Linux ext2), size(2048mb), offset(2mb)
End scan.
Checking partitions...
* Warning: partition(Linux ext2 filesystem) starts beyond disk end.
Partition(Linux ext2 filesystem): invalid primary
Ok.Treat Possible partition as a clue, not proof that a recoverable partition exists at that offset today.
Save scan results to a log
Save terminal output for later review:
sudo gpart -v -l ~/gpart-scan.log /dev/sdXAdd -q if you want less terminal noise while the log file still captures detail.
Open the log when you need to compare runs or share results:
less ~/gpart-scan.logScan a disk image instead of the physical drive
After ddrescue or another imager produces disk.img, scan the file so the physical drive stays idle:
sudo gpart -g /path/to/disk.img-g tells gpart not to query disk geometry from the OS for a plain file. This pattern is often safer than re-reading a failing disk. Use sudo only if file permissions require it.
Useful gpart flags
| Flag | Meaning |
|---|---|
-c |
Check / compare mode |
-q |
Quiet terminal output |
-l file |
Write a log file |
-i |
Ask whether to accept each detected possible partition (not a safety gate before -W) |
-W device |
Write the guessed primary partition table—destructive; not used in this guide |
-g |
Scan a disk image file without OS geometry |
-K sector |
Stop scanning at this sector; useful when you already know the region worth examining |
-h |
Full option list |
gpart has a -W option capable of writing a guessed table. This article intentionally omits a copy-paste write-back example because a wrong guess can make recovery harder. Validate layout with fdisk, LVM tools, or imaging workflows first.
Understand gpart results
Possible partition
A Possible partition line means gpart found filesystem-like data at an offset. Old headers can remain after repartitioning, so the line does not prove a valid, mountable partition is there now.
primary, logical, orphaned, and invalid
During the check phase, gpart tries to build a consistent MBR layout. invalid primary means it saw a signature but could not accept it as a consistent primary partition—overlaps, implausible geometry, disk-size mismatch, stale signatures, or other conflicts. It is a diagnostic clue, not a simple message that "the table is wrong."
Why gpart can find old or false filesystem signatures
The manual warns that guesses can be terribly wrong: stale superblocks, former layouts, and false positives are common. Cross-check proposed boundaries against disk size, existing fdisk output, a second tool such as TestDisk, and any known partition metadata. Work from an image when the data is important.
A safe partition-recovery workflow
- Image the disk if hardware may be failing or data is critical.
- Install
gparton Ubuntu or a live session. - Confirm MBR with
fdisk -l—skipgpartas the first tool on GPT disks. - Scan read-only; save logs with
-l. - Verify guessed sector ranges before any write (
-Wor other tools). - Fall back to TestDisk,
gdisk, or backups from sfdisk partition-table backups when guesses do not match reality.
Update gpart
Refresh package indexes:
sudo apt updateUpgrade only the gpart package:
sudo apt install --only-upgrade gpartConfirm the installed revision:
apt-cache policy gpartRe-check the program version string after the upgrade:
gpart -VRoutine Ubuntu security updates may refresh related tooling on the system; keep applying normal apt upgrade maintenance on recovery workstations.
Uninstall gpart
Remove the package when you no longer need the CLI:
sudo apt remove gpartConfirm removal:
dpkg-query -W gpartWhen the package is gone, dpkg-query reports no matching package. For broader cleanup patterns, see how to remove software on Ubuntu.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
gpart: command not found |
Package not installed or /usr/sbin not on user PATH |
sudo apt install gpart; run sudo gpart or use command -v gpart as root |
Unable to locate package gpart |
Universe disabled | sudo add-apt-repository universe then sudo apt update |
| Installed GParted by mistake | Similar name, different package | Install gpart for CLI recovery; use gparted only for GUI editing |
| gpart shows no useful partitions | GPT disk, encryption, or empty media | Check fdisk -l; try gdisk or TestDisk. Encrypted or containerized layouts may need tools that understand that layer—missing gpart output does not mean data is gone. |
| Disk uses GPT instead of MBR | UEFI/GPT layout | Do not expect gpart to replace GPT header recovery |
| Scan takes a very long time | Large disk, full-sector scan | Work from an image; trial with -K on a test run |
| Disk reports I/O errors | Hardware failure | Stop scanning; image with ddrescue before further reads |
| Did you mean GParted? | Search ambiguity | This page is for gpart recovery CLI, not gparted |
Summary
Install gpart on Ubuntu with sudo apt install gpart from Universe on 26.04, 24.04, or 22.04, verify with gpart -V and command -v gpart, and use sudo fdisk -l to see whether the disk is MBR or GPT before you scan. Normal runs are read-only, but raw devices need root; -W is the write path and stays out of this guide until you validate guesses independently.
gpart guesses MBR-style layouts and can report stale signatures on GPT disks—treat output as heuristic. GParted remains the tool for everyday partition editing. Image failing disks first, prefer scanning disk images when possible, and pair guesses with backups, TestDisk, or gdisk when the data matters.
References
- gpart man page (Debian)
- gpart upstream (GitHub)
- Ubuntu Packages — gpart
Frequently Asked Questions
Is gpart the same as GParted?
No. GParted (gparted) is a graphical partition editor for creating and resizing partitions. gpart (gpart) is a CLI tool that guesses lost MBR-style partition tables. The package names differ by one letter.
Does gpart work on Ubuntu 26.04?
Yes. Install gpart from Universe (1:0.3-10build1 on current 26.04 archives). Verify with gpart -V and command -v gpart.
Does this guide work on Ubuntu 24.04 and 22.04?
Yes. Enable Universe if needed, then sudo apt install gpart. Package revisions differ slightly (1:0.3-10 on 24.04, 1:0.3-9 on 22.04) but the commands match.
Can gpart recover GPT partitions?
Not as a GPT partition-table recovery tool. gpart may notice filesystem signatures on a GPT disk, but it does not reconstruct GPT metadata. Start with gdisk or TestDisk for GPT recovery.
Does gpart modify the disk during a normal scan?
A default scan is read-only. The -W option can write a guessed primary partition table and is destructive if the guess is wrong. This guide sticks to read-only scans and verification.
Should I use gpart or TestDisk?
Use gpart for lightweight MBR layout guessing and logging. Use TestDisk for interactive recovery, EFI/GPT repair, and boot-sector work when you need a broader recovery workflow.

