A missing partition table entry can make Linux show a disk as empty even when the filesystem data is still on the media. Recovering the entry restores the partition boundary in the disk map, which is safer than file-by-file recovery when the lost partition can still be identified.
TestDisk scans a whole disk such as /dev/sdb or /dev/nvme1n1 for old partition boundaries and filesystem signatures. It lets you inspect the directory listing before writing the recovered partition table, so the disk name, partition size, start position, and visible files all need to match the lost volume.
Work from live Ubuntu media when the affected disk might otherwise stay mounted or active. If the missing volume lives inside LUKS, LVM, mdraid, or another storage layer, recover that layer instead of rewriting the outer disk partition table, and check disk health first when kernel logs already show read errors.
Steps to recover a missing disk partition table entry with TestDisk in Linux:
- Start a live Ubuntu session from installation media.
Choose Try Ubuntu on the installer menu so recovery runs from temporary media instead of the disk being repaired.
- Open a terminal in the live session.
If the graphical desktop is unavailable, switch to a text console such as <ctrl> + <alt> + <f2>.
- Identify the whole disk that contains the missing partition entry.
$ lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS NAME SIZE TYPE FSTYPE MOUNTPOINTS sda 476G disk ├─sda1 1G part vfat /boot/efi ├─sda2 2G part ext4 /boot └─sda3 473G part LVM2_member sdb 931G disk
Run TestDisk against the whole disk such as /dev/sdb, not a partition such as /dev/sdb1.
- Check whether any partition from the affected disk is mounted.
$ lsblk -o NAME,MOUNTPOINTS /dev/sdb NAME MOUNTPOINTS sdb `-sdb1 /mnt/data
- Unmount every mounted partition from the affected disk.
$ sudo umount /dev/sdb1
Do not mount or write to the affected partition during recovery because new metadata can overwrite the filesystem being restored.
- Identify a mounted backup volume on a different physical disk. Example output:
$ lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS NAME SIZE TYPE FSTYPE MOUNTPOINTS ##### snipped ##### sdb 931G disk sdc 1.8T disk └─sdc1 1.8T part ext4 /media/ubuntu/Backup
/dev/sdb is the affected disk, while /dev/sdc1 belongs to the separate disk /dev/sdc and is mounted at /media/ubuntu/Backup. The backup volume needs free space for the entire affected disk and a filesystem that supports an image file that large. In a normal live session without persistence, the home folder is held in memory and its contents disappear after a restart.
- Save a whole-disk image before starting TestDisk.
A wrong partition-table write can make the original filesystem harder to recover. An image on separate storage preserves the current disk state before any recovery writes, including file data and both copies of a GPT table, even when the table is already wiped; this is especially important for irreplaceable files.
$ sudo dd if=/dev/sdb of=/media/ubuntu/Backup/sdb-before-testdisk.img bs=4M status=progress conv=fsync
- Verify that the saved image matches the affected disk.
$ sudo cmp /dev/sdb /media/ubuntu/Backup/sdb-before-testdisk.img
No output and a successful exit mean the image matches; any copy or comparison error means the checkpoint is incomplete. Do not proceed to Write unless both commands finish successfully. If a TestDisk write must be undone, restoring this image overwrites the entire target disk and returns it to its damaged pre-recovery state. Only with the original disk identified again and all its partitions unmounted, the rollback command is:
$ sudo dd if=/media/ubuntu/Backup/sdb-before-testdisk.img of=/dev/sdb bs=4M status=progress conv=fsync
- Refresh the package index in the live session.
$ sudo apt update
- Install the testdisk package.
$ sudo apt install testdisk
The Ubuntu distribution package is named testdisk. Connect the live session to a network first if the package is not already cached on the installation media.
- Start TestDisk on the whole disk device.
$ sudo testdisk /dev/sdb
- Select Create to save a recovery log, or No Log if the live session is disposable.
A saved log helps compare what TestDisk detected before any partition table write.
- Select the disk with the missing partition and press [ENTER].

- Accept the detected partition table type.
Intel is typical for MBR disks, while EFI GPT is typical on UEFI systems. Choose another type only when the disk was created that way.
- Select Analyse to inspect the partition map.

- Confirm Quick Search to scan for lost partitions.

- Highlight a found partition and press P to list its files.
Continue only when the directory names and files match the lost volume.
- Press Q to return from the file listing to the partition list.
- Run Deeper Search when Quick Search does not find the missing partition or the reported boundaries are wrong.
Deeper Search can take a long time on large disks, so prevent the live session from sleeping until the scan finishes.
- Change the recovered partition from D to P, L, or * when TestDisk still marks it as deleted.
Ordinary data partitions are usually P or L. Use only one bootable * partition on a disk that must boot an operating system.
- Choose Write to save the recovered partition layout.
Write the change only after the partition boundaries and file listing match the lost volume because a wrong layout can hide the real filesystem and make later recovery harder.
- Press Y to confirm the partition table update.

- Press [ENTER] on Ok after the success message.

- Select Quit to return to the disk selection screen.

- Select Quit again to exit TestDisk.

- Restart the live session, or disconnect and reconnect a non-system removable disk, so the kernel reloads the restored partition table.
TestDisk reports You have to reboot for the change to take effect. after a successful partition table write.
- Verify that the partition entry is visible again before mounting the filesystem.
$ lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS /dev/sdb NAME SIZE TYPE FSTYPE MOUNTPOINTS sdb 931G disk `-sdb1 931G part ext4
- Create a mount point for the recovered filesystem.
$ sudo mkdir -p /mnt/recovered
- Mount the recovered ext4 partition without replaying its journal.
A plain read-only ext4 mount can replay the journal and write to the disk. The ro,noload options prevent writes and journal replay; files may reflect the state before pending journal changes.
$ sudo mount -t ext4 -o ro,noload /dev/sdb1 /mnt/recovered
If the recovered filesystem is not ext4, the no-replay option depends on its type; XFS uses -t xfs -o ro,norecovery. Skipping XFS log recovery can leave some files inaccessible after an unclean shutdown.
- List the recovered files in a familiar directory.
$ ls /mnt/recovered/Documents project-notes.txt
The directory and filenames depend on the recovered volume. A visible partition entry alone does not prove its files are accessible.