RHEL 5 Boot sequence and GRUB

Change is inevitable !!!

Having worked on Apps and database administration, its time to broaden the scope. I will be discussing few topics on RHEL (RedHat Entrprise Linux) system administration. Hope this will help beginners to gain knowledge about the most matured open source operating system available in the world.

Lets have a very quick review of how the Linux boots. Here are the very brief steps.

1) When a PC is booted it starts running a BIOS program which is a memory resident program on an EEPROM integrated circuit. The BIOS program will eventually try to read the first sector on a booting media such as a hard or floppy drive. The boot sector contains a small program that the BIOS will load and attempt to pass run control to. This program will attempt to read the operating system from the disk and run it.

2) The small program containing in the boot sector that BIOS will load and attempt to pass control to is called bootloader. This is a small program residing in the 1st sector of primary partition. Primary partition by default is always /boot. This directory will have all files required for bootup.

The boot loader program is present in 2 stages in Linux.

Stage 1: Small stage and resides in MBR (Master boot record) or boot sector. This is the once we were taking above – A small program residing in the 1st sector of primary partition /boot.

Stage 2: This is the complete bootup program present in /boot partiton and is called from first stage.

So 1st stage is present in MBR and just called for stage 2.

This MBR sector is 512 bytes size. The first 446 bytes contains the GRUB program (1st stage).

3) GRUB program reads the configuration file /boot/grub/grub.conf during boot time. Since this file is present in /boot partition, this partition should be present in file system that GRUB will understand, because it has to read the file before OS starts. So /boot mount point should be formated with either ext2 or ext3.

We will discuss about GRUB file shortly after finishing this brief booting sequence steps.

So once control comes to GRUB program it executes and you will see a red spashing windown comes up which gives the countdown in seconds like

Booting up Redhat Enterprise Linux in 5..4..3.. Secs

Now before the conuntdown ends, you can press either space or enter. Once you press that, you will see a table on a screen with list of operating systems present in that server. Example if you have installed Windows initially and then you installed Linux this table will show both OS in the option.

But to get this list of OS you need to enter space or enter, else it will bootup the default operating system which will be Linux.

This showing up of operating system list can be controlled by parameter hiddenmenu present in GRUB config file. We will see this in a short while. Also you can control the time for which it should countdown (timeout parameter in GRUB file).

GRUB will load the specific kernel into the RAM (which kernel to load is passed to GRUB in its script) and uncompress the kernel program in RAM. Once it uncompresses, the control is taken over by kernel and job of GRUB script ends here.

4) The kernel initialization files generates output which may not be possible to see on screen as it scrolls quickly but can be seen in log message file /var/log/dmesg which contains the snapsot of these kernel messages taken just after control is passed to init.

Many packages and device drivers present in kernel program are called. Device drivers will check all there respective hardware devices if they are available. If successful in locating devices, the driver will initialize and usually log output to kernel message buffer.

kernel of Linux is made light weight and hence will load only the required module and packages. But if some of the modules also needs to be loaded along with the kernel, its not a good idea to make it a part of kernel. Instead in redhat those additional modules are included in initrd file, which is then temporarily mounted by kernel on a RAM disk to make modules available for initialization process. This file initrd is password as one of the arguement in GRUB file for loading the kernel. We will see this arguement when we see GRUB file.

After all essential drivers are loaded, kernel will mount the root filesystem in read-only mode so that no process while booting should make any changes to any file on disk.

The first process is then created and loaded and control is passed from kernel to that process. This first process that gets created is called “init”. This process is having PID=1 and its the initialization process. This will intialize the system.

5) Init process created above will read its configuration file /etc/inittab. This file stores the information like initial run level, system initialization script, run level specific scripts, trap certain key sequences etc.
We will discuss about this file in my next post when I will explain run levels.

The final file that is run in boot sequence is /etc/rc.d/rc.local

So if we have to make any customization or call a custom script, we can call from this file. Example if we want to start a database when our server boots up we can add a script in /etc/rc.d/rc.local to start a database.

Having a brief idea about boot sequence for Linux, lets see the content of GRUB config file


The GRUB file in RHEL is present in /boot/grub/grub.conf

Following is the content of this file

# cat /boot/grub/grub.conf
# grub.conf generated by anaconda
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/sda2
#          initrd /initrd-version.img
title Enterprise (2.6.9-
root (sd0,0)
kernel /vmlinuz-2.6.9- ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.9-
title Enterprise-smp (2.6.9-
root (sd0,0)
kernel /vmlinuz-2.6.9- ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.9-
title Enterprise-up (2.6.9-
root (sd0,0)
kernel /vmlinuz-2.6.9- ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.9-

lets understand meaning of each parameter here.

default -> This gives the default operating system to be booted in case the user is not giving any choice. Example if there are 2 OS installed on a server (lets say Linux and Windows, linux with number 0 and windows with number 1) then default=0 will boot Linux by default. The number is decided by the sequence in which these OS are listed in grub.conf above.

If we see the lines starting with “title”, these are the list of OS installed on server and this list (only the title) will be displayed at the time of booting when control goes from BIOS to GRUB. Since its present in grub.conf 1st stage of bootloader program will display this OS list.

In above file default=0 will pick “Enterprise (2.6.9-” OS by default.

timeout -> This gives the time for which countdown will continue or time for which the list of OS should be displayed before taking default option. Example in out case timeout=5 means it will show the option for 5 seconds.

splashimage -> This option gives a red spashing window of redhat linux while showing the list of OS or while booting. If you remove this file it will show a black window.

hiddenmenu -> This options will hide the list of OS installed on server. It will only show the countdown. If you press enter or space (as explained previously in point 3 of boot sequence) then it will show the list of OS. If you remove this option by default while booting it will show the list of OS installed.

title -> As explained just now these are the title to be shown during booting from where you can select. You can change title to anything that you want. Example “My OS”. This will show “My OS” as one of the option during booting.

root (sd0,0) -> This tells us that the boot loader program is present in 1st disk (sd0 indicate 1st hard disk) and 1st partition (,0 indicates 1st partition). So here we are telling where exactly is the bootloader program.

kernel /vmlinuz-2.6.9- ro root=LABEL=/ rhgb quiet

kernel is a parameter, /vmlinuz-2.6.9- is a value -> This is the name of kernel file to be used.

ro -> opens the filesystem in readonly mode during booting. If we remove this arguement it will open the filesystem in read write mode.

rhgb -> This is redhar graphical boot. This parameters gives a graphical progress bar while booting. If we remove this then it will give a traditional black window with many [ OK ] messages.

root=LABEL=/ -> This gives the location of root directory where all the installation has happened. this is usaully /. We can also give device name directly example in my case the device name is /dev/sda2. So we can give root=/dev/sda2
This will also work.

quiet -> This will hide details while booting up and will show only few message ehgb mode or in traditional mode. Only few [ OK ] messages will be displayed corresponding to services that are getting started. Else if we remove this parameter many more detailed messages will be displayed.

initrd /initrd-2.6.9- -> This gives the extended modules which we want to load while booting. As I explained that not all modules are part of kernel, in order to keep it light. So if additional extended modules needs to be intalled then we need to give this file as input.

My next post will be in run levels and understanding /etc/inittab file. Happy reading !!

Hope this helps !!


20 thoughts on “RHEL 5 Boot sequence and GRUB

  1. It was really informative. I liked the way you explained each procedure.Thanks for sharing your knowledge. But I have an issue. After having dual boot, I re-installed Windows. Now I cannot boot rhel. The MBR was overwritten. How can it be tackled? Can you help me out? Thanks in advance.

  2. Hi Shinu,

    That’s why we should never install windows after linux on the same machine 🙂
    Anyways, what you can do is, get a boot.iso – This is a boot image which can be burned on a CD. You must be having this on your linux software DVD. You can also use pen drive and load diskboot.iso file into pen drive. diskboot.iso is same as boot.iso, but used with VFAT filesystem.

    Once you create lets say a CD using boot.iso, make changes in your BIOS setting to boot from a CDROM instead of hard drive. When it will boot from CDROM, you will get ISOLINUX> prompt.

    At this prompt you can type “linux rescue” and hit enter. This will setup a rescue environment. Carry out the installation it is asking for. Its going to do a bare minimum installation to setup rescue environment. It will ask you if you want to mount your file system. Click on continue.

    Once every thing is done, you will be at a prompt and your file system of linux gets mounted at /mnt/sysimage

    After that carry out following steps at prompt.

    # chroot /mnt/sysimage
    # grub-install /dev/sda
    # exit

    The command grub-install is going to write grub file at the first sector of your boot disk. After then when you boot, you will be shown both options Linux as well as windows.

    Also confirm the disk you are using, if its a SCSI controller disk then its /dev/sda else it will be /dev/hda

  3. hey this is teju.. N i am a technical trainer for linux N thank u so much for spending your valuable time in posting this article.. This boot procedure helped me a lot n i understood still more better.. Really it will help my students also a lot thanks once again…

  4. thanks a lot for this valuable information..can u tell me why i am not able to see linux os when i install windows after linux.how can i recover my linux from this??? waiting for response…

  5. Hi,

    The reason you are not able to see your Linux after installing windows is that, windows always replaces the Master boot record which was having linux grub file. Problem is windows won’t let you switch to the grub file of linux once its installed. But if you had installed windows first and then linux, then linux will make changes to the master boot record but will never replace it.

    In this situation, I am really not sure how to get back linux installation.


    Advait Deo

  6. sir, thank u for replying me.i asked my rhce trainer abt tht he told me to go linux rescue method and type chroot /mnt/sysimage,grub-install /dev/hda,exit then root (hd0,0),setup (hd0).this will recover windows..
    sir.. you have not mentioned abt cmos and mechanism how processor hand over the control to bios.please tell me abt this.. waiting for response

  7. Dear Sir
    Very usefull information shared you with us.
    can yiu tell me tell me how i can install grub to a usb pen drive to make it linux bootable
    when i try to install
    grub-install /dev/sdb1
    it give an error no bios information available for this device
    (/dev/sdb1 is usb pen drive)


    Basant Sharma (RHCE)

  8. you should have mentioned the names of scripts also which init runs like the etc/rc.d/rc.sysinit script which sets the environment path, starts swap and checks the file systems, then /etc/inittab script, which describes how the system should be set up in each Sys init runlevel and then the source function library, /etc/rc.d/init.d/functions, for the system which spells out how to start or kill a program and how to determine the PID of a program.

  9. It is excellent man i got idea about GRUB.Actually i got one problem
    while i am preparing vmware server for RAC installation i added additional things after quiet keyword in grub.conf file for making time stamp equal in host and guest.

    kernel /boot/vmlinuz-2.6.9- ro root=LABEL=/
    rhgb quiet clock=pit nosmp noapic nolapic

    After i added this i am unable to boot i am getting error like
    errr 17:Unrecognized device string

    Can you please tell me diff b/w UP,SMP kernels i got two kernels though i select only one while i was installing.

  10. Its such a nice information. Its really helpful for all Red Hat lover.

    Very very Thanks to whom who so ever publish this information.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s