How to Install gpart on Ubuntu

Install gpart on Ubuntu with sudo apt install gpart from universe, run a read-only scan when the MBR or partition table is damaged, use gpart on a live USB, and know how gpart differs from the GParted graphical editor.

Published

Updated

Read time 6 min read

Reviewed byDeepak Prasad

Install gpart on Ubuntu banner with disk partition recovery terminal motif

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; gpart 1:0.3-10 (gpart -V reports v0.2.3-dev).

WARNING
Work on a backup or disk image when possible. Writing a guessed partition table to the wrong device can make recovery harder. If 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 (gpart is packaged there).
  • The target disk identified with lsblk—never guess /dev/sdX on 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:

bash
sudo apt update
apt-cache policy gpart

On Ubuntu 25.04:

text
gpart:
 Candidate: 1:0.3-10
 1:0.3-10 500
 500 http://archive.ubuntu.com/ubuntu plucky/universe amd64 Packages

Install with apt:

bash
sudo apt install -y gpart

Example install output:

text
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:

bash
gpart -V
which gpart
text
gpart v0.2.3-dev
/usr/sbin/gpart

The 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.

  1. Boot the Ubuntu ISO and choose Try Ubuntu.
  2. Open a terminal (Ctrl+Alt+T).
  3. Install gpart—it is not preinstalled on the live session (unlike GParted, which Ubuntu live images include):
bash
sudo apt update
sudo apt install -y gpart
  1. Identify disks with lsblk, then scan the target device read-only.
NOTE
The Ubuntu community wiki warns that editing partitions on the disk hosting your running OS can corrupt the system. Live media—or a clone image—is the safe place for recovery work on the boot drive.

Run gpart: usage and first scan

Without a device argument, gpart prints usage and options—the same help shown after install:

bash
sudo gpart
text
Usage: 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

bash
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT

Scan the whole disk (for example /dev/sda), not an LVM logical volume:

bash
sudo gpart /dev/sda

Example output from a test scan on /dev/sda:

text
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:

bash
sudo gpart -cqv -l ~/gpart-scan.log /dev/sda
less ~/gpart-scan.log

Read the manual for module weights and advanced recovery:

bash
man gpart

After install: typical recovery workflow

  1. Clone or image the failing disk if data matters (ddrescue or your backup tool).
  2. Install gpart on Ubuntu or boot Ubuntu live media and install gpart there.
  3. Scan the disk read-only; save logs with -l.
  4. Validate guessed offsets against known partition sizes before writing anything back.
  5. 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:

bash
sudo apt update && sudo apt upgrade -y gpart

Check the installed candidate:

bash
apt-cache policy gpart
gpart -V

Uninstall gpart

bash
sudo apt purge -y gpart
sudo apt autoremove -y

Confirm removal:

bash
dpkg -l gpart
text
dpkg-query: no packages found matching gpart

Troubleshooting

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


Frequently Asked Questions

1. What is gpart on Ubuntu?

gpart is a GPL recovery tool that guesses PC-style MBR partition layouts when the partition table is missing or corrupted. It scans raw block devices and reports possible ext4, FAT, LVM, and other signatures—it does not resize or create partitions like GParted.

2. How do I install gpart on Ubuntu?

Run sudo apt update && sudo apt install -y gpart. The package lives in universe on current Ubuntu releases. Verify with gpart -V. On a live USB session, run the same commands after enabling network if indexes are stale.

3. Is gpart the same as GParted?

No. GParted is a graphical partition editor (sudo apt install gparted). gpart guesses lost partition tables for forensic and recovery work. Ranking guides often cover GParted; this article is for the gpart CLI package in universe.

4. Can I run gpart on a mounted root disk?

You can scan read-only, but do not write a guessed table to a live system disk without backups. Boot Ubuntu live media, work on a clone image, or scan a secondary disk—not the one hosting your running root filesystem unless you know exactly what you are doing.

5. How do I install gpart on Ubuntu live USB?

Boot Try Ubuntu, open a terminal, run sudo apt update && sudo apt install -y gpart. Ubuntu live ISOs include GParted by default but not gpart—you install gpart when you need partition-table guessing, not GUI resizing.

6. When should I use testdisk instead of gpart?

Use testdisk when you need interactive partition recovery, EFI GPT repair, or boot sector rebuilds. gpart is a lightweight guesser; testdisk and professional imaging tools are better when data is critical or the disk may be failing.

7. How do I update gpart on Ubuntu?

Run sudo apt update && sudo apt upgrade gpart, or upgrade all packages with sudo apt upgrade. Confirm with gpart -V and apt-cache policy gpart.

8. How do I uninstall gpart from Ubuntu?

Run sudo apt purge -y gpart. It is a standalone CLI tool with no background service.
Deepak Prasad

R&D Engineer

Founder of GoLinuxCloud with more than 15 years of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive …