The Linux Booting Process
The Linux Booting Process
The Linux Booting Process
PROCESS
STAGE2:-MBR PROCESS
MBR stands for master-boot record.
It is located in the first sector of the bootable disk. It is of 512 bytes in memory and contains three
important components.
Primary boot-loader information in first 446 bytes.
Partition table information in next 64 bytes.
MBR validation checks in last 2 bytes.
MBR also contains the information about the GRUB, so we can say that MBR loads and executes
GRUB.
STAGE 4:-KERNEL
STAGE 6:RUN-LEVEL
Run-level is the last stage of the Linux boot process.
When the Linux operating system is booting up, you might have seen various services which are
staring up like staring sendmail OK. Those are the run-level programs which are executed from the
run-level directories as defined by your run-level.
Depending upon your default init level setting, the system will execute the program from one of the
following directories.
Run-level 0:- /etc/rc.d/rc0.d/
Run-level 1:- /ect/rc.d/rc1.d/
Run-level2:- /etc/rc.d/rc2.d/
Run-level 3:-/etc/rc.d/rc3.d/
Run-level 4:- /etc/rc.d/rc4.d/
Run-level 5:-/etc/rc.d/rc5.d/
Run-level6:- /etc/rc.d/rc6.d/
Symbolic links to these directories are also present inside /etc directories like
Run level 0:- /etc/rc0.d/ is symbolic link to /etc/rc.d/rc0.d/
Run-level 1:- /etc/rc1.d/ is symbolic link to /etc/rc.d/rc1.d/
Run-level 2:- /etc/rc2.d/ is symbolic link to /etc/rc.d/rc2.d/
Run-level 3:- /etc/rc3.d/ is symbolic link to /etc/rc.d/rc3.d/
Run-level 4:- /etc/rc4.d/ is symbolic link to /etc/rc.d/rc4.d/
Run-level 5:- /etc/rc5.d/ is symbolic link to /etc/rc.d/rc5.d/
Under the directories /etc/rc.d/rc*.d/ you would have seen that programs starts with S and K.
Program thats starts with S are used during startup.
Program thats starts with K are used during shutdown.
There are also the numbers right to S and K in the programs names; these are the sequence
numbers in which program will start and shutdown.
For example S12syslog is to start the syslog daemon which has the sequence number 12, on the
other hand S80sendmail is to start the sendmail daemon which has the sequence number 80. So in
this case syslog program will start before sendmail.
RUN-LEVELS
RUN-LEVEL 1:
This is the run-level which is used in Linux Operating system to run the system in single user mode.
This run-level is equivalent to maintenance mode in window operating system.
RUN-LEVEL 2:
This is the run-level which is used to run the machine in multi-user CLI mode. But there is no
restriction in this run-level is that it does support network file-sharing services like NFS and SMB.
RUN-LEVEL 3:
This is the run-level which run the machine in multi-user mode. This is the run-level which is most
widely used in the industries standard. This is the run-level which work in command line interface
mode and support all services.
RUN-LEVEL 4:
This is the run-level which is not so used and reserved for future purpose. This is the run-level which
is used for custom-level only even though this run-level has many more features as compared to runlevel 3.
RUN-LEVEL 5:
This is the run-level which is default run-level in Linux Operating system. This is the run-level which
works in Graphical Interface mode. This run-level also support all services and widely used in
workstation.
RUN-LEVEL 6:
This is the run-level which is used to restart the system.
END OF TOPIC
OVERVIEW OF GRUB
CONFIGURATION FILE
With first line you got to know which drive contain the Linux boot-loader i.e #boot= dev/sda.
With second line you got to know which kernel image grub loads and execute during booting
process i.e default =0, or default=1 or 2. This line will depends when you have various kernel
images loads on your system.
With third line, you got to know till how much time splash image waits for your input. After that
it will executes the kernel image as specified in Linux Operating system i.e timeout=5
With fourth line you got to know the location of the splash image i.e
splashimage=(hd0,0)/boot/grub/splash.xpm.gz.
Fifth line indicates the hidden menu, which you will not see while the Linux booting up, and
these lines are as follows.
First it will contain the Linux version, second it contains the location of root file-system and
third and fourth line contains the kernel and initrd images.
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
root (hd0,0)
initrd /boot/initrd-2.6.18-194.el5PAE.img
GRUB VS LILO
S.N
O
GRUB
1.
2.
3.
4.
5.
6.
7.
LILO
LILO stands for Linux Loader.
LILO does not have the knowledge of the filesystem.
LILO does not boot from the network.
LILO does not have interactive command line
interface.
LILO was present till Linux version 4.
Changes made to LILO do not auto-load to OS.
LILO understand only Linux Operating system.
STAGES OF GRUB
LEVELS OF GRUB
GRUB plays the vital role in the Linux Operating system and it is the default boot-loader to
redhat, Ubuntu and various other Linux variant. Lets discussed the various stage of GRUB
which shows how GRUB loads and execute kernel.
STAGES OF GRUB:
GRUB has three different stages which is called
GRUB stage 1.
GRUB stage 1.5.
GRUB stage 2.
In GRUB stage 1, the code contain in the master- boot record is considered to be GRUB stage 1, in
this stage GRUB looks for the master boot record for the active partition from where it can boot
kernel. This is the stage which calls GRUB stage 1.5.
In GRUB stage 1.5, looks to identify the file-system type which is an optional, this stage directly calls
GRUB stage 2.
GRUB stage 2 is the final stage which calls the kernel and Loads it into the memory. This is the stage
where most of the troubleshooting time will be spend off.
We bring the system in GRUB Command line mode, by using RHEL installation CD, and pressing c
option in GRUB.
Now we have to find out in which partition and disk, the grub.conf file contains, and for this we have
to use the find command as follows. Grub> find /grub/grub.conf.
Now it will return the disk name and partition, now we also can use grub> root. This will show that
the (hd0,0) file does not exist and also show the file-system type.
Now finally, we load the grub to the disk which is returned in the previous command as follows
grub>setup (hd 0)
END OF TOPIC
FREQUENTLY ASKED
QUESTION
Kernel execute init program only when all computer drivers are in place.
What are the commands to view current run-level in Linux Operating system?
The command to view current run-level in Linux Operating system are
Runlevel
Who r
What are the commands to change the run-level in Linux Operating system?
The commands to change the run-level in Linux Operating system are
Init (runlevel) Temporary method.
Make entry in /etc/inittab file- Permanent method
What is the difference between traditional sysv and upstart utility?
S.N
O
1.
2.
3.
4.
SYSV
Traditional sysv was present till redhat Linux
5
It is slower as compared to upstart utility
It calls all services sequentially
UPSTART
Upstart is the new utility comes in red-hat Linux
version 6.
It is faster.
It does call the services sequentially, and worked
upon jobs and event based and all services is with
/etc/init directories as jobs.
It does not any such mediator while calling services
and services start and stop by upstart only.
What is the path of the filename where all booting information stored?
The path of the filename where all booting information stored is /var/log/dmesg.
What is the command to troubleshoot hardware issues in Linux operating system?
The command to troubleshoot hardware issues in Linux Operating system is lsmod.
SHUTDOWN
COMMAND
SHUTDOWN COMMAND:
Shutdown command plays vital role in Linux Operating system.
This command is used to bring the system in power off state i.e in HALT state.
It will also used to restart or reboot the system.
With the help of this command we can also warn the user for the shutdown and also set the timings
for the shutdown.
The syntax and the switches used in shutdown command as follows.
SYNTAX:
shutdown[option] time.
SWITCHES:
k- This switch is used to just warn the user, dont reboot.
h- This switch is used to bring the system in power off state after shutdown
r- This switch is used to reboot the system.
F- This switch is used to check file-system while booting.
t SECS This switch is used to sets seconds.
n- This switch is used to kill all process and send the shutdown message and delay the
shutdown by x. This switch is
So Recommended.
FEWS EXAMPLE OF SHUTDOWN:
Shutdown now- This will bring the system in resue mode.
Shutdown h 120- This will power off the system after 120 secs while shutting down the
system.
Shutdown r now- This will reboot the system.
END OF TOPIC
CHKCONFIG COMMAND
SYNTAX:
Chkconfig[option] service name.
SWITCHES:
--list This switch is used to check the service at the run-levels.
-- add- This switch is used to add the services at run-levels.
--del This switch is used to remove the services at the run-levels.
--level This switch is used to add or remove the services at particular level.
EXAMPLES OF CHKCONFIG COMMAND:
Chkconfig
Chkconfig
Chkconfig
Chkconfig
list sshd- This command is used to list the services at all run-levels.
add sshd- This command is used to add the sshd services at the run-levels.
del sshd This command is used to remove the services at the run-levels.
level 3 sshd on This command is used to on the sshd services at run-level 3.
IPTABLES
INPUT CHAIN
OUTPUT CHAIN
FORWARD CHAIN
PREROUTING CHAIN
POSTROUTING CHAIN
INPUT CHAIN
OUTPUT CHAIN
FORWARD CHAIN
PREROUTING CHAIN
POST ROUTING CHAIN
OUTPUT CHAIN
INPUT CHAIN
OUTPUT CHAIN
FORWARD CHAIN
PRE-ROUTING CHAIN
POST ROUTING CHAIN
SYNTAX OF IPTABLES:
The syntax of IP tables is as below.
iptables t tablename [actions reaction][packet pattern] j [what to do]
This action is used to add the rule in the IP tables and we can also add to specific place by
giving the number.
WHAT TO DO IN IPTABLES?
What to do are the targets values which we already discussed.
IP tables are installed state by default in Linux operating system, so no need to install.