Black God

How to chroot Ubuntu using Live CD to fix GRUB rescue prompt

Recently I messed up GRUB boot loader in my laptop installed with Ubuntu which resulted in grub rescue prompt. So I had to boot Ubuntu Live CD to get it fixed. Thought of blogging it, may be useful for some one.

This fix involves two steps. First one is to chroot into Ubuntu installation partition. Second one is to install the grub MBR (Master Boot Record). I am using Ubuntu Lucid 10.04 and Live CD also of same.

Step-1: Boot your machine with Ubuntu Live CD and select Trying Ubuntu without installation option when it is prompted (Live CD mode)

Step-2: Be patient till you get complete desktop ready.

Step-3: Ubuntu main menu -> Places -> Home Folder -> Look for other partitions listed on left hand side pane. Mount one by one and identify your Ubuntu root partition. When you are in your root partition, press Ctrl+L to view the complete mount path. Press Ctrl+C to copy this path. This path is normally /media/xx..xx kind of long path, where xx..xx denotes your hard disk partition unique id.

If you know your Ubuntu root partition you can replace the above GUI step-3 with simple mount command like this (Applications -> Accessories -> Terminal):

$ sudo mount /dev/sdax /mnt/myroot (where sdax is your root partition)

Let’s say you have mounted root partition at /media/xx..xx.

Step-4: $ Run the terminal through Applications -> Accessories -> Terminal.

Step-5: Run the following commands to export the pesudo file system of Live CD to your would be root file system soon.

$ sudo mount ‐‐bind /dev /media/xx..xx/dev

$ sudo mount ‐‐bind /proc /media/xx..xx/proc

$ sudo mount ‐‐bind /sys /media/xx..xx/sys

Step-6: Changing the root file system of live system to your hard disk installed root file system.

$ sudo chroot /media/xx..xx

Step-7: Installing GRUB Boot record in Master Boot record of your hard disk. My hard disk is sda. Replace your hard disk device node in the following command.

$ sudo grub-install /dev/sda

Step-8: Reboot the Live Ubuntu. Eject the CD.

Now you should get boot menu for your Ubuntu installation back. Enjoy the Ubuntu!

Note: How to get it done without Live CD which includes GRUB2 rescue prompt

71 comments for “How to chroot Ubuntu using Live CD to fix GRUB rescue prompt

  1. Pingback: dla cukrzyka
  2. gonzalo
    July 30, 2013 at 9:09 am

    Thanks a lot!!! save my day :)

  3. vimes
    May 26, 2013 at 1:34 am

    You saved my day. Thanks a lot!

  4. YannisK
    April 25, 2013 at 11:46 pm

    Thank you my good man! It worked with 12.04 using 10.10 live, after new, additional windows partition (XP)
    Keep on sharing. It’s life :-)

  5. Ryan
    April 16, 2013 at 12:21 am

    Man, this is perfect. Worked on a dual boot Fedora 18 / MS Vista installation. Thanks very much.

  6. Pingback: chroot command
  7. george
    November 15, 2012 at 12:55 pm

    it works great..but it would be great if you can change that /media/xx.xx to /mnt/xx.xx because you specified /mnt as the root filesystem mount point. thanks again.

  8. Pingback: dual boot failure
  9. Vegard
    August 16, 2012 at 1:54 am

    You just saved my computer. Thank you!!

  10. Harris
    June 17, 2012 at 6:51 am

    ty ty

  11. Ashish
    June 10, 2012 at 12:58 am

    Thanks man ..you saved my night ..

  12. KeithS
    May 19, 2012 at 8:55 am

    And I am finally away from someone’s post with a better understanding of the utilization of chroot. You’re an ACE dude, Black God! Huge thank you!!!

    Just, please, could you add a small “further info” footnote expanding just a little on why /dev, /sys and /proc need to be mounted –bind?

  13. jhvanderven
    May 3, 2012 at 1:06 am

    Thanks!

  14. April 29, 2012 at 5:59 pm

    thanks! worked like a charm using the 9.10 live cd as well. you da man!
    - peace

  15. mark
    April 8, 2012 at 9:03 am

    thanks so much, works perfectly

Leave a Reply

Your email address will not be published. Required fields are marked *