Sunday 7 April 2013

How to recover Grub in Ubuntu using Rescue commands

                  How to recover Grub in Ubuntu
If Grub is missing after installing Ubuntu and screen is showing Grub Rescue, then Ubuntu grub rescue or restore has to done. It can be done through Ubuntu Server CD or Ubuntu Desktop CD. 
If at system start up you might be seeing the option Grub Rescue or Grub missing option then you need to follow the below commands.

For Ubuntu grub rescue follow these steps:
1.Boot from the Ubuntu Desktop live CD. 



                      
Select Try Ubuntu.     

2.In Live Desktop session open terminal. 

  Application ->Accessories->Terminal. Or Dash home Type terminal

3. In Terminal tpye sudo fdisk -l  

    It will display all partiton of the disk.
                 
The partation which have Linux under System column is your drive in which ubuntu linux is installed. In screenshot ubuntu partition drive is /dev/sda1.

4. Mount the ubuntu partition drive
       sudo mount /dev/sdXX /mnt  (example 'sudo mount /dev/sda1 /mnt' ,don't miss the spaces.)

5.Only if you have a separate boot partition:
            sudo mount /dev/sdYY /mnt/boot.
 6.  Mount the virtual filesystems:
            
            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/sdX  (e.g. grub-install /dev/sda. Do not specify the partition number).   
 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.

No comments:

Post a Comment