How to recover partition table in Linux

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.

In this tutorial you will learn:

  • Where to download a live Linux ISO for recovery
  • How to boot into live / recovery mode
  • How to install testdisk
  • How to recover a deleted partition table
How to recover partition table in Linux
How to recover partition table in Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software testdisk
Other 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.

  1. 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
  2. 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, the commands would be:
    $ sudo add-apt-repository universe
    $ sudo apt install testdisk
    
  3. Once installation is complete, launch testdisk with the following command.
    $ sudo testdisk
    
  4. Select the No Log option and proceed.

    Select No Log option on testdisk prompt
    Select No Log option on testdisk prompt



  5. Highlight the disk that has the deleted partition you need to recover, and select Proceed when ready.
    Select the disk that contained the deleted partition you want to recover
    Select the disk that contained the deleted partition you want to recover
  6. 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)
  7. Proceed with the Analyse option to search for partition tables.
    Use the Analyse option
    Use the Analyse option
  8. Choose the Quick search option to locate partition tables.

    Choose Quick search option
    Choose Quick search option



  9. 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
  10. If the partition table looks correct to you, choose the Write option to recover it.
    Write changes to recover the partition table
    Write changes to recover the partition table
  11. Testdisk will ask once again if you want to confirm these changes. Answer Y to proceed.
  12. When done, quit out of the testdisk menu.
    Quit testdisk
    Quit testdisk
  13. 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.



Comments and Discussions
Linux Forum