Страници: [1]
Изпечатай
Автор Тема: Ubuntu how to re-install grub using chroot  (Прочетена 835 пъти)
ron
Administrator
Newbie
*****

Карма: 0
Публикации: 13


Профил Ел. поща
« -: July 21, 2009, 11:27:09 pm »

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

Код:
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
Активен
Страници: [1]
Изпечатай
Отиди на: