Article:Ubuntu how to re-install grub using chroot

(Redirected from Article:Ubuntu reinstall grub problem)

When making multi-boot systems or re-organizing your disks you may be unlucky to find your grub install is either partially or completely removed.

The simplest way to fix this is to boot a livecd but what should you do once the live cd is loaded, especially if you enter grub-install or grub and then find /boot/grub/stage1 and all you get is

Fatal: Error 15

The following are a few quick steps to fix grub using chroot

First make your life easier by getting into a full root session

ubuntu@ubuntu:~$ sudo su

now mount your ubuntu install. Use fdisk -l /dev/hda or fdisk -l /dev/sda to see your partition table. My partition was on /dev/hda5

root@ubuntu:/home/ubuntu# mount /dev/hda5 /mnt

Next bind your real devices so that the grub command can work

root@ubuntu:/home/ubuntu# mount -o bind /dev /mnt/dev
root@ubuntu:/home/ubuntu# mount -o bind /proc /mnt/proc

Enter the chroot session

root@ubuntu:/home/ubuntu# chroot /mnt
root@ubuntu:/# grub
grub> find /boot/grub/stage1
find /boot/grub/stage1
 (hd0,1)
 (hd0,4)

My root disk was installed on partition 5 so now set that as root

grub> root (hd0,4)
root (hd0,4)

install grub

grub> setup (hd0)
setup (hd0)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd0)"...  16 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,4)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded
Done.

Now quit and restart your machine

grub> quit
exit
reboot
MediaWiki

This page has been accessed 9,922 times.

This page was last modified 23:48, 11 June 2010.