Usually grub gets automatically installed for you, does what it is supposed to do, and requires no attention. The rest of this guide covers the cases when things go wrong.
There are millions of grub tutorials and articles on the web. There is no decent
official documentation for grub, which is a shame. There is of course the texinfo
stuff, but I don't know anyone who knows how to navigate through texinfo pages.
Some pretty good articles are:
Sometimes you may need to edit the file /boot/grub/grub.conf. On some systems /etc/grub.conf is a handy symbolic link to this file, but I am not sure this is a good habit to be lured into. Note that you can just edit this file and then reboot to have changes take effect, no need to reinstall grub.
The grub-install utility is the handiest way to reinstall grub. The one time I have needed to (and had success doing so) was when I was doing a dual boot install and the windows install overwrote GRUB, allowing me to boot windows, but not linux. The fix in this case went like this:
grubThis gives you a grub shell with lots of commands. Grub lives in its own world, which is just a little peculiar. Hard drives all get designations like (hd0) (which would be used to specify the MBR of the first drive for example). Hard drive partitions get designations like (hd0,0) (which would be used to specify sda1, often a /boot partition).
Note that sda is known to grub as hd0, sdb is known to grub as hd1. I have seen cases where the BIOS drive error (hd0, hd1) differes from the linux logical order (sda, sdb), so keep on you toes. Also note that the linux partition numbers begin with "1" (sda1, sda2) whereas the grub partition numbers begin with "0" (hd0,0), (hd0,1).
A recommended set of commands to put grub onto the MBR of a system with an sda1 /boot partition might be:
grub find /boot/grub/stage1 (if you have no /boot) find /grub/stage1 (if you have a /boot) root (hd0,0) setup (hd0) quitNote that when I actually tried this, it did not do all that I had hoped it would. Running grub-install did what I wanted. After doing setup, when I tried to boot the machine it would launch grub which would present me with a prompt! Then it was necessary to use the configfile command to grub to actually boot the system. Someday perhaps I will understand this.
fdisk -lThis isn't actually a grub trick, but very often you need this information when working with grub, so I present it here.
Grub has a builtin cat command, use it like:
cat (hd0,1)/etc/fstab
If your system boots, and then presents you with a grub prompt, try this:
configfile /grub/grub.confIt worked for me. For some reason grub in this case could not find the grub menu all by itself. The fix was to boot from an install CD (or use the trick above and then use the system to patch itself) and then:
chroot /mnt/sysimage grub-install /dev/sda
-- boot the Fedora 11 install/rescue DVD into rescue mode. chroot /mnt/sysimage grub-install /dev/sdaAfter this, the system booted!
There is more to the story than just this though. I had set up a /boot partition, but it was just being ignored and /boot was just a directory in root. I had just one drive with /dev/sda1 being /boot and /dev/sda3 being /. The initial install worked just fine without /boot. So I moved all the stuff from /boot on /dev/sda3 onto the /boot (which I mounted on some oddball mountpoint for the purpose). Then I edited /etc/fstab to mount /dev/sda1 on /boot (after moving the old /boot directory elsewhere. This still halted at the GRUB word (so the /boot partition may have been a red herring), but after doing the above grub-install, everything worked just fine.
Good Luck!
Adventures in Computing / [email protected]