Linux Administration: Unit 1 Booting & Shutting Down

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 17
At a glance
Powered by AI
The key takeaways from the document are the Linux booting process, boot loaders like GRUB and LILO, the init process, runlevels, and managing services.

The main stages in the Linux booting process are POST, BIOS, boot loader (GRUB/LILO), kernel, initrd, init, mounting the root filesystem, and starting init scripts.

The init process is the first user-space process that runs. It reads the /etc/inittab file to determine the default runlevel and starts scripts in the appropriate runlevel directories to start services.

Linux Administration

Unit 1
Booting & Shutting Down

Compiled by Bhavesh Shah

Overview

Booting Process

Boot Loaders

GRUB

LILO

Bootstrapping

INIT process

RC scripts

Enabling & Disabling Services


Compiled by Bhavesh Shah

Booting Process
POST BIOS Active Partition MBR BOOT
Loader Kernel initrd init insertion of kernel
modules to support the most essential hardware
needed for booting mounting of root file system from
the secondary storage /etc directory init in /etc
fstab initab rc.sysinit inittab init levels
rcN.d Naming convention (K/S),2 digit integer
chronological sequence (N in rcN.d stands for run
level bet 0 and 6)

Compiled by Bhavesh Shah

Booting of a Linux System: Pictorial


View

Compiled by Bhavesh Shah

Bootloaders

The boot loader is the first software program that


runs when a computer starts
It is responsible for handing over control of the
system to the operating system
The boot loader resides in the Master Boot Record
(MBR) of the disk, and it knows how to get the
operating system up and running
The main choices that come with Linux
distributions are GRUB (Grand Unified Bootloader)
& LILO (Linux Loader)
GRUB is the most common boot loader that ships
with the newer distributions of Linux and has a lot
more features than LILO
Compiled by Bhavesh Shah

GRUB

Most modern Linux distributions use GRUB as the default


boot loader during installation
GRUB is the default boot loader for Fedora, Red Hat
Enterprise Linux (RHEL), OpenSUSE, Mandrake, Ubuntu,
and a host of other Linux distributions
GRUB aims to be compliant with the Multiboot Specification
and offers many features like

GRUB provides a true command-based, pre-OS environment


on x86 machines to allow maximum flexibility in loading
operating systems with certain options or gathering
information about the system
GRUB supports Logical Block Addressing (LBA) mode,
needed to access many IDE and all SCSI hard disks
GRUB's configuration file is read from the disk every time the
system boots, preventing you from having to write over the
MBR every time you change the boot options
Compiled by Bhavesh Shah

GRUB (contd...)

Most Linux distributions will give you a choice to install


& configure the boot loader during the initial operating
system installation
The GRUB boot process happens in 2 stages

Stage 1 in this stage the GRUB is embedded in the


Master Boot Record (MBR) of the disk or in the boot
sector of a partition. The stage 1 image can either load
stage 1.5 or stage 2 directly
Stage 2 consists of two steps. In step 1 (stage 1.5),
the semantics of file system are mapped and helps to
locate stage 2 image file. Step 2 (stage 2) contains the
actual code to load the kernel that boots the OS, it
displays the boot menu, & it also contains the GRUB
shell from which GRUB commands can be entered
Compiled by Bhavesh Shah

GRUB (contd...)

Compiled by Bhavesh Shah

LILO

LILO, short for Linux Loader, is a boot manager


It allows you to boot multiple operating systems, provided each
system exists on its own partition
Configuring LILO is straightforward: A configuration file (/etc/lilo.conf)
specifies which partitions are bootable &, if a partition is Linux, which
kernel to load
LILO is a two-stage boot loader

The first stage loads LILO itself into memory & prompts you for
booting instructions with the lilo: prompt or a colorized boot menu
Once you select the OS to boot & press enter, LILO enters the
second stage, booting the Linux operating system

If you are familiar with the Microsoft Windows boot process, you can
think of LILO as comparable to the OS loader (NTLDR)
Similarly, the LILO configuration file, /etc/lilo.conf, is comparable to
BOOT.INI (which is typically hidden from view)
Compiled by Bhavesh Shah

Bootstrapping

The process of bootstrapping is as follows

Kernel Loading

Once GRUB has started & the operating system is


selected to boot, the first thing to get loaded is the
kernel

At this point, no operating system exists in memory &


PCs have no easy way to access all of their memory

Thus, the kernel must load completely into the first


megabyte of available RAM. In order to accomplish
this, the kernel is compressed

The head of the file contains the code necessary to


bring the CPU into protected mode (thereby removing
the memory restriction) and decompress the
remainder of the kernel
Compiled by Bhavesh Shah

Bootstrapping (contd...)

Kernel Execution

With the kernel in memory, it can begin executing


It knows only whatever functionality is built into it,
which means any parts of the kernel compiled as
modules are useless at this point
At the very minimum, the kernel must have enough
code to set up its virtual memory subsystem and root
file system (usually, the ext3 file system)
Once the kernel has started, a hardware probe
determines what device drivers should be initialized.
From here, the kernel can mount the root file system.
(You could draw a parallel of this process to that of
Windows being able to recognize and access its C
drive.)
The kernel mounts the root file system and starts a
program called init
Compiled by Bhavesh Shah

The INIT process

The init process is the first non-kernel process that is started, and,
therefore, it always gets the process ID number of 1
init reads its configuration file, /etc/inittab, and determines the
runlevel where it should start
A runlevel of initdefault is selected if it exists; otherwise, you are
prompted to supply a runlevel value
The runlevel values are as follows:
0
1
2
3
4
5
6

Halt the system


Enter single-user mode
Multiuser mode, but without Network File System (NFS)
Full multiuser mode (normal)
Unused
Same as runlevel 3, except using an X Window System login rather
than a text based login
Reboot the system
Compiled by Bhavesh Shah

RC scripts

The /etc/inittab file specifies which scripts to run when runlevels


change
These scripts are responsible for either starting or stopping the
services that are particular to the runlevel
Because of the number of services that need to be managed, rc
scripts are used
The main one, /etc/rc.d/rc, is responsible for calling the appropriate
scripts in the correct order for each runlevel
For each runlevel, a subdirectory exists in the /etc/rc.d directory
These runlevel subdirectories follow the naming scheme of rc X .d,
where X is the runlevel

For example, all the scripts for runlevel 3 are in /etc/rc.d/rc3.d

The symbolic links are prefixed with an S, if the script is to start a


service, or with a K, if the script is to stop (or kill) a service

Note that these two letters are case sensitive


Compiled by Bhavesh Shah

RC scripts (contd...)
The /etc/rc.d/rc3.d directory

Compiled by Bhavesh Shah

Enabling & Disabling Services

At times, you may find that you simply dont need a particular
service to be started at boot time
This is especially important if you are configuring the system as a
server & need only specific services & nothing more
You can cause a service not to be started by simply renaming the
symbolic link in a particular runlevel directory
Once you are comfortable working with the command line, youll
quickly find that it is easy to enable or disable a service
The startup runlevels of the service/program can also be managed
using the chkconfig utility
To completely disable a service, you must, at a minimum, know the
name of the service
You can then use the chkconfig tool to permanently turn it off,
thereby preventing it from starting in all runlevels

Compiled by Bhavesh Shah

Enabling Service

Disabling Service

Compiled by Bhavesh Shah

Questions?
Please don't keep it to yourself ?

Compiled by Bhavesh Shah

You might also like