gpart (not GParted) is a small recovery utility that guesses PC-style partition tables when the MBR or primary partition table was overwritten, zeroed, or corrupted—situations that can follow cloning mistakes, dual-boot edits, or storage errors. It scans a block device read-only, reports possible ext4, FAT, LVM, NTFS, and other signatures, and can log results for review.
Most ranking guides and the Ubuntu community GParted wiki document gparted, the graphical partition editor. This article covers gpart, the CLI recovery tool—the package names differ by one letter, and installing the wrong one is a common mistake.
Tested on: Ubuntu 25.04 (Plucky Puffin); kernel 6.14.0-37-generic; amd64;
gpart1:0.3-10 (gpart -Vreports v0.2.3-dev).
dmesg shows I/O errors or SMART failures, clone the disk first—see backup a Linux partition.
gpart vs GParted on Ubuntu
| gpart (this guide) | GParted (most ranking articles) | |
|---|---|---|
| Package | gpart (universe) |
gparted (main) |
| Interface | Terminal CLI | Graphical (GTK) |
| Primary job | Guess lost/corrupt MBR-style partition tables | Create, resize, move, delete, format partitions |
| Typical use | Recovery after table damage | Dual-boot prep, disk layout changes |
| Install | sudo apt install gpart |
sudo apt install gparted |
| Launch | sudo gpart /dev/sdX |
sudo gparted or Activities → GParted |
Need to resize /home or prepare a dual-boot layout? Install gparted, not gpart. Need to investigate a missing partition table on a failing disk? Install gpart (often from Ubuntu live media) and scan read-only first.
Prerequisites
- Ubuntu 22.04 LTS, 24.04 LTS, or newer (25.04 tested here) on amd64.
- sudo for package install and disk scans.
- universe enabled (
gpartis packaged there). - The target disk identified with
lsblk—never guess/dev/sdXon a server with multiple drives.
See check Ubuntu version if you are unsure which release you are on.
Quick command summary
| Task | Command |
|---|---|
| Install | sudo apt update && sudo apt install -y gpart |
| Verify | gpart -V |
| Usage help | gpart (no arguments) or man gpart |
| Read-only scan | sudo gpart -cqv -l ~/gpart-scan.log /dev/sdX |
| Update | sudo apt update && sudo apt upgrade gpart |
| Uninstall | sudo apt purge -y gpart |
Replace /dev/sdX with the whole disk (for example /dev/sda), not a partition or LVM logical volume, when hunting for a lost MBR layout.
Install gpart from Ubuntu apt
Install gpart from Ubuntu universe unless you are building from upstream source for development—which almost no recovery workflow requires.
Refresh indexes and confirm the candidate:
sudo apt update
apt-cache policy gpartOn Ubuntu 25.04:
gpart:
Candidate: 1:0.3-10
1:0.3-10 500
500 http://archive.ubuntu.com/ubuntu plucky/universe amd64 PackagesInstall with apt:
sudo apt install -y gpartExample install output:
The following NEW packages will be installed:
gpart
Need to get 35.2 kB of archives.
After this operation, 82.9 kB of additional disk space will be used.Verify the binary:
gpart -V
which gpartgpart v0.2.3-dev
/usr/sbin/gpartThe Debian package version (1:0.3-10) and gpart -V string differ—that is normal for this upstream release tagging.
Install gpart on Ubuntu live USB
When the partition table on your boot disk is damaged, you often recover from Ubuntu Desktop live media rather than the broken install.
- Boot the Ubuntu ISO and choose Try Ubuntu.
- Open a terminal (Ctrl+Alt+T).
- Install
gpart—it is not preinstalled on the live session (unlike GParted, which Ubuntu live images include):
sudo apt update
sudo apt install -y gpart- Identify disks with
lsblk, then scan the target device read-only.
Run gpart: usage and first scan
Without a device argument, gpart prints usage and options—the same help shown after install:
sudo gpartUsage: gpart [options] device
Options: [-b <backup MBR>][-C c,h,s][-c][-d][-E][-e][-f][-g][-h][-i]
[-K <last sector>][-l <log file>]
[-n <increment>][-q][-s <sector-size>]
[-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.Identify the disk before you scan
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTScan the whole disk (for example /dev/sda), not an LVM logical volume:
sudo gpart /dev/sdaExample output from a test scan on /dev/sda:
Begin scan...
Possible partition(Linux ext2), size(2048mb), offset(2mb)
Possible partition(Linux LVM2 physical volume), size(23549mb), offset(2050mb)
End scan.
Checking partitions...
Partition(Linux ext2 filesystem): invalid primary
Partition(Linux LVM physical volume): invalid primary
Ok.gpart is reporting signatures it found on the media. invalid primary often means the on-disk table does not match what it guessed—exactly the situation you are diagnosing. Do not treat guessed tables as authoritative until you cross-check offsets with fdisk -l, LVM tools, or e2fsck in rescue mode.
Useful gpart flags
| Flag | Purpose |
|---|---|
-c |
Check / compare mode |
-q |
Quiet terminal output |
-l file |
Write a log file |
-i |
Interactive—asks before writing |
-K sector |
Stop scan at sector (faster tests on large disks) |
-h |
Full option list |
Logged scan example:
sudo gpart -cqv -l ~/gpart-scan.log /dev/sda
less ~/gpart-scan.logRead the manual for module weights and advanced recovery:
man gpartAfter install: typical recovery workflow
- Clone or image the failing disk if data matters (
ddrescueor your backup tool). - Install gpart on Ubuntu or boot Ubuntu live media and install
gpartthere. - Scan the disk read-only; save logs with
-l. - Validate guessed offsets against known partition sizes before writing anything back.
- Use testdisk, gdisk, or restore from backup if gpart’s guess does not match reality.
gpart complements—not replaces—partition table backup with sfdisk practices you should have in place before disasters.
Keep gpart updated
gpart updates through normal apt upgrades:
sudo apt update && sudo apt upgrade -y gpartCheck the installed candidate:
apt-cache policy gpart
gpart -VUninstall gpart
sudo apt purge -y gpart
sudo apt autoremove -yConfirm removal:
dpkg -l gpartdpkg-query: no packages found matching gpartTroubleshooting
| Issue | What to check |
|---|---|
gpart: command not found |
sudo apt install gpart; confirm /usr/sbin is on root’s PATH when using sudo. |
apt cannot find gpart |
Enable universe: sudo add-apt-repository universe && sudo apt update. |
| Installed GParted by mistake | gparted is the GUI editor—install gpart for CLI recovery. |
| Scan shows nothing useful | Disk may use GPT only with an intact backup header—try gdisk -l or testdisk. Encrypted LUKS volumes need unlock first. |
| Scan runs for hours | Large disks are slow; use -K to limit test scans, or work from a disk image. |
| I/O errors during scan | Stop—treat as hardware failure; image the disk before further reads. |
Summary
Install gpart on Ubuntu with sudo apt install gpart from universe, confirm with gpart -V, identify the correct /dev/sdX disk with lsblk, and run a read-only scan. On a live USB, install gpart after booting Try Ubuntu—it is not bundled like GParted. Save logs with -l when you need to share results.
Do not confuse gpart (partition-table guessing for recovery) with gparted (graphical resize and layout editing). Use guessed layouts cautiously; pair this tool with backups, testdisk, or professional recovery when the data is irreplaceable.
References
- gpart man page (Debian)
- Ubuntu community wiki — GParted (graphical editor, different package)
- On-site: e2fsck in rescue mode, backup partition table, repair Debian after power outage, check Ubuntu version

