The partition table of a hard disk holds all the information about where each partition begins and ends. If the partition table gets deleted or becomes corrupt in some way, most likely your operating system will not be able to boot or you will face other hard disk issues. But there is good news: if your partition table is lost, it is possible to recover it using software such as testdisk.
In this tutorial, we will go over the step by step instructions of booting into recovery mode, installing testdisk, and recovering a deleted partition table on a Linux system. After successful recovery of the partition table, you should be able to boot back into your Linux distro and go about using the system as normal – at least if there are no other underlying issues.
Privileged access to your Linux system as root or via the sudo command.
Conventions
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command $ – requires given linux commands to be executed as a regular non-privileged user
How to recover partition table in Linux step by step instructions
In order to start with the recovery of the partition table, we will need to boot into the live CD mode of a Linux distro. It does not really matter which distro you decide to use for this, but we will be covering the instructions for Ubuntu Linux, as we must pick one to cover and can’t possibly cover every distro or Live CD out there.
You can download an Ubuntu ISO from Ubuntu’s download page or check out our guide on Live CD/DVD Linux downloads if you want to use a different distribution. Afterwards, create a bootable USB drive with your ISO or burn a live CD or DVD.
With your boot media inserted, turn on the computer and boot into live mode. In the case of Ubuntu, that means clicking on the “Try Ubuntu” option.
👁 Boot into the live mode of your Linux distro Boot into the live mode of your Linux distro
Once you are loaded into the live environment, open a terminal and install the testdisk package with your distro’s package manager. In the case of Ubuntu, first enable the universe repository with sudo add-apt-repository universe, then install the package:
Select the partition type. Most likely this will be Intel/PC unless you are using a more specialized system.
👁 Select partition type (probably Intel/PC) Select partition type (probably Intel/PC)
Proceed with the Analyse option to search for partition tables.
👁 Use the Analyse option Use the Analyse option
Choose the Quick search option to locate partition tables.
👁 Choose Quick search option Choose Quick search option
Highlight the found partition, simply called Linux in our case, and press Enter to proceed with recovering the partition table.
👁 Highlight the correct partition table and recover it Highlight the correct partition table and recover it
Testdisk will ask once again if you want to confirm these changes. Answer Y to proceed.
When done, quit out of the testdisk menu.
👁 Quit testdisk Quit testdisk
Now you can reboot your system for the changes to take effect. Also be sure to eject your boot media before doing so.
Closing Thoughts
In this tutorial, you saw how to recover a partition table on a Linux system. This was accomplished through the testdisk software, which comes in as a real life saver when if you accidentally delete your disk’s partition table or it becomes corrupt in some way. After recovery, you should be able to boot back into your operating system like usual.