Wednesday, March 20, 2013

Restoring lost partitions using Ubuntu live CD



FAQ: How do I restore my lost partition table? I accidentally deleted my partition table, how do I recover my data? How to recover deleted partitions and data in them? Recover data from deleted drives.
WARNING: If you’ve formatted and/or added new data to the drive, or carried on with an OS installation, chances of recovery are very less.
Most people end up deleting their partition table while they try to install a new OS for the first time, I personally know a couple of them who ended up deleting their partition table while they tried to install Linux for the first time, (more on that later), Now what I am going to introduce to you a tiny tool called “gpart”which will help you restore your deleted partition table.
Things you’ll need.


  1. An Ubuntu or similar, live CD (actually any Linux live CD / USB will do, but I am demonstrating here using Ubuntu 9.04 (Jaunty Jackalope)
  2. A working internet connection or this file (35.8 KiB)
  3. Patience!
Here is the step by step procedure for restoring your lost partition table, and hence your lost data
  1. Boot using your live cd, I am using Ubuntu 9.04, Jackalope here.
  2. You will need this file (35.8 KiB), or if you’re using another version of Ubuntu or a different Linux distro, the name of the package you need is gpart.
  3. You can install these packages using apt-get as well, from the terminal, if you have a working internet connection, here is the procedure for that
  • Open the repository file by typing the following at the terminal :
  • sudo gedit /etc/apt/sources.list
  • Add the following line to it :
  • deb http://archive.ubuntu.com/ubuntu gutsy main restricted universe
  • Install gpart by typing the following commands in the terminal :
  • sudo apt-get update
  • sudo apt-get install gpart
  1. Once you’ve downloaded and installed it, (it’s a binary file, just double click and go)
  2. Open up terminal from the applications menu at the top
  3. And type in the following command to detect the lost partitions : sudo gpart /dev/sda [This might take some time]
  4. This command assume that the drive is detected as /dev/sda if this is the only drive you’ve got, 99% chances are that it will be detected like this, otherwise change the /dev/sda parameter accordingly.
  5. This command will output the detected partitions that might have been lost due to some reasons, if they’re correct, and then this partition table needs to be written to the disk, use the following command for it.
  6. sudo gpart /dev/sda -W /dev/sda
After the partition table has been successfully written [after considerable time], you will be asked to restart the computer, if everything goes well, you will be presented with your lost partition table and data on the next restart!
Now, if you’re using terminal for everything, here is a short-cut.
  • ubuntu@ubuntu:~$ sudo gedit /etc/apt/sources.list[You will have to add the following line to the end of the file that is opened: deb http://archive.ubuntu.com/ubuntu gutsy main restricted universe, save and close this file.]
  • ubuntu@ubuntu:~$ sudo apt-get update
  • ubuntu@ubuntu:~$ sudo apt-get install gpart
  • ubuntu@ubuntu:~$ sudo gpart /dev/sda
    [you will have to verify if the detected partition data is correct before proceeding, this command is supposed to take some time]
  • ubuntu@ubuntu:~$ sudo gpart /dev/sda -W sudo gpart /dev/sda
    [Restart if this command is completed successfully, This command may take considerable time
This post was originally published at tuespeaks.co.cc by phoenix@tuespeaks.co.cc

No comments:

Post a Comment