0% found this document useful (0 votes)
58 views

Linux RHEL6 Starting Up and Shutting Down

The document discusses the Linux boot process and shutting down. It covers the BIOS, MBR, bootloaders like GRUB and LILO, the kernel, init program, runlevels, RC scripts, and services. The boot process initializes hardware and loads the operating system. Shutdown terminates services and halts or reboots the system. Runlevels and RC scripts control which services start at each system state.

Uploaded by

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

Linux RHEL6 Starting Up and Shutting Down

The document discusses the Linux boot process and shutting down. It covers the BIOS, MBR, bootloaders like GRUB and LILO, the kernel, init program, runlevels, RC scripts, and services. The boot process initializes hardware and loads the operating system. Shutdown terminates services and halts or reboots the system. Runlevels and RC scripts control which services start at each system state.

Uploaded by

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

Linux administration

CHAPTER 3: BOOTING AND SHUTTING DOWN


Topics we would cover…
• Boot Process
• BIOS
• MBR
• Bootloaders
• Kernel
• Bootstrapping
• The init program
• Runlevels
• RC scripts
• Enabling and disabling services
• Shutting down
What does Booting mean?
• In the simplest terms, booting means ‘Initializing the
Computer System’.
• Steps while booting:
 POST
 Locating and Initializing of peripherals
 Loading and starting of the OS.
• Example: Booting of modern computers
Why understand the boot process?
• Absolute control
• Customization
• Troubleshooting
Steps in the Boot Process
Boot process and BIOS
• When you turn on your PC, its runs a program called BIOS.
• Only way to communicate with the system components.
• Stored on EEPROM and it is not writable by the user.
• Functions performed by the BIOS after it loads-
 H/W diagnostics (POST)
 Search the boot drive
 Search for the MBR
 Findthe boot program and give up the control of the boot
process
 Boot program is nothing but the boot loader
• P.S: Booting is derived from the word ‘Bootstrapping’.
MBR
• Master Boot Record
• First 512 bytes of the boot drive
 446 bytes – Boot loader
 64 bytes – Partition table
2 bytes – magic number; used for
error detection.
• MBR code searches for first active
partition.
• Finds the boot loader (LILO or GRUB).
• Passes the control to the boot loader.
• Boot loader loads the O.S.
Boot loaders
• Needs for an OS to start on any standard PC.
• First s/w program to load after the PC starts.
• Responsible for handing over the control of the
system to the OS.
• Resides in MBR.
• Knows how to get the OS up and running.
• Popular loaders are GRUB and LILO
GRUB
• Grand Unified Boot loader.
• Default for most Linux distributions
• Can boot multiple OSs.
• Modular.
• Each stage has its own image file.
• Stage 1
• Stage 1.5 (Optional or depends upon the
system)
• Stage 2.
Stages of GRUB
• STAGE 1:
 Boots up the grub at the first place
 Stored in MBR or boot sector of a partition
 Image file is named stage1.
 It will load stage1.5 or stage2 directly.
• Stage 2:
 Has two images (1.5 and 2)
 Stage 1.5 – bridge between stage1 and stage2
 Stage 1.5 allows the GRUB to access various file systems.
 The image file is named as X_Stage_1_5, where X = file
system
 Will help to locate stage2 image
Stage2 Cont…

• Core of the GRUB


• Contains actual code to load the Kernel which in turn
will load the OS
• Displays boot menu options
• Also contains GRUB shell where commands can be
entered while booting
• Other files like stage2_eltorito is used for booting via CD-
ROM
• Ngrub and pxegrub are used for network boot.
GRUB config file
• Location: /boot/grub/grub.conf
• Stores info about what will be displayed at the boot-time grapgical screen
• Controlls if we can see the graphical screen at all.
GRUB
LILO
• Like GRUB, LILO also allows loading multiple OSs.
• Allows choosing multiple kernel versions for
trying
• Config file: (/etc/lilo.conf)
• Will use the config file for boot menu options
• Loads the kernel and passes the control to it
• Was default loader before.
LILO
Kernel
• Kernel prepares the system memory for use.
• It investigates all the hardware.
• Uncompresses the initrd in ram.
• Mounts it.
• After the kernel has configured all the
system devices and mounted the system
drives, it runs the init command.
The init program
• First non-kernel process with PID = 1
• Reads config file /etc/inittab to determine the default run
level
• In the config file ‘initdefault’ denotes the default run level
• 1st script to be run by the init program is
‘/etc/rc.d/rc.sysinit’
 Starts swap, examines file system and performs other initialization
• Next script is ‘/etc/rc.d/rc’
 Responsible for starting and stopping services when the run level changes
and determining the new run level
 Has sub directories for each run level
 Sub directories contain scripts to start and stop services for that particular run
level
• View the file using
#cat /etc/inittab
Run levels
• They are essential ‘states‘ that allow services to be started
or stopped depending upon the run level you are in.
• /etc/inittab file shows the default run level.
• There are total 7 run levels numbered 0 to 6.
• Changing the system Run level in the inittab file.
• ‘Initdefault’
• Each run level has a directory /etc/rc.d/rc#.d (# is from 0
to 6)
• These directories contain scripts known as RC scripts(Run
Commands).
RC Scripts
• RC scripts are responsible for starting or stopping services depending
upon the run level.
• Huge number of services to be managed and hence RC scripts are
used.
• Subdirectories for each runlevel exist in /etc/rc.d
• These subdirectories contain symbolic links to scripts in /etc/rc.d/init
directory
• Scripts are prefixed with K or S
• Two digit numbers are used to enforce order
• /etc/rc.d/rc invokes the scripts in numerical order
• Scripts starting with K take stop as argument
• Scripts starting with S take start as argument
example

#/etc/rc.d/init.d/saslauthd stop
#/etc/rc.d/init.d/sshd start
Enabling and disabling services
• chkconfig command for service management
• Syntax: chkconfig [option] service_name
Options:
a. --list [name]: Shows the status of the service at each runlevel
E.g. # chkconfig --list sshd
b. --add <name>: Adds a service to be managed by the chkconfig command
E.g. # chkconfig --add sshd
c. --del <name>: Removes a service from being managed by the chkconfig
command
E.g. # chkconfig --del sshd
d. --level <levels>: Enables or disables the service at the given levels
E.g. #chkconfig --level 4 sshd on
e. <name> <on|off|reset> Enables or disables the service at levels 2-5
E.g. #chkconfig sshd on
Contd..

Using service command for service management


Syntax: service <--status-all | service_name CMD>
Examples:
#service sshd status
#service sshd start
#service sshd stop
Shutting down
• Root has the permission to shutdown the server
• When the shutdown command is issued, the following happens:
 Users who are logged in, receive a notice
 Logins after the shutdown command will not be allowed
 SIGTERM is issued to the services
• /sbin/shutdown -h now will shut down the system immediately
• /sbin/shutdown -r now will start the shutdown process and reboot the
system

You might also like