How to recover a Lost Partition
A few days ago a friend of mine had some trouble booting Windows. He wasn't even able to mount that partition in linux and so didn't have any way to recover the data. This made me look for different data recovery methods available in Linux. And I finally came up with this article.
There are different methods of data recovery, and the right one for you depends upon the kind of problem you have. Sometimes you may have just lost a partition while partitioning and want to recover it and sometimes you may want to recover a deleted file. In this particular article, I will tell you about different methods of recovering a lost partition.
Many a times we make some mistake while partitioning and after that a partition no longer appears in the new partition table. Such cases are known as the lost partition problems. If you haven't written any data after that on the disk then it is a fair chance that you will be able to recover that partition. Following are a couple of methods to do that.
Using GNU parted
GNU parted is a partition manipulation program i.e. it is used to create, resize or delete partitions. We can use it to recover our lost partition. Follow these steps to recover your partition.
Step 1
Before starting the recovery please note that since the partition table of the hard disk is going to be modified none of the partitions should be mounted including the swap spaces. This can be easily done by using a liveCD. But the liveCD should have GNU parted installed (like Ubuntu LiveCD). In order to unmount the swap spaces, you can run this command in the terminal (as root)
[shredder12]$ swapoff -a
Step 2
Now, run parted as root and mention the device(containing the lost partition). If the hard disk is /dev/sda from which you want to recover then run this command
[shredder12]$ parted /dev/sda
Step 3
You will see a command prompt now enter this command there
(parted) rescue START END
where, START and END are the locations on the disk. They can be mentioned as GB/MB, percentage of the disk e.g 10% and even sectors. For more info on the units of START and END use the help command in the (parted) prompt.
Using Gpart
Gpart, Guess PC disk partition table is a tool to find lost partitions. After installing it run the following command (as root).
[shredder12]$ gpart /dev/sda
where /dev/sda is the hard disk containing the lost partition. The result will be a guest partitioned table. After examining it very carefully and running it 2-3 times to confirm the partitions distribution you can write the guessed partition table to the device(as root).
[shredder12]$ gpart -W /dev/sda /dev/sda
So, whenever you face the problem of a lost partition don't panic just make sure that you don't write anything on the disk after that and use any of the above methods to recover the partition.



























2 Comments
Well, when it comes to data recovery I need all the help I can get. I know there are softwares and specific methods for hard drive recovery but that only makes it harder for users to orientate. Thanks for this informative post and I hope I'll never need it.
I wish you shared a solution not just for Linxus but for other operating systems as well, this article would have a huge popularity. Most of the computer users had this problem at least once in their lives. Kall
Post new comment