How to Recover a Disk Partition with TestDisk and GParted Live

A friend recently asked me to perform a system recovery on her VAIO laptop. The hard disk was split between a C drive for the OS, and a D drive with 200GB of data. I'm a Linux user, so I was like, come on, at least give me a challenge! Have you heard people saying, be careful what you wish for? Well, 30 seconds into the recovery procedure, I got an Error 333 and a restart button. Both partitions had been deleted.

The good news was that before I started the system recovery procedure, I asked her to backup the most important data, but that was just 5GB out of 200GB—the rest was gone. That's a lot of lost data! Thankfully, I was able to use a cool program called TestDisk to fully recover everything.

In this tutorial, I will show you how to create a bootable GParted Live USB drive, and use TestDisk to recover your partitions. Note that if you are still able to boot normally to your system, and just want to recover your files without creating a bootable disk, you might also want to have a look at Recover Deleted Files Using the Free Open Source Tool PhotoRec.

Create a GParted Live USB drive

Start by downloading the GParted Live ISO. Choose the latest stable release for your computer architecture (if you are not sure choose i686). There are multiple methods you can use to create a bootable USB drive from the ISO file—I prefer UNetbootin.

Windows

If you are on Windows, just download UNetbootin.

Linux

If you are on Ubuntu, ensure you have the latest version by adding the Ubuntu PPA repository for UNetbootin and install it.

$ sudo add-apt-repository ppa:gezakovacs/ppa
$ sudo apt-get update
$ sudo apt-get install unetbootin

For other distributions, you can find binaries and sources at the official UNetbootin page.

Create bootable USB

After installing, plug-in an empty USB drive and run UNetbootin. Select the GParted ISO you have just downloaded and the drive you wish to use for GParted Live, and then click OK.

UNetbootin

Boot into the GParted Live USB

Restart your computer and boot from the USB drive you have created. While GParted is booting it will ask you some questions, e.g. keyboard layout, don't try to be a hero, just accept the defaults by pressing Enter. When the window manager loads, the first open window is the GParted Partition Editor.

GParted

Select your disk drive using the drop-down menu on the top-right. I have selected /dev/sdc, which as you can see doesn't have any valid partitions on it, since I accidentally deleted them for this tutorial.

Open the terminal window, by double clicking on the terminal icon on the desktop, and run TestDisk as root:

$ sudo -s
$ testdisk

Follow the steps below:

  1. Select No Log.

  2. Select the disk drive you want to recover, e.g. /dev/sdc.

  3. Select your partition table type. Usually it's Intel.

  4. Select Analyse and Quick Search.

  5. If you get asked whether your partition was created under Vista, answer yes/no.

  6. Your drive will be analysed and you will see a list of all found partitions. If you know what you are doing, you can edit the list, otherwise just press Enter.

  7. On the next screen you have the option to either perform a second Deeper Search, or Write the current partition table to disk. If the quick search was successful, choose Write.

Quit TestDisk, and rescan your devices in the GParted Partition Editor by clicking GPartedRefresh Devices. Select your device from the top-right drop-down menu.

GParted

If your deleted partitions were successfully recovered, as in the above screenshot, you can reboot your computer by double clicking on the Exit button.

You can learn more about TestDisk by looking at the official documentation.