Thursday, November 12, 2009

[ Tutorial ] Reinstall Grub 1 and Grub 2 on Ubuntu

Windows bootloader will overwriten Linux GRUB bootloader if we reinstall windows on a computer with dual boot OS.Now follow this tutorial to restore GRUB1 and GRUB2

GRUB1
boot with livecd or liveusb
open terminal
follow this step

sudo grub
grub>find /boot/grub/stage1
grub>root (hdx,y)
grub>setup (hdx)
quit

*note x and y is the output of grub find /boot/grub/stage1.The output may different on different machine

GRUB2
boot with ubuntu 9.10 livecd/liveusb(the current version of ubuntu that using the newest grub2 version is ubuntu 9.10 when i am writing this article).
open terminal
write the following line on the terminal
$sudo -i
#mount /dev/sdax /mnt
#grub-install --root-directory=/mnt/ /dev/sda
#exit

note:x is your root linux partition

GRUB2 didn't recognize another OS automatically so we have to do that manually.It's not that hard just type the following command in terminal

$sudo update-grub

This will reconfigure the list of title and detect another OS like Windows.