Losing a partition entry hides installed systems, data volumes, and backups behind a missing record in the partition table while leaving the underlying data largely intact. Restoring that entry re-exposes the existing filesystem, avoiding slower file-by-file recovery and reducing downtime.
On Linux, the tool TestDisk scans block devices such as /dev/sda for filesystem signatures and partition metadata, then proposes entries that rebuild the original partition table layout. Operations work directly on the disk rather than through mounted filesystems, which allows recovery even when no partitions appear in normal tools.
Safe recovery depends on minimizing writes to the affected disk. Booting from a live Linux distribution such as Ubuntu, unmounting any partitions on the target disk, and only writing changes once the proposed layout has been carefully checked helps reduce the risk of further data loss.
Related: How to check disk errors in Linux
Related: How to mount disks and partitions in Linux
Steps to recover lost or deleted partition for free using Linux:
- Boot the computer using a live Linux distribution, such as Ubuntu.
- Enter Live CD mode when available if booting from an installer image.
For Ubuntu installer, click the Try Ubuntu button.
- Open a terminal.
If no Live CD mode is available, press <ctrl> + <alt> + <f2> keys to get to the terminal.
- Identify the disk containing the lost or deleted partition.
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 1.9G 1 loop /rofs loop1 7:1 0 89.3M 1 loop /snap/core/6673 loop2 7:2 0 53.7M 1 loop /snap/core18/941 loop3 7:3 0 151M 1 loop /snap/gnome-3-28-1804/31 loop4 7:4 0 4M 1 loop /snap/gnome-calculator/406 loop5 7:5 0 14.8M 1 loop /snap/gnome-characters/254 loop6 7:6 0 1008K 1 loop /snap/gnome-logs/61 loop7 7:7 0 3.7M 1 loop /snap/gnome-system-monitor/77 loop8 7:8 0 35.3M 1 loop /snap/gtk-common-themes/1198 sda 8:0 0 20G 0 disk sr0 11:0 1 2G 0 rom /cdrom
Look for the disk size or label to identify the correct disk.
- Ensure partitions on the target disk are not mounted before recovery.
$ mount | grep sda $ sudo umount /dev/sda1
Writing to mounted partitions on the affected disk can overwrite recoverable data and permanently destroy filesystems.
- Enable additional repositories if TestDisk is not available from the default sources on Ubuntu.
$ sudo add-apt-repository universe 'universe' distribution component enabled for all sources. ##### snipped #####
- Install TestDisk if it is not already installed.
$ sudo apt install --assume-yes testdisk Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: testdisk 0 upgraded, 1 newly installed, 0 to remove and 316 not upgraded. Need to get 345 kB of archives. ##### snipped #####
- Launch TestDisk from the terminal.
$ sudo testdisk
- Select No Log with the arrow keys and press [ENTER].

- Select the disk with the lost or deleted partition and press [ENTER] to proceed.

- Select the disk's partition table type and press [ENTER].
Intel is the most common partition type with EFI GPT starting to gain popularity.
- Press [ENTER] to start analysing the disk.

- Press [ENTER] again to search for potential partitions on the chosen disk.

- Select the found partition and press [ENTER] to continue.

- Choose Write and press [ENTER] to update the partition table.
Writing an incorrect partition layout can make existing data harder to recover, so the proposed start and end positions should match expectations before confirming.
- Press Y to confirm the partition table update.

- Press [ENTER] on Ok to continue.

- Select Quit and press [ENTER] to return to the disk selection menu.

- Select Quit and press [ENTER] to exit TestDisk.

- Verify that the partition has been recovered by listing block devices again.
$ lsblk
- Restart the computer to apply the changes and load the recovered partition table.
$ sudo reboot
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
Comment anonymously. Login not required.
