Wednesday, October 12, 2011

Recovery of a deleted partition ( Part - 3 )

         As I have written in my last post ( http://meandmyubuntulinux.blogspot.com/2011/10/recovery-of-deleted-partition-part-2.html ) that the Ubuntu Live disk was able to detect all of my partitions and all my data but still I was unable to boot into the system.

        So, I tried to re-install the Ubuntu Grub Loader and see if that works . So, as per the post on ubuntu forum ( http://ubuntuforums.org/showthread.php?t=1581099 ) , I proceeded as follows :

1) Boot into the Live USB disk.
  
3) Created a directory for mounting my Ubuntu partition :
                 sudo mkdir /mnt/temp
3) Mount the Ubuntu Installation :
              sudo mount /dev/sda9 /mnt/temp

4) Mount miscellaneous filesystem for proper working of chroot command :
      for i in /dev /dev/pts /proc /sys; do sudo mount -B $i /mnt/temp$i; done

5) chroot into the Ubuntu installation :
                        sudo chroot /mnt/temp
If the above commands run successfully, the terminal prompt should include "root" ( root@ubuntu:/# ), which indicates you are in the chroot environment.

6) Confirm that I have an working internet connection in the chroot environment : 
                                apt-get update
As I was having a working internet connection , I moved forward to the next step.

7) Purging the Grub Loader : Do not proceed to following command if you don't have a working internet connection. The next command will remove grub, grub-pc (Grub 2) and grub-common. ( If you are sure you have never had Grub legacy on the current installation you may omit "grub" from the next command else keeping that in the command does no harm. ). Here is what you will do when you enter the command :

         a) Press ENTER to continue.

         b)Read the warning during the install about removing the bootloader. TAB to highlight "<Yes>" and press ENTER.

Command :

                            apt-get purge grub grub-pc grub-common

8) Re-install the grub packages : Here is what will happen:
         a) You will be given the opportunity to add extra kernel options to the kernel line. If you don't know, you probably don't need them ; TAB to highlight "<OK>" and press ENTER.

         b) Read the installation notes. TAB to "<OK>" to continue.
         
         c) When presented with the device option, use the UP/DN keys to select the correct drive ( /dev/sdX ).
    • Make sure the installation drive [*] /dev/sdX has an asterisk next to it ( example: [*] /dev/sda ). If it doesn't, highlight it and press the SPACE bar to select it.
    • Do not select a partition ( example: [ ] /dev/sda5 , etc). 
       d) TAB to "<OK>" and press ENTER. When it has finishing the installation, you should have Grub 2 installed.
Command :
                       apt-get install grub-common grub-pc
  This is the point where I got stuck again, as it refuesd to install the Grub Loader onto my Hard Disk ( /dev/sda ).

:-(

       When this problem persisted no matter what I do to resolve it, I finally figured out that the Mini iso image which I was trying to write on the Pen-drive using the dd command ( Refer to my post : http://meandmyubuntulinux.blogspot.com/2011/10/recovery-of-deleted-partition.html ) was almost 25 MB in size so it must have over written the Master Boot Record , the partition table as well as some other important Windows files ( remember that I had Windows Xp installed in my 1st Partition ) and hence corrupting the Windows installation.
          So, I decided to format that partition and do a fresh re-install of the Ubuntu Grub Loader. I back-up everything that was important for me from the Xp partition via the USB live disk and formatted the /dev/sda1 partition using GParted Partition Editor . Next I repeated the above steps from 1 to 8. This time it successfully installed the Grub Loader without a hitch. So I could proceed further.

Step 9:- Update the Grub Loader files
                         update-grub

Step 10:- Exit the chroot environment
                      exit
If you have successfully exited chroot, the terminal prompt should return to the Ubuntu Live CD prompt ( ubuntu@ubuntu:~$ )

Step 11:- Unmout whatever you previously mounted :
                           sudo umount /mnt/temp
           for i in /dev/pts /dev /proc /sys; do sudo umount /mnt/temp$i ; done

                 When I finally re-booted the system. I was able to boot into my only left Operating System i.e. my loving Ubuntu. Windows is gone ( as such also I was rarely using it and was thinking to remove it and put it into the Virtual-Box.). It was a very tiring but learning experience to do all this. I actually never imagined that I could bring back my system into this working condition and that too without loosing a single important file . But I did it !!! All thanks to the Ubuntu forum ( http://ubuntuforums.org ). One very important thing that I learned is cross-check each command twice before firing it especially when you are in root privilage else you may land into a series of problem that you never imagined and may be never able to recover from the damage that it inflict.

Have a Good Day and a happy Ubuntu experience.....

No comments:

Post a Comment