Monday, July 19, 2010

GRUB

GRUB is the boot loader commonly used in desktop systems, having supplanted LILO in the past few years. GRUB performs the same job as LILO: after the first-stage boot loader has run, GRUB finds a kernel, puts it into memory, and lets the system start. GRUB divide booting into three stages: 1, 1.5, and 2. The stage 1 boot loader fits into the MBR of the device; its job is to mount the devices necessary to run the stage 2 GRUB boot loader, which reads a configuration file and presents a user interface. The 1.5 boot loader is necessary when the code required to find the stage 2 boot loader doesn’t fit into the 512 bytes of the MBR. GRUB is controlled by the /boot/grub/menu.lst file stored on the boot partition configured when you install GRUB This file is divided into one section (at the start of the file) with global options and a second section containing a list of kernels to boot. A typical menu.lst file for an embedded system looks like the following:

title Linux

root (hd0,1)

kernel /zImage root=/dev/hda2 ro

The root parameter indicates that the / should be mapped to the device hd0’s first partition. The next line tells the system to get the kernel at /zImage. Because there’s only one entry, grub doesn’t display a menu. This root parameter doesn’t have an effect on the root file system that the kernel eventually mounts; it’s the root file system for the boot loader itself. The root device format is different than Linux, which can result in confusion. In GRUB, a device has the following format:

(device[bios number][,partition])

Device can be one of the following values: hd for fixed disks, fd for floppy disks, or nd for network drives. The number that follows is the identifier assigned by the computer’s BIOS. You can find this in the BIOS setup for the computer; the assigned numbers start at 0 and work upward. The partition is the logical division of the drive. To find the partitions on a drive, use the sfdisk command:

$ sudo /sbin/sfdisk -l

GRUB allows you to load the kernel from a TFTP server. To do this, you need to configure the IP parameters and use (nd) instead of (hd0,1) as the root device. For example:

ifconfig -address=10.0.0.1 -server=10.0.0.2
kernel (nd)/bzImage


This results in GRUB configuring the adapter to have an IP address of 10.0.0.1 and use the default netmask (255.0.0.0) and contact 10.0.0.2 to download the kernel file bzImage via TFTP to boot the system.

Source of Information : Pro Linux Embedded Systems

No comments: