To FUBAR and back again!

by subacati

How to recover your lost partition table!

If you use gparted from time to time you will, sooner or later, accidently erase the partition table on your primary hard drive! :left:.

A simple task.

It all started when a colleague asked me to copy a movie on to a usb flash drive for him. He wanted to see if his new blu-ray player would play dvd's from the usb socket. :left:. I didn't have any blank flash drives, so I decided to format one that I didn't need any more. Unfortunately, I forgot to concentrate and erased the partition table on /dev/sda instead of /dev/sdb :doh:.

The result was an unbootable netbook and the possible loss of all my data! :insane:.

Well, I knew that all the data was still there, I just couldn't access it! :awww:. Since I didn't have any current backups, I'd only just got my backup drive back from a colleague I'd lent it to, I had to try the hard way to recover from this FUBAR!

The first task was to backup the drive so that if I made things worse, I could at least return to the condition I started with. :knight:. I booted with System Rescue CD and mounted the backup drive like this;

mkdir /mnt/backup
mount /dev/sdb2 /mnt/backup

Then I used dd to make a drive image of the hard drive. (make sure you have enough free space in your destination drive);

dd if=/dev/sda of=/mnt/backup/drive.img

That took several hours on my 500GB hard drive! :faint:. Be patient because dd does not give any progress report until it's finished! :up:.

The next step is easier and quicker. I simply typed, 'testdisk' on the command line. I followed the menus and recovered the partition table as far as possible. Unfortunately, This process wipes out grub. :awww:.

Now I know there is a way to chroot into the directory, but I couldn't get that to work so my next step was to boot up with my Ubuntu install disk. I selected install and then proceeded with installing 'side by side' with existing systems. This process installs grub, thus making my machine bootable again! :hat:.

So now my system is restored with no data lost! :yes:.

Advertisements