As with LILO, the steps you will need to perform to use GRUB as your active boot loader depend on whether you are installing the OS fresh or have already installed Linux and are planning on moving to GRUB.
For existing Linux users wanting to migrate to GRUB, get the latest version of GRUB. As the root user, type:
# /boot/grub/grub
This will load up a BASH-like command prompt where you now use the GRUB command:
grub> install (hd1,2)/boot/grub/stage1 (hd1) (hd1,2)/boot/grub/stage2 p (hd1,2)/boot/grub/menu.conf
This command uses the GRUB install command, which requires the location of the stage one image and the location of the MBR (install (hd1,2)/boot/grub/stage1 (hd1)
). Also the location of the stage two image ((hd1,2)/boot/grub/stage2
) is required. Finally, an optional p (hd1,2)/boot/grub/menu.conf
tells GRUB the location of the GUI menu configuration file.
In the previous example, hd1
is my Linux Disk
and hd0
is my Windows disk. This will use the current GRUB defaults and splat anything that is currently in the MBR .
GRUB configuration is all done through a configuration file located in /boot/grub/grub.conf. Listing 2 shows an example configuration that relates to my home setup, a dual-booting Linux and Windows machine:
Listing 2. Example grub.conf file
default=0 |
- The
default=
option signals to GRUB which image to boot from by default after the timeout period. This relates to one of the images in the grub.conf file. 0 is the first specified, 1 is the second specified, etc. If you don't specify this option in the configuration file, it will boot the first image specified in the file. timeout=
is the number of seconds the boot prompt will wait before automatically loading the default OS, in this case, Red Hat Linux.splashimage=
is the location of the image to be used as the background for the GRUB GUI.- The
password
option specifies the MD5-encrypted password used to gain access to GRUB's interactive boot options. Note this does not stop users loading your defined OS choices; this needs to be set on a per-title
basis. To generate anmd5
password, run the toolgrub-md5-crypt
(as root), which comes with GRUB. It will prompt you for the password you want to encrypt. It then will output the MD5-encrypted password. Copy this into your grub.conf afterpassword -md5
but on the same line. Usually this password can be set to the root password, since it is only root who can read the grub.conf file anyway. title
identifies the specific OS that will be booted from at the user interface at runtime. Unlike with LILO, you can include spaces in this name.password
is set in the same way as the password above. Do not set this password to the root password if you are planning on sharing this machine with other users.- The
root
option tells GRUB where the OS file system actually lives. As you can see, GRUB references the media in a different way than LILO. In our LILO example, /dev/hdb3 is the third partition of the second disk. Grub references this disk as (hd1,2), again the third partition of the second disk (disk 0 being the first disk, partition 0 being the first partition). kernel
: vmlinuz-X.X.XX-XX is the name of the default boot kernel image within your root directory.initrd
: initrd-X.X.XX-XX.img is the name of the default initrd file within your root directory.title
is the same as all other title options.password
: See other password options.- The
rootnoverify
option tells GRUB to not try to vary the root of the OS. This saves load errors if the file system is not a supported by GRUB. chainloader +1
tells GRUB to use a chain loader to load this OS, which is required for loading Windows.
You can use many other parameters in the grub.conf file, but the parameters in Listing 2 should get you into a fairly usable state on your machine. For further information on these and other grub.conf parameters, see the manual pages (man grub.conf).
Unlike LILO's configuration file, grub.conf is read at boot time, and the MBR does not need to be refreshed when this is changed.
www.ibm.com
No comments:
Post a Comment