0% found this document useful (0 votes)
18 views23 pages

Linux Adm 3

The document provides an overview of the Linux startup process, including: - The BIOS performs initial hardware checks and loads the boot loader. - The boot loader (GRUB or LILO) loads the Linux kernel and initrd. - The kernel initializes hardware and mounts the root filesystem. - Init reads the /etc/inittab file to determine the default runlevel and starts programs for that runlevel.

Uploaded by

Mark Zuña
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)
18 views23 pages

Linux Adm 3

The document provides an overview of the Linux startup process, including: - The BIOS performs initial hardware checks and loads the boot loader. - The boot loader (GRUB or LILO) loads the Linux kernel and initrd. - The kernel initializes hardware and mounts the root filesystem. - Init reads the /etc/inittab file to determine the default runlevel and starts programs for that runlevel.

Uploaded by

Mark Zuña
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

Welcome to:

Unit 2
Startup and Shutdown

© Copyright IBM Corporation 2006


Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 3.3.3
Unit Objectives
After completing this unit, you should be able to:
• Describe the Linux startup flow
• Configure autostarting services
• Boot Linux in single-user mode
• Perform a proper shutdown of a Linux system

© Copyright IBM Corporation 2006


Linux Startup Flow
power on
Low level initialization of
important hardware (disk,
BIOS cpu, vga adapter...)
Hardware boot

boot loader Usually GRUB or LILO

Linux kernel Full initialization of all


and initrd hardware
Software boot
init Runs boot scripts and
starts system services

system ready ...Have a lot of fun

© Copyright IBM Corporation 2006


Basic Input Output System (BIOS)
• Checks memory and hardware (POST)
• Loads options from nonvolatile memory
– Memory timings
– Order of boot devices
• Checks for boot devices
– Floppy disks
– CD-ROM
– Hard disks
• Loads Master Boot Record of boot device and executes it

© Copyright IBM Corporation 2006


Master Boot Record (MBR)

Master Boot Record (MBR)

• Size: 512 bytes (first sector of hd)


• Addressed by BIOS
• Content:
- 446 bytes program code (to boot
an operating system)
- 64 bytes partition table with
max. 4 entries
- 2 bytes "magic number"
© Copyright IBM Corporation 2006
LILO - Linux Loader
contains the LILO boot
MBR sector (1st stage)
Configuration:
/etc/lilo.conf
addresses "map" (CHS)
LILO boot sector

addresses LILO core (CHS)


"/boot/map" /sbin/lilo

Lilo core LILO 2nd stage - can localize generates /boot/map and
"/boot/boot.b" vmlinuz, initrd and load them writes its address into LILO
(CHS) boot sector

© Copyright IBM Corporation 2006


/etc/lilo.conf
boot=/dev/hda Where to store the 1st stage (MBR)
map=/boot/map Where the map file is stored
install=/boot/boot.b Which 2nd stage boot loader to use
message=/boot/lilo.msg Which message to display
prompt Ask for the OS to load
timeout=50 Timeout for booting in deciseconds (1/10s)
image=/boot/vmlinuz Default OS is a Linux system with kernel
label=linux /boot/vmlinuz
root=/dev/hda5 The root partition to mount is /dev/hda5
append="mem=128M" and it should be mounted read-only
read-only Pass the "mem=128M" option to the kernel
other=/dev/hda1
label=dos This non-Linux operating system is
table=/dev/hda booted when the user enters "dos" at the
LILO prompt.

© Copyright IBM Corporation 2006


GRand Unified Bootloader (GRUB)
• Program stored in MBR (first stage) and in /boot/grub
(1.5th and second stage)
• Understands filesystem structure
– No need to activate a configuration as with LILO
• Configuration file is /boot/grub/menu.lst (linked to
/boot/grub.conf)
• Installed in MBR with grub-install
• When system boots:
– Select predefined OS to boot, or
– Use command language to boot non-predefined OS
– Command language compatible with configuration file
• GRUB additional features:
– MD5 encrypted passwords
– Hiding/Unhiding partitions

© Copyright IBM Corporation 2006


GRUB Startup Sequence

MBR contains stage1

addresses stage1_5
Stage 1 (CHS)

filesystem driver, loads


Stage 1_5 (hd0,3)/grub/stage2

Configuration:
/boot/grub/menu.lst
loads for example
Stage 2 (hd0,3)/vmlinuz or Windows
via "chainloading"

© Copyright IBM Corporation 2006


/boot/grub/grub.conf
or /boot/grub/menu.lst
#boot=/dev/hda
default=0
timeout=5
title Red Hat Enterprise Linux ES (2.6.9-34.EL)
root (hd0,0)
kernel /vmlinuz-2.6.9-34.EL ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.9-34.EL.img

#boot=/dev/hda
default=0
timeout=5
title Fedora Core (2.6.15-1.1955_FC5)
root (hd0,0)
kernel /vmlinuz-2.6.15-1.1955_FC5 ro root=/dev/VolGroup00/LogVol00 rhgb
quiet
initrd /initrd-2.6.15-1.1955_FC5.img

default=0
timeout=8
title SUSE SLES 10
root (hd0,6)
kernel /boot/vmlinuz root=/dev/hda7 selinux=0 resume=/dev/hda6
splash=silent showopts
initrd /boot/initrd

© Copyright IBM Corporation 2006


Starting the Kernel
• Once the kernel is loaded, it is started by the boot loader
• On most architectures (including i386) the kernel is
compressed with a decompress program included
• When the kernel starts, it detects all hardware and switches
the CPU to multitasking, multiuser mode
Inspecting /boot/System.map-2.6.16-rc1-git3-7-default
Loaded 21547 symbols from /boot/System.map-2.6.16-rc1-git3-7-default.
Symbols match kernel version 2.6.16.
No module symbols loaded - kernel modules not enabled.
klogd 1.4.1, log source = ksyslog started.
<5>Linux version 2.6.16-rc1-git3-7-default (geeko@buildhost) (gcc version 4.1.0
20060123 (prerelease) (SUSE Linux)) #1 Mon Jan 30 21:52:12 UTC 2006
<6>BIOS-provided physical RAM map:
<4> BIOS-e820: 0000000000000000 - 000000000009fc00 (usable)
<4> BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved)
<4> BIOS-e820: 00000000000e0000 - 0000000000100000 (reserved)
<4> BIOS-e820: 0000000000100000 - 0000000017ee06c0 (usable)
<4> BIOS-e820: 0000000017ee06c0 - 0000000017ee66c0 (ACPI data)
<4> BIOS-e820: 0000000017ee66c0 - 0000000017eee700 (ACPI NVS)
<4> BIOS-e820: 0000000017eee700 - 0000000018000000 (reserved)
<4> BIOS-e820: 00000000fec00000 - 00000000fec01000 (reserved)
<4> BIOS-e820: 00000000fee00000 - 00000000fee01000 (reserved)
<4> BIOS-e820: 00000000fff80000 - 0000000100000000 (reserved)
<5>0MB HIGHMEM available.
<5>382MB LOWMEM available.
<6>found SMP MP-table at 0009fe00
<7>On node 0 totalpages: 98016

© Copyright IBM Corporation 2006


Initial RAM Disk (initrd)
• An Initial RAM Disk (initrd) is needed if the kernel can't
access the root filesystem without modules (SCSI, LVM,
RAID, ext3, reiser)
• The initrd is loaded into memory by the boot loader
• The initrd contains a linuxrc script that loads the
modules from the RAM disk and mounts the actual root
filesystem
Linux Kernel
initrd

linuxrc
no initrd Kernel
modules

mount actual root fs


© Copyright IBM Corporation 2006
init
•init is started by the kernel after the root filesystem is
mounted
•init reads configuration file /etc/inittab
• Decides on default runlevel if no runlevel is given
• Runlevels have different meaning:
– 0 - System Halt
– S - Single user mode (No scripts run) (SUSE)
– 1 - Single user mode (Some scripts run)
– 2 - Local multiuser without network
– 3 - Full multiuser with network
– 4 - Not used
– 5 - Full multiuser with network and xdm (GUI)
– 6 - System Reboot
•init will start all programs for that runlevel

Note: Once the system has started, you can switch runlevels
with init runlevel or telinit runlevel
© Copyright IBM Corporation 2006
/etc/inittab (RHEL/Fedora/SLES)
RHEL, Fedora SLES
The default runlevel is 3
# Default runlevel # Default runlevel
id:3:initdefault:
id:3:initdefault:
Always run
# System initialization. /etc/rc.d/rc.sysinit (RHEL)
si::sysinit:/etc/rc.d/rc.sysinit # System initialization.
si::bootwait:/etc/init.d/boot
or /etc/init.d/boot (SUSE)
l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2 l0:0:wait:/etc/init.d/rc 0
l3:3:wait:/etc/rc.d/rc 3 l1:1:wait:/etc/init.d/rc 1
Run /etc/rc.d/rc (RHEL) or
l4:4:wait:/etc/rc.d/rc
l5:5:wait:/etc/rc.d/rc
4
5
l2:2:wait:/etc/init.d/rc 2 /etc/init.d/rc (SUSE) with
l6:6:wait:/etc/rc.d/rc 6 l3:3:wait:/etc/init.d/rc 3 the runlevel as
#l4:4:wait:/etc/init.d/rc 4
# Trap CTRL-ALT-DELETE l5:5:wait:/etc/init.d/rc 5 parameter
ca::ctrlaltdel:/sbin/shutdown -t3 -r l6:6:wait:/etc/init.d/rc 6
now
# Run gettys in standard runlevels # Trap CTRL-ALT-DELETE
1:2345:respawn:/sbin/mingetty tty1 ca::ctrlaltdel:/sbin/shutdown -r -
Trap the three-finger salute
2:2345:respawn:/sbin/mingetty tty2 t4 now CTRL-ALT-DELETE
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6
# Run gettys in standard runlevels Allow users to log in on six
1:2345:respawn:/sbin/mingetty --
# Run xdm in runlevel 5
noclear tty1 virtual consoles (Virtual
x:5:respawn:/etc/X11/prefdm - 2:2345:respawn:/sbin/mingetty tty2 consoles can be
nodaemon 3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4 activated with Alt-F1
5:2345:respawn:/sbin/mingetty tty5 through Alt-F6)
6:2345:respawn:/sbin/mingetty tty6

Start a graphical login


prompt (xdm, kdm or
gdm) in runlevel 5

© Copyright IBM Corporation 2006


Starting Services (System V init Style)
/etc/rc.d/rc 3
init (RHEL/Fedora)
/etc/init.d/rc 3 (SUSE)

/etc/rc.d/rc3.d/K* stop
/etc/inittab

/etc/rc.d/rc3.d/S* start

(Symlinks to the actual


start/stop script)

# ls -l /etc/rc.d/rc3.d
lrwxrwxrwx 1 root root 24 Mar 15 10:47 K02NetworkManager ->
../init.d/NetworkManager
lrwxrwxrwx 1 root root 14 Mar 15 11:45 K05innd -> ../init.d/innd
lrwxrwxrwx 1 root root 19 Mar 15 10:45 K05saslauthd -> ../init.d/saslauthd
. . .
lrwxrwxrwx 1 root root 15 Mar 15 10:48 K15httpd -> ../init.d/httpd
lrwxrwxrwx 1 root root 15 Mar 15 11:45 K16rarpd -> ../init.d/rarpd
. . .

© Copyright IBM Corporation 2006


Configuring Services per Runlevel
• Use chkconfig to create the appropriate K- and S- links
for each service

# chkconfig --list
...
acpid 0:off 1:off 2:off 3:off 4:off 5:off 6:off
atd 0:off 1:off 2:on 3:on 4:off 5:on 6:off
...
# chkconfig acpid on
# chkconfig --list
...
acpid 0:off 1:off 2:on 3:on 4:off 5:on 6:off
atd 0:off 1:off 2:on 3:on 4:off 5:on 6:off
...

© Copyright IBM Corporation 2006


Starting and Stopping Services Manually
• Scripts in init.d directory can be used to start/stop services
manually
– On RHEL/Fedora, the service command calls this script
– On SUSE, rc service is a symlink to the init.d script
• Default options: start, stop, status, restart
• Other options may also be available

RHEL/Fedora # service atd restart


Stopping atd: [ OK ]
Starting atd: [ OK ]

SLES # rcatd restart


Shutting down service at daemon done
Starting service at daemon done

© Copyright IBM Corporation 2006


Booting Linux in Single-User Mode
• Single-User Mode
– No networking (so no incoming hackers)
– No services being started
– No root password being asked (RHEL/Fedora)
• Very useful for system maintenance
• To start from LILO: add "single" parameter to boot-prompt
LILO
For Linux, type linux, for Windows, type win
Boot: linux single

• To start from GRUB: add "single" to the "kernel" line of the


corresponding menu entry
GRUB
[Minimal BASH-like line editing is supported. For the first word, TAB lists
possible command completions. Anywhere else TAB list the possible completion of
a device/filename. ESC at any time cancels. ENTER at any time accepts your
change.]
grub append: ro root=/dev/VolGroup00/LogVol00 rhgb
quiet single

© Copyright IBM Corporation 2006


Shutting Down a Linux System
• DO NOT switch power off to shut down
• Use shutdown command or Ctrl-Alt-Delete
– Warns users
– Stops all running processes
– Unmounts filesystems
– Does an orderly shutdown
– Reboots if necessary
• Example:
– To reboot: shutdown -r now, reboot, or init 6
– To halt: shutdown -h now, halt, init 0, or
poweroff
• Some display managers allow a user to perform a shutdown
as well

© Copyright IBM Corporation 2006


Checkpoint
1. Name the four steps that form the startup order of a Linux
system:

2. How would you select a graphical login screen (xdm, kdm


or gdm)?

© Copyright IBM Corporation 2006


Checkpoint Solutions
1. Name the four steps that form the startup order of a Linux
system:

BIOS, Boot Loader, Linux, init

2. How would you select a graphical login screen (xdm, kdm


or gdm)?

By setting runlevel 5 as the default runlevel in


/etc/inittab

© Copyright IBM Corporation 2006


Exercise 2: Startup and Shutdown

What you will do in this exercise:


• Choose between a graphical and a
text-based login screen by changing
the runlevel of a system
• Boot a Linux system in single user
mode
• Use runlevel editors

© Copyright IBM Corporation 2006


Unit Summary

• The Linux startup flow is as follows:


– When power is switched on, the BIOS is loaded
– BIOS loads MBR and executes it
– MBR contains a boot loader (LILO or GRUB), which loads the Linux
kernel and starts it
– The boot loader may also load an initrd (Initial RAM disk)
– If an initrd is loaded, the kernel starts linuxrc to load modules and
mount the root filesystem - otherwise the kernel can mount the root
filesystem directly
– The first process started is init
– init starts the rest of the processes
• Booting in single user mode is done from the LILO prompt or by editing
the GRUB description
• Shutting down a Linux system is done with the shutdown command or
with Ctrl-Alt-Delete

© Copyright IBM Corporation 2006

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy