Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
167 views11 pages

6 Stages of Linux Boot Process (Startup Sequence)

The Linux boot process involves 6 main stages: 1. BIOS initializes hardware and loads the MBR boot loader 2. MBR boot loader loads and executes the GRUB boot loader 3. GRUB displays a menu to select the kernel and loads the Linux kernel and initrd image

Uploaded by

joshi.isha.ec
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
167 views11 pages

6 Stages of Linux Boot Process (Startup Sequence)

The Linux boot process involves 6 main stages: 1. BIOS initializes hardware and loads the MBR boot loader 2. MBR boot loader loads and executes the GRUB boot loader 3. GRUB displays a menu to select the kernel and loads the Linux kernel and initrd image

Uploaded by

joshi.isha.ec
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

6 Stages of Linux Boot Process (Startup Sequence)

Press the power button on your system, and


after few moments you see the Linux login
prompt.
Have you ever wondered what happens behind
the scenes from the time you press the power
button until the Linux login prompt appears?
The following are the 6 high level stages of a
typical Linux boot process.

1. BIOS
BIOS stands for Basic Input/Output System
Performs some system integrity checks
Searches, loads, and executes the boot
loader program.
It looks for boot loader in floppy, cd-rom, or
hard drive. You can press a key (typically F12
of F2, but it depends on your system) during
the BIOS startup to change the boot
sequence.
Once the boot loader program is detected
and loaded into the memory, BIOS gives the
control to it.
So, in simple terms BIOS loads and executes
the MBR boot loader.
2. MBR
MBR stands for Master Boot Record.
It is located in the 1st sector of the bootable

disk. Typically /dev/hda, or /dev/sda


MBR is less than 512 bytes in size. This has
three components 1) primary boot loader
info in 1st 446 bytes 2) partition table info in
next 64 bytes 3) mbr validation check in last
2 bytes.
It contains information about GRUB (or LILO
in old systems).
So, in simple terms MBR loads and executes
the GRUB boot loader.
3. GRUB
GRUB stands for Grand Unified Bootloader.
If you have multiple kernel images installed
on your system, you can choose which one to
be executed.
GRUB displays a splash screen, waits for few
seconds, if you dont enter anything, it loads
the default kernel image as specified in the
grub configuration file.
GRUB has the knowledge of the filesystem
(the older Linux loader LILO didnt
understand filesystem).
Grub configuration file is
/boot/grub/grub.conf (/etc/grub.conf is a link
to this). The following is sample grub.conf of
CentOS.
#boot=/dev/sda
default=0
timeout=5

splashimage=(hd0,0)/boot/grub/splash.xpm.
gz
hiddenmenu
title CentOS (2.6.18-194.el5PAE)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-194.el5PAE
ro root=LABEL=/
initrd /boot/initrd-2.6.18194.el5PAE.img
As you notice from the above info, it contains
kernel and initrd image.
So, in simple terms GRUB just loads and
executes Kernel and initrd images.
4. Kernel
Mounts the root file system as specified in
the root= in grub.conf
Kernel executes the /sbin/init program
Since init was the 1st program to be
executed by Linux Kernel, it has the process
id (PID) of 1. Do a ps -ef | grep init and
check the pid.
initrd stands for Initial RAM Disk.
initrd is used by kernel as temporary root file
system until kernel is booted and the real
root file system is mounted. It also contains
necessary drivers compiled inside, which

helps it to access the hard drive partitions,


and other hardware.
5. Init
Looks at the /etc/inittab file to decide the
Linux run level.
Following are the available run levels
0 halt
1 Single user mode
2 Multiuser, without NFS
3 Full multiuser mode
4 unused
5 X11
6 reboot
Init identifies the default initlevel from
/etc/inittab and uses that to load all
appropriate program.
Execute grep initdefault /etc/inittab on your
system to identify the default run level
If you want to get into trouble, you can set
the default run level to 0 or 6. Since you
know what 0 and 6 means, probably you
might not do that.
Typically you would set the default run level
to either 3 or 5.
6. Runlevel programs
When the Linux system is booting up, you
might see various services getting started.
For example, it might say starting sendmail
. OK. Those are the runlevel programs,
executed from the run level directory as
defined by your run level.

Depending on your default init level setting,


the system will execute the programs from
one of the following directories.
Run level 0 /etc/rc.d/rc0.d/
Run level 1 /etc/rc.d/rc1.d/
Run level 2 /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 level 6 /etc/rc.d/rc6.d/
Please note that there are also symbolic links
available for these directory under /etc
directly. So, /etc/rc0.d is linked to
/etc/rc.d/rc0.d.
Under the /etc/rc.d/rc*.d/ directories, you
would see programs that start with S and K.
Programs starts with S are used during
startup. S for startup.
Programs starts with K are used during
shutdown. K for kill.
There are numbers right next to S and K in
the program names. Those are the sequence
number in which the programs should be
started or killed.
For example, S12syslog is to start the syslog
deamon, which has the sequence number of
12. S80sendmail is to start the
sendmail daemon, which has the sequence
number of 80. So, syslog program will be
started before sendmail.
There you have it. That is what happens during
the Linux boot process.

Standard run levels for Red Hat based


distributions
Run
Mode
Action
Level
0
Halt
Shuts down system
Does not configure network
Single-User
1
interfaces, start daemons,
Mode
or allow non-root logins
Does not configure network
Multi-User
2
interfaces or start
Mode
daemons.
Multi-User
3
Mode with
Starts the system normally.
Networking
4
Undefined
Not used/User-definable
As runlevel 3 + display
5
X11
manager(X)
6
Reboot
Reboots the system

Linux Directory Structure (File System Structure)


Explained

1. / Root
Every single file and directory starts from the
root directory.
Only root user has write privilege under this
directory.
Please note that /root is root users home
directory, which is not same as /.
2. /bin User Binaries
Contains binary executables.

Common linux commands you need to use in


single-user modes are located under this
directory.
Commands used by all the users of the
system are located here.
For example: ps, ls, ping, grep, cp.
3. /sbin System Binaries
Just like /bin, /sbin also contains binary
executables.
But, the linux commands located under this
directory are used typically by system
aministrator, for system maintenance
purpose.
For example: iptables, reboot, fdisk, ifconfig,
swapon
4. /etc Configuration Files
Contains configuration files required by all
programs.
This also contains startup and shutdown shell
scripts used to start/stop individual
programs.
For example: /etc/resolv.conf,
/etc/logrotate.conf
5. /dev Device Files
Contains device files.
These include terminal devices, usb, or any
device attached to the system.
For example: /dev/tty1, /dev/usbmon0
6. /proc Process Information

Contains information about system process.


This is a pseudo filesystem contains
information about running process. For
example: /proc/{pid} directory contains
information about the process with that
particular pid.
This is a virtual filesystem with text
information about system resources. For
example: /proc/uptime
7. /var Variable Files
var stands for variable files.
Content of the files that are expected to grow
can be found under this directory.
This includes system log files (/var/log);
packages and database files (/var/lib); emails
(/var/mail); print queues (/var/spool); lock
files (/var/lock); temp files needed across
reboots (/var/tmp);
8. /tmp Temporary Files
Directory that contains temporary files
created by system and users.
Files under this directory are deleted when
system is rebooted.
9. /usr User Programs
Contains binaries, libraries, documentation,
and source-code for second level programs.
/usr/bin contains binary files for user
programs. If you cant find a user binary
under /bin, look under /usr/bin. For example:
at, awk, cc, less, scp

/usr/sbin contains binary files for system


administrators. If you cant find a system
binary under /sbin, look under /usr/sbin. For
example: atd, cron, sshd, useradd, userdel
/usr/lib contains libraries for /usr/bin and
/usr/sbin
/usr/local contains users programs that you
install from source. For example, when you
install apache from source, it goes under
/usr/local/apache2
10. /home Home Directories
Home directories for all users to store their
personal files.
For example: /home/john, /home/nikita
11. /boot Boot Loader Files
Contains boot loader related files.
Kernel initrd, vmlinux, grub files are located
under /boot
For example: initrd.img-2.6.32-24-generic,
vmlinuz-2.6.32-24-generic
12. /lib System Libraries
Contains library files that supports the
binaries located under /bin and /sbin
Library filenames are either ld* or lib*.so.*
For example: ld-2.11.1.so, libncurses.so.5.7
13. /opt Optional add-on Applications
opt stands for optional.
Contains add-on applications from individual
vendors.

add-on applications should be installed under


either /opt/ or /opt/ sub-directory.
14. /mnt Mount Directory
Temporary mount directory where sysadmins
can mount filesystems.
15. /media Removable Media Devices
Temporary mount directory for removable
devices.
For examples, /media/cdrom for CD-ROM;
/media/floppy for floppy drives;
/media/cdrecorder for CD writer
16. /srv Service Data
srv stands for service.
Contains server specific services related
data.
For example, /srv/cvs contains CVS related
data.
questions:
boot process of linux
file structure of linux
diff btw linux windows and unix
what is kernel,shell
types of shell
command to the shell on which you are
working(echo $shell)
command-cat
,touch

,top(the top program provides a dynamic real


time view

You might also like