PDA

View Full Version : Getting grubby: Demystifying the Linux start-up processes



OMEN
10-21-2007, 11:19 AM
Linux users can boast long times between reboots, but even so, the startup screens will grace your display at some time. Here’s just what your computer is doing during this process, the several important steps that occur and the order they take place, and how you can take control.
Linux users, almost by definition, like to get their hands dirty, and understand how their computer really works under the hood. Although it may sound fairly obvious, the boot process actually contains some subtle intricate behaviours and it is helpful to get a handle on them.

The BIOS and the boot loader
No matter what operating system is installed, when a computer is powered up control is first given to the motherboard’s built-in BIOS. The BIOS performs a power-on self test (POST) which assesses if attached devices are functioning normally.

If all is well, the BIOS hands over control to the master boot record (MBR) of the boot device. Different media may be used for booting – like CD/DVD ROMs and USB drives – but most commonly a computer will boot from an internal hard drive.

Linux distros offer several different boot loaders; LILO was once popular, and others now exist which may vary by vendor; Red Hat have implemented GRUB as their only boot loader for example while others use syslinux. IBM offer a comparison between LILO and GRUB (http://www-128.ibm.com/developerworks/library/l-bootload.html), but the significant thing to know is that each Linux variant requires, and offers, a boot loader whatever it may be.

Older PCs need the boot loader to be located within the first 1024 cylinders of the hard disk and necessitates the /boot partition to be in a primary partition. Modern BIOSs support logical block addressing (LBA) which avoids this restriction by letting the BIOS work with much more of the hard drive.

GRUB derives its name from its objective as “The Grand Unified Bootloader”, seeking to serve all your operating system booting needs. GRUB – and any boot loader – is partially stored within the MBR itself. It will list the different operating systems available for booting on your computer – of which there may be just one, or there may be many. Either way, the primary purpose of GRUB is to determine which OS to boot and to then, in daisy chain fashion, pass control on to it.

For Linux operating systems, GRUB will specify the disk partition that should become the root partition, the location of the kernel and the initial RAM disk. These may be listed in /boot/grub/grub.conf like so:

title Red Hat Enterprise Linux
root (hd0,4)
kernel /vmlinuz.EL ro root=LABEL=/ rhgb quiet
initrd /initrd.EL.img

(Other boot loaders will have a similar config file.)

These settings specify this operating system should be displayed in GRUB’s list as “Red Hat Enterprise Linux.” Its /boot directory is located on the fifth partition on the first hard drive (these indexes are 0-based, hence the “4” actually means the fifth partition.)

The kernel is the file vmlinuz.EL which is located within the /boot directory. This is opened as read-only (mode “ro”) to protect from any accidental harm. The actual top-level root directory is associated with the / label, and finally rhgb quiet directs boot messages to be hidden by default. Other directives can be specified here; selinux=0 for instance will disable Security Enhance Linux (SELinux).

ITWire