GRUB: Instalasi

From OnnoWiki
Revision as of 05:09, 6 February 2011 by Onnowpurbo (talk | contribs) (New page: 3.1 Installing GRUB using grub-install Caution: This procedure is definitely less safe, because there are several ways in which your computer can become unbootable. For example, most oper...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

3.1 Installing GRUB using grub-install

Caution: This procedure is definitely less safe, because there are several ways in which your computer can become 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. Therefore, GRUB provides you with a map file called the device map, which you must fix if it is wrong. See Device map, for more details.

On BIOS platforms GRUB has to use a so-called embedding zone. On msdos partition tables, this is the space between the MBR and the first partition (called the MBR gap or the boot track), while on GPT partition tables it uses a BIOS Boot Partition (a partition with GUID 21686148-6449-6e6f-744e656564454649). If you use GRUB on a BIOS system, make sure that the embedding zone is at least 31 KiB (512KiB or more recommended).

If you still 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 simple. You only need to specify one argument to the program, namely, where to install the boot loader. The argument can be either a device file (like ‘/dev/hda’) or a partition specified in GRUB's notation. For example, under Linux the following will install GRUB into the MBR of the first IDE disk:

    # grub-install /dev/hda

Likewise, under GNU/Hurd, this has the same effect:

    # grub-install /dev/hd0

But all the above examples assume that GRUB should use 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 when 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 quite careful. If the output is wrong, it is unlikely that your computer will be able to boot with no problem.

Some BIOSes have a bug of exposing the first partition of a USB drive as a floppy instead of exposing the USB drive as a hard disk (they call it “USB-FDD” boot). In such cases, you need to install like this:

    # losetup /dev/loop0 /dev/sdb1
    # mount /dev/loop0 /mnt/usb
    # grub-install --boot-directory=/mnt/usb/bugbios --force --allow-floppy /dev/loop0

This install doesn't conflict with standard install as long as they are in separate directories.

Note that grub-install is actually just a shell script and the real task is done by grub-mkimage and grub-setup. Therefore, you may run those commands 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.