Monday, January 9, 2012

Recover or Rescue Grub from live Ubuntu CD

In Last Post We Have Discussed About Restoring Windows From Grub.This Post Explains A Method Of Restoring Linux Installations Like Ubuntu Using Linux Live Desktop Cd Or a Server Cd.

Steps To Be Followed.

1.Boot From The Ubuntu Or Any Linux Variant Live Cd.
2.Open Terminal .

Applications> Accessories> Terminal.
3. In Terminal type sudo fdisk -l   . 
    It will display all the Available partition on the disk.


Identify the partition which have Linux under System column is your drive in which ubuntu linux is installed. 


4. Mount the ubuntu partition drive
       sudo mount /dev/sdXX /mnt  (example 'sudo mount /dev/sda11 /mnt' ,Here XX Stands For Your Drive.)


5.Only if you have a separate boot partition: 
            sudo mount /dev/sdYY /mnt/boot.


 6.  Mount the virtual file systems: 
            
            sudo mount --bind /dev /mnt/dev
        sudo mount --bind /proc /mnt/proc 
        sudo mount --bind /sys /mnt/sys


7. To ensure that only the grub utilities from the LiveCD get executed, mount /usr     
     sudo mount --bind /usr/ /mnt/usr 
     sudo chroot /mnt  


8. If there is no /boot/grub/grub.cfg or it's not correct, create one using 
            update-grub 
      or  update-grub2


9.Now reinstall Grub  
         grub-install /dev/sda     


 10. Verify the install 
        sudo grub-install --recheck /dev/sdX


11. Exit chroot : CTRL-D on keyboard.


12. Unmount virtual filesystems:  
           sudo umount /mnt/dev 
           sudo umount /mnt/proc
           sudo umount /mnt/sys 


If you mounted a separate /boot partition:  
           sudo umount /mnt/boot 


13. Unmount the LiveCD's /usr directory: 
          sudo umount /mnt/usr


14. Unmount last device: 
           sudo umount /mnt
15. Reboot. 
         sudo reboot.


NOTE: If you are getting /usr/sbin/grub-probe: error: cannot stat 'aufs'  error then the possible reason is that you didn't follow the commands listed above. Specifically you did not do chroot.


Credits:Sidh.

No comments:

Post a Comment