LinuxSelfhelp.com

Go to the first, previous, next, last section, table of contents.


Booting

For Multiboot-compliant kernels, GRUB can load them in a consistent way, but, for some free operating systems, you need to use some OS-specific magic.

How to boot operating systems

GRUB has two distinct boot methods. One of the two is to load an operating system directly, and the other is to chain-load another boot loader which then will load an operating system actually. Generally speaking, the former is desirable, because you don't need to install or maintain other boot loaders and GRUB is flexible enough to load an operating system from an arbitrary disk/partition. However, the latter is sometimes required, since GRUB doesn't support all the existing operating systems natively.

How to boot an OS directly with GRUB

Multiboot (see section `Motivation' in The Multiboot Specification) is the native format supported by GRUB. For the sake of convenience, there are also support for Linux, FreeBSD, NetBSD and OpenBSD. If you want to boot other operating systems, you will have to chain-load them (see section Load another boot loader to boot unsupported operating systems).

Generally, GRUB can boot any Multiboot-compliant OS in the following steps:

  1. Set GRUB's root device to the drive where the OS images are stored by the command @command{root} (see section root).
  2. Load the kernel image by the command @command{kernel} (see section kernel).
  3. If you need modules, load them with the command @command{module} (see section module) or @command{modulenounzip} (see section modulenounzip).
  4. Run the command @command{boot} (see section boot).

Linux, FreeBSD, NetBSD and OpenBSD can be booted in a similar manner. You can load a kernel image by the command @command{kernel} and then run the command @command{boot}. If the kernel requires some parameters, just append the parameters to @command{kernel}, after the file name of the kernel. Also, please refer to section Some caveats on OS-specific issues, for the information on your OS-specific issues.

Load another boot loader to boot unsupported operating systems

If you want to boot an unsupported operating system (e.g. Windows 95), chain-load a boot loader for the operating system. Normally, the boot loader is embedded in the boot sector of the partition on which the operating system is installed.

  1. Set GRUB's root device to the partition by the command @command{rootnoverify} (see section rootnoverify):
    grub> rootnoverify (hd0,0)
    
  2. Set the active flag in the partition by the command @command{makeactive}(5) (see section makeactive):
    grub> makeactive
    
  3. Load the boot loader by the command @command{chainloader} (see section chainloader):
    grub> chainloader +1
    
    `+1' indicates that GRUB should read one sector from the start of the partition. The complete description about this syntax can be found in section How to specify block lists.
  4. Run the command @command{boot} (see section boot).

However, DOS and Windows have some deficiencies, so you might have to use more complicated instructions. See section DOS/Windows, for more information.

Some caveats on OS-specific issues

Here, we describe some caveats on several operating systems.

GNU/Hurd

Since GNU/Hurd is Multiboot-compliant, it is easy to boot it; there is nothing special about it. But do not forget that you have to specify a root partition to the kernel.

  1. Set GRUB's root device to the same drive as GNU/Hurd's. Probably the command find /boot/gnumach or similar can help you (see section find).
  2. Load the kernel and the module, like this:
    grub> kernel /boot/gnumach root=hd0s1
    grub> module /boot/serverboot
    
  3. Run the command @command{boot} (see section boot).

GNU/Linux

It is relatively easy to boot GNU/Linux from GRUB, because it somewhat resembles to boot a Multiboot-compliant OS.

  1. Set GRUB's root device to the same drive as GNU/Linux's. Probably the command find /vmlinuz or similar can help you (see section find).
  2. Load the kernel:
    grub> kernel /vmlinuz root=/dev/hda1
    
    If you need to specify some kernel parameters, just append them to the command. For example, to set @option{vga} to `ext', do this:
    grub> kernel /vmlinuz root=/dev/hda1 vga=ext
    
    See the documentation in the Linux source tree for the complete information on the available options.
  3. If you use an initrd, execute the command @command{initrd} (see section initrd) after @command{kernel}:
    grub> initrd /initrd
    
  4. Finally, run the command @command{boot} (see section boot).

Caution: If you use an initrd and specify the `mem=' option to the kernel, to let it use less than actual memory size, you will also have to specify the same memory size to GRUB. To let GRUB know the size, run the command @command{uppermem} before loading the kernel. See section uppermem, for more information.

FreeBSD

GRUB can load the kernel directly, either in ELF or a.out format. But this is not recommended, since FreeBSD's bootstrap interface sometimes changes heavily, so GRUB can't guarantee to pass kernel parameters correctly.

Thus, we'd recommend loading the very flexible loader `/boot/loader' instead. See this example:

grub> root (hd0,a)
grub> kernel /boot/loader
grub> boot

NetBSD

GRUB can load NetBSD a.out and ELF directly, follow these steps:

  1. Set GRUB's root device with @command{root} (see section root).
  2. Load the kernel with @command{kernel} (see section kernel). You should append the ugly option @option{--type=netbsd}, if you want to load an ELF kernel, like this:
    grub> kernel --type=netbsd /netbsd-elf
    
  3. Run @command{boot} (see section boot).

For now, however, GRUB doesn't allow you to pass kernel parameters, so it may be better to chain-load it instead, for more information please see section Load another boot loader to boot unsupported operating systems.

OpenBSD

The booting instruction is exactly the same as for NetBSD (see section NetBSD).

DOS/Windows

GRUB cannot boot DOS or Windows directly, so you must chain-load them (see section Load another boot loader to boot unsupported operating systems). However, their boot loaders have some critical deficiencies, so it may not work to just chain-load them. To overcome the problems, GRUB provides you with two helper functions.

If you have installed DOS (or Windows) on a non-first hard disk, you have to use the disk swapping technique, because that OS cannot boot from any disks but the first one. The workaround used in GRUB is the command @command{map} (see section map), like this:

grub> map (hd0) (hd1)
grub> map (hd1) (hd0)

This performs a virtual swap between your first and second hard drive.

Caution: This is effective only if DOS (or Windows) uses BIOS to access the swapped disks. If that OS uses a special driver for the disks, this probably won't work.

Another problem arises if you installed more than one set of DOS/Windows onto one disk, because they could be confused if there are more than one primary partitions for DOS/Windows. Certainly you should avoid doing this, but there is a solution if you do want to do so. Use the partition hiding/unhiding technique.

If GRUB hides a DOS (or Windows) partition (see section hide), DOS (or Windows) will ignore the partition. If GRUB unhides a DOS (or Windows) partition (see section unhide), DOS (or Windows) will detect the partition. Thus, if you have installed DOS (or Windows) on the first and the second partition of the first hard disk, and you want to boot the copy on the first partition, do the following:

grub> unhide (hd0,0)
grub> hide (hd0,1)
grub> rootnoverify (hd0,0)
grub> chainloader +1
grub> makeactive
grub> boot

SCO UnixWare

It is known that the signature in the boot loader for SCO UnixWare is wrong, so you will have to specify the option @option{--force} to @command{chainloader} (see section chainloader), like this:

grub> rootnoverify (hd1,0)
grub> chainloader --force +1
grub> makeactive
grub> boot


Go to the first, previous, next, last section, table of contents.