Jan 2, 2008

Ubuntu: GRUB Repair!

I had a problem after reinstalling my windows on my dual boot laptop. I have windows XP and Ubuntu Gutsy. As usual i prefer using GRUB as bootloader, but the consequences is you will fail to load GRUB after formatting your Windows Operating System. As usual people still will rely on windows on some work to do because windows is still a dominan operating system nowadays.

But there is solution to repair GRUB after formatting your Windows. There is a native way and also simple way to repair those problem about GRUB. The first method is by using the native way of repairing GRUB. I would recommend this method method to people who know how to use terminal very well to do this method. Otherwise please use the second method cause it's easier.

First Method:

Booting from any linux distro live CD and open the terminal.
  1. Open terminal by going to Application>Accessories>Terminal
  2. As usual you need to gain root access. Via live CD we know that we can do SUDO to gain temporarily access to root but we have a lot of command need root access so i prefer you change the root password so that we can use SU command to gain permenent root access. To change root password type SUDO passwd root. then set your root password. (Remember, this do not change your root password in your existing linux distro)
  3. Then we began to the repairing part. First use su command to gain root access. Then make a new directory by typing mkdir repair/ im using directory name .
  4. Next is we have to mount the default linux partition to your new directory by using mount /dev/hda7 /repair. (hda7 is the partiton which you have your linux distro installed)
  5. After that, we need to mount dev directory into /repair/dev by commiting this command. mount -o bind /dev /repair/dev
  6. After you finish doing all the above command successfully, then we may proceed by chrooting to the directory.
  7. Type chroot /repair
  8. Then type grub-install dev/hda to install a new GRUB bootloader.
  9. Then restart by typing shutdown -r now
Second Method:

You need to boot from any Linux Distribution Live CD, then run the terminal.
  1. Open terminal by going to Application>Accessories>Terminal.
  2. Then type SUDO grub in the terminal to access the GRUB.
  3. In the GRUB, type find /boot/grub/stage1
  4. You will have output like (hd0,6). hd0 is your hardisk of your linux, and 6 is the index number of your linux partition.
  5. Then type root (hd0,6) by assuming your output for step 3 is (hd0,6).
  6. Then type setup (hd0) and look at the output. If any problem occur then you need to check the step and the output for STEP 3.
  7. If there isnt any problem occur then we may proceed to the final step. Restart your laptop by typing shutdown -r now command.

If there is anything goes wrong then you should have your Grub back to normal when you restart your pc/laptop. But if there is anything wrong, and the GRUB cant load, i will encourage you to post it at http://forums.ubuntu.com.my. Have a nice day!

Thank you for your unbelievable support on Negative Zero - Permission to read and write blog for nearly 4 years. Don't forget to like Negative Zero on Facebook.
Blogirific.com Blog Directory

Post(s) you might like to read :

1 comment:

  1. Regarding 1st method, step 2: Just use "sudo su -", no need to set a password.