A missing partition table can make an intact filesystem inaccessible. Ubuntu's gpart package provides a command-line scanner for locating lost partitions and can be installed on an existing system or in a desktop live session.

gpart is a legacy tool that guesses PC-style MBR primary partitions from filesystem signatures. It cannot recover a GPT partition table, and its detection of extended and logical partitions is unreliable. Its findings are candidates for recovery, not confirmation that the files are intact.

An Ubuntu desktop live session keeps package installation away from a damaged system disk. The installation needs an Internet connection and sudo access; packages installed in a live session without persistence disappear at shutdown. An installed Ubuntu system is also suitable when its system drive is not the disk being investigated.

Steps to install gpart on Ubuntu:

  1. Update Ubuntu's package lists.
    $ sudo apt update
  2. Install the repository management utility if add-apt-repository is unavailable.
    $ sudo apt install --assume-yes software-properties-common

    Ubuntu desktop installations and the official Ubuntu 26.04 desktop live image already include this utility. Minimal installed systems may need the package.

  3. Enable Ubuntu's universe repository.
    $ sudo add-apt-repository --yes universe

    gpart is maintained in Ubuntu's community universe component. The official Ubuntu 26.04 desktop live image already enables it, but an installed or customized system can have it disabled. This command also refreshes the package lists and is safe to repeat when universe is already enabled.

  4. Install the gpart package.
    $ sudo apt install --assume-yes gpart
    ##### snipped #####
    Setting up gpart (1:0.3-10build1) ...
    ##### snipped #####

    The package is available in Ubuntu 22.04, 24.04, and 26.04. The displayed package version is from Ubuntu 26.04; other releases can report a different revision.

  5. Identify the affected whole disk in the device listing.
    $ lsblk -o NAME,SIZE,TYPE,PTTYPE,FSTYPE,MOUNTPOINTS,MODEL

    The disk's size and model distinguish it from the Ubuntu system drive. The scan target is a whole disk such as /dev/sdb, rather than a partition such as /dev/sdb1. Device names can change after booting a live session. A gpt partition-table type requires another tool; a lost table may leave PTTYPE blank. An idle, unmounted disk or a disk image avoids changes from other software during the scan.

  6. Scan the affected whole disk for lost MBR partitions.
    $ sudo gpart /dev/sdb
    
    Begin scan...
    Possible partition(Linux ext2), size(16mb), offset(1mb)
    End scan.
    
    Checking partitions...
    Partition(Linux ext2 filesystem): primary 
    Ok.
    
    Guessed primary partition table:
    Primary partition(1)
       type: 131(0x83)(Linux ext2 filesystem)
       size: 16mb #s(32768) s(2048-34815)
       chs:  (6/8/1)-(108/15/16)d (6/8/1)-(108/15/16)r
    ##### snipped #####

    This invocation only reads the disk; it does not write a partition table or recover files. Here, gpart identifies a 16 MiB ext2 primary partition starting at sector 2048. Partition types, sizes, and offsets depend on the disk. A scan can take a long time, and an empty result or a disk-geometry error does not prove that no files remain. GPT recovery and writing a recovered partition table require another tool.
    Related: Recover a partition table with TestDisk

Share this guide