Node:Installing GRUB using grub-install, Previous:Installing GRUB natively, Up:Installation
Caution: This procedure is definitely deprecated, because there are several posibilities that your computer can be unbootable. For example, most operating systems don't tell GRUB how to map BIOS drives to OS devices correctly, GRUB merely guesses the mapping. This will succeed in most cases, but not always. So GRUB provides you with a user-defined map file called device map, which you must fix, if it is wrong. See Device map, for more details.
Unfortunately, if you do want to install GRUB under a UNIX-like OS (such
as GNU), invoke the program
grub-install (see Invoking grub-install) as the superuser (root).
The usage is basically very easy. You only need to specify one argument
to the program, namely, where to install GRUB. The argument can be
either of a device file or a GRUB's drive/partition. So, this will
install GRUB into the MBR of the first IDE disk under Linux:
# grub-install /dev/hda
Likewise, under GNU/Hurd, this has the same effect:
# grub-install /dev/hd0
If it is the first BIOS drive, this is the same as well:
# grub-install '(hd0)'
But all the above examples assume that you use GRUB images under
the root directory. If you want GRUB to use images under a directory
other than the root directory, you need to specify the option
--root-directory. The typical usage is that you create a GRUB
boot floppy with a filesystem. Here is an example:
# mke2fs /dev/fd0 # mount -t ext2 /dev/fd0 /mnt # grub-install --root-directory=/mnt '(fd0)' # umount /mnt
Another example is in case that you have a separate boot partition
which is mounted at
/boot. Since GRUB is a boot loader, it
doesn't know anything about mountpoints at all. Thus, you need to run
grub-install like this:
# grub-install --root-directory=/boot /dev/hda
By the way, as noted above, it is quite difficult to guess BIOS drives
correctly under a UNIX-like OS. Thus,
grub-install will prompt
you to check if it could really guess the correct mappings, after the
installation. The format is defined in Device map. Please be
careful enough. If the output is wrong, it is unlikely that your
computer can boot with no problem.
grub-install is actually just a shell script and the
real task is done by the grub shell
grub (see Invoking the grub shell). Therefore, you may run
grub directly to install
GRUB, without using
grub-install. Don't do that, however,
unless you are very familiar with the internals of GRUB. Installing a
boot loader on a running OS may be extremely dangerous.