Boot loader is an integral part of the computer. In computing, booting is a set of operations that computer systems perform when power is on. Today, modern computers take one- tenth of a second and typically perform power on self test (POST). A Boot Loader is a computer program that loads the main operating system of the computer after the completion of self-tests.
Today, most of the Linux distribution uses GRUB as a boot loader. GRUB (GNU Grand Unified Boot loader) is a boot loader package from the GNU Project. GRUB Comprises of two stages. Stage 1 consists of 512 bytes and its only task is to load second stage of the boot loader. Subsequently, stage 2 is loaded. The second stage contains the main part of the boot loader.
Configuration of the GRUB based on below files.
The graphical splash screen with the boot menu is based on the GRUB configuration file /boot/grub/menu.lst, which contains all information about all partitions or operating systems that can be booted by the menu. Every time the system is booted, GRUB loads the menu file from the file system. For this reason, GRUB does not need to be reinstalled after every change to the file.
The file 'device.map' maps GRUB and BIOS device names to Linux device names. In a mixed system containing PATA (IDE) and SCSI hard disks, GRUB must try to determine the boot sequence by a special procedure because GRUB may not have access to the BIOS information on the boot sequence. GRUB saves the result of this analysis in the file /boot/grub/device.map
After manually changing 'device.map', execute the following command to reinstall GRUB. This command causes the file 'device.map' to be reloaded and the commands listed in 'grub.conf' to be executed:
grub --batch < /etc/grub.conf
This file contains the commands, parameters and options that the GRUB shell needs for installing the boot loader correctly.
setup --stage2=/boot/grub/stage2 --force-lba (hd0,1) (hd0,1)
This command tells GRUB to automatically install the boot loader to the second partition on the first hard disk (hd0,1) using the boot images located on the same partition. The --stage2=/boot/grub/stage2 parameter is needed to install the stage2 image from a mounted file system.
Setting Grub Boot Password
At the root prompt, encrypt the password using grub-md5-crypt:
[root@mailserver grub]# grub-md5-crypt
Paste the encrypted string into the global section of the file menu.lst or /etc/grub.conf file
password --md5 $1$lS2dv/$JOYcdxIn7CJk9xShzzJVw/
Accessing files from the grub prompt
grub> root (hd0,1)
grub> cat /etc/passwd
You can directly access files from the grub command prompt by executing the two commands given above.
For searching files from the grub command prompt:
grub> find /etc/passwd
The above command finds the partition that contains the password file.
Displaying memory information
EISA Memory BIOS Interface is present
Address Map BIOS Interface is present
Lower memory: 640K, Upper memory (to first chipset hole): 3072K
[Address Range Descriptor entries immediately follow (values are 64-bit)]
Usable RAM: Base Address: 0x0 X 4GB + 0x0,
Length: 0x0 X 4GB + 0xa0000 bytes
Reserved: Base Address: 0x0 X 4GB + 0xa0000,
Length: 0x0 X 4GB + 0x60000 bytes
Usable RAM: Base Address: 0x0 X 4GB + 0x100000,
Length: 0x0 X 4GB + 0x300000 bytes
Displays the current use of memory, based on information from the BIOS. This is useful in determining how much RAM a system has prior to booting it.
To display Disk Geometry:
grub> geometry (hd0)
drive 0x80: C/H/S = 1305/255/63, The number of sectors = 20971520, /dev/hda
Partition num: 0, Filesystem type is ext2fs, partition type 0x83
Partition num: 1, Filesystem type is ext2fs, partition type 0x83
Partition num: 2, Filesystem type unknown, partition type 0x82
Above out command output shows geometry about the first disk. You can find the number of Cylinders/Heads/ and sectors in the first disk. It also shows number of partitions and partition type.