Top Five Open Source Packages for System Administrators
Pages: 1, 2
Some GRUB Recipes
We're now ready to look at the GRUB configuration file (grub.conf). Here are some sample lines from its first, general section:
# general section splashimage (hd0,0)/grub/splash.xpm.gz Pretty picture behind the menu. default 0 Default boot entry (numbering starts at 0). timeout 30 Menu timeout period in seconds. password -md5 xxxxxxx Use grub-md5-crypt to encode password.
These lines specify the image displayed behind the boot menu, the menu timeout period and default entry to boot, and the boot password.
The remainder of the file specifies the items on the boot menu. Here are two examples that boot the Linux operating system on the first partition on the first hard disk (selecting different kernels):
title Linux root (hd0,0) kernel /vmlinuz ro root=/dev/hda2 initrd /initrd.img title Test-Linux root (hd0,0) kernel /vmlinuz-test ro root=/dev/hda3 initrd /initrd.img-test
title lines indicate the menu item text. The
specify the partition where the boot loader is located. All directory
references are assumed to be relative to the root of this partition. Thus, the
location of the
vmlinuz files specified in the
kernel lines is in
the root directory of this partition.
kernel lines specify the path to the Linux kernel in each case,
along with any parameters to be passed to it. In this case, a separate /boot
partition is being used, so the
root parameter is passed to the
kernel; the latter indicates the location of the system root directory (such as /). Thus, we can tell that the kernel images reside at /boot/vmlinuz*
from the point of view of the booted Linux system. The
similarly specify the path to the initrd.img file (if used).
Booting FreeBSD is also very simple:
title FreeBSD # use the 1st BSD subpartition in disk 1 partition 3 root (hd0,2,a) kernel /boot/loader
This stanza again specifies the boot partition and locates the FreeBSD final-stage boot loader. This is the recommended practice (rather than directly invoking the FreeBSD kernel).
This stanza defines a bootable Windows partition:
title Win2K root (hd0,2) makeactive chainloader +1
The boot partition is specified in the usual way. The
command activates the partition, and the
chainloader command hands off
the boot process to local boot loader (for example, NTLDR).
In general, GRUB can boot operating systems on any disk. However, in some cases, it is easier to boot non-Unix operating systems on the second hard disk if you logically "swap" the first two drives. GRUB uses entries like these to do so:
map (hd0) (hd1) map (hd1) (hd0)
GRUB also has the nice feature of remembering what operating system was last
booted and making it the default for the next time. To enable this capability,
default entry to
saved (in the general section), and add a
savedefault directive to the end of each stanza:
title Linux ... savedefault
Once you've created the configuration file, installing GRUB is very easy. It
is done with the
grub-install utility that is included with the package.
This tool has the following general syntax:
# grub-install [--root-directory=/dir] disk
where disk is the boot partition, specified in either GRUB's format or
the local format (for example,
--root-directory option specifies the directory location of a
separate boot partition (for example,
/boot under Linux).
For more information about GRUB, consult the following:
- GRUB project home page.
- Chapter 16, "Configuring and Building Kernels," of Essential System Administration, 3rd Edition.
If you liked this article and would like to receive the free ESA3 newsletter, you can sign up here.
Æleen Frisch has been a system administrator for over 20 years, tending a plethora of VMS, Unix, Macintosh, and Windows systems. If you liked this article and would like to receive the free ESA3 newsletter, you can sign up at http://www.aeleen.com/esa3_news.htm.
O'Reilly & Associates recently released (August 2002) Essential System Administration, 3rd Edition.
Sample Chapter 11, "Backup and Restore," is available free online.
For more information, or to order the book, click here.
Return to ONLamp.com.
RH-specific config file name
2003-05-30 20:27:15 anonymous2 [View]
Mistake in example on page 1
2002-11-11 04:54:41 anonymous2 [View]
Mistake in example on page 1 - fixed
2002-11-11 11:02:55 sarahkim [View]
2002-11-08 20:14:57 anonymous2 [View]
most under-used app? 'info'
2003-04-26 10:58:12 anonymous2 [View]
most under-used app? 'info'
2003-05-30 12:36:00 anonymous2 [View]