Linux Startup processx

Download Report

Transcript Linux Startup processx

Linux Startup
Process
• Presenter: Dipu Gupta
The Linux Boot Process
• When you press the “On” button on your PC to start it, BIOS starts. The BIOS is the
small chip that has the responsibility of identifying, checking and initializing system
devices such as graphics cards, hard disks, etc.
• To do this the BIOS makes a POST (Power On Self Test) and then checks which drive
to use as the primary boot device and hands over the control of the computer.
• The boot of the operating system starts here, with the boot partition always
located at the same place for all operating systems: track 0, head 0 and cylinder 0.
Then the small program here, which is GRUB (GRand Unified Boot loader) or LILO
(LInux LOader) performs the initialization and boot of the operating system
GRUB
• The GRUB is either in /boot/grub/menu.lst or /boot/boot/menu.lst. A sample
GRUB configuration file is as follows:
default 0
timeout 5
Linux
root (hd0,0)
kernel /vmlinuz-2.6.22-bf2.4 root=/dev/sda0 ro
• GRUB makes a call to the kernel (which is the vmlinuz-2.6.22-bf.2.4 file in the
configuration above) to decompress itself and start.
Kernel
• The kernel is a compressed file and can decompress itself in case of a system call.
• The kernel checks if your graphics card is there and running and if it supports
complex text modes. After that it checks the hardware present on the computer
(hard disks, network cards, TV cards etc.) and loads the relevant drivers.
• The kernel displays all the progress with informative messages during this time,
as you can see in the screenshot.
• After this boot stage the kernel tries to mount the file system. It tries to auto
detect the file system and if it succeeds, carries on. If not, a kernel panic occurs
and the system stops. If not, the kernel finally hands over the remaining job to
the process named init and waits.
Initialization(Init)
•
Init is the first process in the Linux system, with Process ID (PID) 1 and it initializes the rest of
the system.
•
One of the most important concepts in how Linux works are the runlevels. These modes of
operation allow Linux to run in V-style initialization state.
•
We have to understand about the different runlevels to understand the Init process.
•
The runlevels are numbered from 1 to 6 and the corresponding system states are as follows:
-Runlevel 0: shutdown/halt the system
-Runlevel 1: single user mode
-Runlevel 2: multi user mode without network
-Runlevel 3: multi user mode with network
-Runlevel 4: reserved for local use (GUI mode for Slackware only)
-Runlevel 5: graphical user interface (GUI) mode
-Runlevel 6: reboot
Init(Contd.)
•
There are programs that have to be started in each runlevel. These programs are
listed in rcX.d files, where X indicates the runlevel number .
•
/etc/init.d file holds the information to point at these files for the init to look for.
•
When the init process starts, it checks configuration files to carry on its job. First of
all, it looks at the /etc/inittab which tells the init which processes to start. In the
/etc/inittab file is the information about the runlevels. The default runlevel for the
system is indicated by the line id:X:initdefault where X is the runlevel number.
Then the init performs system initialization, named sysinit.
•
•
Depending on the runlevel, init tries to figure out if it is a part of a network. Then it
mounts /proc, where Linux keeps track of various processes and hardware (try cat
/proc/cpuinfo at the command line), and checks the BIOS to align the system with
the BIOS settings such as date and time, and sets the time zone.
Init(Contd.)
•
After that init mounts the swap partition (which Windows users know as pagefile)
as defined in the /etc/fstab.
•
When finished, it goes on to setting the hostname, which is the system's “name” in
the network. After that, it mounts the root file system (/ in Linux notation) and
checks the /etc/fstab again to verify the other file systems if specified.
•
Then it goes on to identify the Plug'n'Play devices in the system and makes the
operating system aware of them by executing some routines.
•
Init finally checks if there are any RAID devices in the system and verifies them.
Reaching the last stages, it mounts all the file systems defined in /etc/fstab.
Logging In
•
•
When all of the above are completed successfully, init executes the /sbin/mingetty
processes, which shows the graphical login screen of the distribution.
Reaching this state means that the system is up and running in graphical user
interface mode and waiting to know which user will log in.
Conclusion
•
This is a step by step walk through of the Linux boot process. We have started from
a basic “power off” state and reached the “graphical user interface” mode
whereby a user can login.