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
Direct booting
Generally, GRUB can boot any Multiboot-compliant OS in the following steps:
- Set GRUB's root device to the drive where the OS images are stored with the command root (see root).
Load the kernel image with the command kernel .
- Optional: If you need modules, load them with the command module or modulenounzip.
- Run the command boot
Linux
Set GRUB's root device to the same drive as GNU/Linux's. Probably the command find /vmlinuz or similar can help you (see find).
- 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 vga to `ext', do this:
grub> kernel /vmlinuz root=/dev/hda1 vga=ext
If you use an initrd (this is general in Linuxes), execute the command initrd after kernel:
grub> initrd /initrd
Finally, run the command boot.
ChainLoading
If you want to boot an unsupported operating system (e.g. Windows XP), chain-load a boot loader for the operating system. Normally, the boot loader is embedded in the BootSector of the partition on which the operating system is installed.
Set GRUB's root device to the partition by the command rootnoverify:
grub> rootnoverify (hd0,0)
Set the active flag in the partition using the command makeactive1 (this is not necessaryt for most of the modern operating systems):
grub> makeactive
Load the boot loader with the command chainloader :
grub> chainloader +1
`+1' indicates that GRUB should read one sector from the start of the partition.
Run the command boot .
However, DOS and Windows have some deficiencies, so you might have to use more complicated instructions.
DOS / Windows
DOS/Windows 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 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, DOS (or Windows) will ignore the partition. If GRUB unhides a DOS (or Windows) partition (see 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