(This how to is written for Ubuntu but should work on other systems. The only thing to take note of, when you see "sudo" that will mean to you that the following command should be entered at a root terminal.)
Boot into the live Ubuntu cd. This can be the live installer cd or the older live session Ubuntu cds.
When you get to the desktop open a terminal and enter. (I am going to give you the commands and then I will explain them later)
Code:
sudo grub
Code:
find /boot/grub/stage1
Next, THIS IS IMPORTANT, whatever was returned for the find command use it in the next line (you are still at grub>. when you enter the next 3 commands)
Code:
root (hd?,?)
Next enter the command to install grub to the mbr
Code:
setup (hd0)
Code:
quit
When you reboot, you will have the grub menu at startup.
Now the explanation.
Sudo grub gets you the grub shell.
Find /boot/grub/stage1 has grub locate the file stage1. What this does is tell us where grub's files are. Only a small part of grub is located on the mbr, the rest of grub is in your boot folder. Grub needs those files to run the setup. So you find the files and then you tell grub where to locate the files it will need for setup.
So root (hd?,?) tells grub it's files are on that partition.
Finally setup (hd0) tells grub to setup on hd0. When you give grub the parameter hd0 with no following value for a partition, grub will use the mbr. hd0 is the grub label for the first drive's mbr.
Quit will exit you from the grub shell.
==============================
Way 2:
When the busted system is in a single ext3 root partition (say, /dev/sda5)...
mkdir /mnt/tempWhen the busted system has separate ext3 boot and root partitions (say, /dev/sda5 and /dev/sda6)...
mount /dev/sda5 /mnt/temp
grub-install --root-directory=/mnt/temp /dev/sda
mkdir -p /mnt/temp/bootWhen the busted system has a separate ext3 boot partition (say, /dev/sda5), and the root partition is a logical volume (say, /dev/VolGroup00/LogVol00 according to lvdisplay)...
mount /dev/sda6 /mnt/temp
mount /dev/sda5 /mnt/temp/boot
grub-install --root-directory=/mnt/temp /dev/sda
mkdir -p /mnt/temp/bootIf grub-install fails with a read error or the boot loader still doesn't work, always try the GRUB shell (and vice versa). They both accomplish the same thing, but different things occur in the background. It's not necessary to mount partitions when using the GRUB shell commands in the LiveCD. Change x & y in the example to the busted system's boot partition...
vgchange -a y
lvdisplay
mount /dev/VolGroup00/LogVol00 /mnt/temp
mount /dev/sda5 /mnt/temp/boot
grub-install --root-directory=/mnt/temp /dev/sda
/sbin/grub
grub> root (hdx,y)
grub> setup (hd0)
grub>quit
Restart & all are done.
No comments:
Post a Comment