+ All Categories
Home > Documents > LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

Date post: 03-Jun-2018
Category:
Upload: ghodghod123
View: 232 times
Download: 0 times
Share this document with a friend

of 20

Transcript
  • 8/12/2019 LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

    1/20

    Linux Junior Level Administration - LPI 102

    5 - 1 2004, SaigonCTT All rights reservedLast updated: 26 December 2003

    Boot, InitializationShutdown and Runlevels

    Chapter 5

  • 8/12/2019 LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

    2/20

    5 - 2 Last updated: 26 December 2003

    Objectives

    giving commands to the boot loader.

    giving options to the kernel at boot time.

    checking the events in the log files.

    changing to single user mode. shutdown or rebooting the system.

    alert users before switching runlevel.

    setting the default runlevel.

  • 8/12/2019 LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

    3/20

    5 - 3 Last updated: 26 December 2003

    Boot stages

    1. BIOS Stage

    BIOS checks the system (POST - Power On Self Test)

    2. Bootloader Stage

    The bootloader loads the second stage into memory

    3. Kernel Stage

    The Kernel is loaded in to memory

    4. Init Stage init load all services and user space tools and mounts all

    from /etc/fstab

  • 8/12/2019 LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

    4/20

    5 - 4 Last updated: 26 December 2003

    Demo pictures

    GRUB LILO

  • 8/12/2019 LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

    5/20

    5 - 5 Last updated: 26 December 2003

    Giving kernel options to the bootloader

    The list of options supported by the current kernel can

    be found in/usr/src/linux/Documentation/kernel-parameters.txt

    The kernel options used are always readable from the

    file/proc/cmdline

    Example: options given to LILO bootloaders

    LILO boot: linux aha152x=0x300,10,7

    Means that the Adaptec SCSI adapter is at address 0x300 IRQ 10and SCSI-ID 7

  • 8/12/2019 LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

    6/20

    5 - 6 Last updated: 26 December 2003

    Giving kernel options to the bootloader

    Kernel options that must always be used can be

    entered in the bootloader's configuration file.

    LILO

    append=vga=791 hdc=ide-scsi splash=verbose acpi=off

    GRUBkernel (hd0,2)/boot/vmlinuz.2.4.20 root=/dev/hda3

    vga=791 splash=verbose

  • 8/12/2019 LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

    7/205 - 7 Last updated: 26 December 2003

    /etc/modules.conf(or conf.modules)

    Kernels can be of 2 types:

    Monolithic: All device drivers are compiled into the kernel.

    Modular: Some device drivers are compiled as loadablemodules.

    Module configuration file: New name: /etc/modules.conf or/etc/modprobe.conf

    Old name: /etc/conf.modules

    In some other distributions,

    find in the /etc/modprobe.d/ directory

  • 8/12/2019 LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

    8/205 - 8 Last updated: 26 December 2003

    Boot Log files

    As the kernel boots it saves its log messages in an

    internal buffer which is readable with the commanddmesg

    most of the system messages including kernel

    messages are stored in /var/log/messages

    The command

    tail -f /var/log/messages allows you to read the last 10 lines of the log file, refreshing it when

    having new message(s).

  • 8/12/2019 LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

    9/205 - 9 Last updated: 26 December 2003

    LiLo configuration file

    This file is read by the LiLo boot loader.

    $cat /etc/lilo.conf

    prompt

    timeout=50

    default=linux

    boot=/dev/sda

    map=/boot/map

    image=/boot/vmlinuz-2.4.20-8

    label=linux

    initrd=/boot/initrd-2.4.20-8.img

    read-only

    append="root=LABEL=/"

  • 8/12/2019 LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

    10/205 - 10 Last updated: 26 December 2003

    Grub configuration file

    This file is read by the Grub boot loader.

    Location: /boot/grub/grub.conf

    /etc/grub.conf

    /boot/grub/menu.lst

    $ cat /etc/grub.conf

    default=0

    timeout=10

    splashimage=(hd0,0)/grub/splash.xpm.gztitle Red Hat Linux (2.4.20-8)

    root (hd0,0)

    kernel /vmlinuz-2.4.20-8 ro root=LABEL=/

    initrd /initrd-2.4.20-8.img

  • 8/12/2019 LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

    11/205 - 11 Last updated: 26 December 2003

    Runlevels

    Runlevel Description

    0 Shutdown

    1 Single user mode

    2 Multi-user mode (without Network)

    3 Full multi-user mode4 unused

    5 Full multi-user and GUI mode (redhat)

    6 Reboot

    The default runlevel is defined in /etc/inittab

    id:5:initdefault

    Will start the system in runlevel 5

  • 8/12/2019 LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

    12/205 - 12 Last updated: 26 December 2003

    The /etc/rc#.ddirectory

    rc.sysinit The startup script launched by init at boot time.

    rc.localA script for local startup customizations, started

    automatically after the system is running.

    rc A script used to change runlevels.

    rc[0-6].dDirectories containing symlinks to scripts in/etc/init.d

  • 8/12/2019 LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

    13/205 - 13 Last updated: 26 December 2003

    Displaying the current runlevel

    Find the current and previous system runlevel.

    Example

    # runlevel

    runlevelN3

    The command runlevel displays the Previous ('N' if None) and thecurrent

    The previous runlevel was None (After Booting) and present: 3

    runlevel

  • 8/12/2019 LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

    14/205 - 14 Last updated: 26 December 2003

    Changing the runlevel

    Changes the current runlevel.

    In some dist. /sbin/telinitis linked to/sbin/init.

    Example

    # init 6

    restart system.# init 1

    change to single mode.

    telinit

  • 8/12/2019 LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

    15/205 - 15 Last updated: 26 December 2003

    /etc/inittabfile format

    Each line starting with '#' is a comment.

    Each entry uses one line.

    Each entry's syntax is as follows:

    id:runlevels:action:process

  • 8/12/2019 LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

    16/205 - 16 Last updated: 26 December 2003

    Shutting down the system properly

    Before the system is turned off, it needs:

    shut down every current runlevel service properly;

    unmount all filesystems

    Shutdown

    init 0

    shutdown -hnow

    halt

    poweroff

    Reboot

    init 6

    shutdown -rnow

  • 8/12/2019 LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

    17/205 - 17 Last updated: 26 December 2003

    shutdowncommand

    bring the systemdown.

    Options

    shutdown [options] time

    -c Cancels a shutdown

    -f Will not run fsck on the reboot

    -F This WILL run fsck on reboot

    -h Halts system after shutdown

    -k Sends warning / does not shutdown

    -n Shuts down without calling init

    -r Reboots, does not halt

    -t {Seconds}Delay time after killing process (before init)

  • 8/12/2019 LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

    18/205 - 18 Last updated: 26 December 2003

    Summary

    giving commands to the boot loader.

    giving options to the kernel at boot time.

    checking the events in the log files.

    changing to single user mode. shutdown or rebooting the system.

    alert users before switching runlevel.

    setting the default runlevel.

  • 8/12/2019 LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

    19/205 - 19 Last updated: 26 December 2003

    Question & Answer

  • 8/12/2019 LPI 1.00 101 05-Boot Initialization Shutdown and Runlevels

    20/205 20 Last updated: 26 December 2003


Recommended