The Linux Boot Process

Kernel:

Services provided by the OS and Kernel:

Boot Process

This is the process of bringing a portion of the OS into main memory and then having the processor execute it.

Why? Because the Operating System is not available or running yet.


Overview of Steps to boot the system:


The first step in the boot process: Loading and initializing the kernel

Turning on the computer: The BIOS

MBR 1st Primary Partition 2nd Primary Partition Extended Partitin Logical Partition

Note: The boot sector is the first sector on a floppy disk.  On a hard disk it is the first sector of a partition.


Using the Windows or OS/2 boot loader

Booting Linux using the Windows 2000 or NT boot loader -- This works with NTFS filesystem.

      # cd /etc
      # cp lilo.conf.anaconda lilo.conf
      # vi lilo.conf
      
modify this line from

      boot=/dev/hda
      
to

      boot=/dev/hda2
      
Execute the lilo command to write your changes
 
      # lilo
      
  • Grab the first 512 bytes of the root partition and save it to a file. (If you have a /boot partition, dd the first 512 bytes of that partition)
          # dd if=/dev/hda2 of=bootsect.lnx bs=512 count=1
          
  • copy the file to a floppy so you can eventually move it to your Windows system partition (containing ntldr and ntdetect.com).
          # mount -t msdos /dev/fd0 /mnt/floppy
          # cp bootsect.lnx /mnt/floppy
          # umount /mnt/floppy
          
  • Boot your Windows partition and modify the Windows boot.ini by adding a line at the bottom of that file for Linux.
          C:\bootsect.lnx="Linux"
          
  • Copy the bootsect.lnx file off the floppy to the Windows system partition, reboot and choose your OS.
  • LILO (LInux LOader) boot loader

    Other LILO details

    Grub

    Kernel Initialization

    Initial ramdisk (initrd)

    Back to the kernel

    The second step in the boot process: Init

    init -- Process Id 

    System Initialization Scripts:


    Init config file: /etc/inittab

    The scripts are found in /etc/rc.d/rcN.d where N is the run level number.

    To Deactivate Starting X on Boot

    Why deactivate X logon?

    How to deactivate the X login screen

    NOTE: Always shutdown your computer before powering off!

    init: The Finer Points

    init reads the file /etc/inittab, which tells it what to do. To examine the inittab man page type:

    % man 5 inittab

    The inittab file contains entries with four fields:

    1: id field

    2: run-level field
    3:2345:respawn:/sbin/mingetty tty3
      
    3: action field
    3:2345:respawn:/sbin/mingetty tty3
      

    4: process Field

    What happens when init starts: review

    The run-level scripts

    # ls -l /etc/rc.d/rc3.d | grep S

    lrwxrwxrwx 1 root root 17 Aug 10 06:50 S10network -> ../init.d/network
    lrwxrwxrwx 1 root root 17 Aug 10 06:55 S11portmap -> ../init.d/portmap
    lrwxrwxrwx 1 root root 16 Sep 26 11:19 S18autofs -> ../init.d/autofs
    lrwxrwxrwx 1 root root 16 Aug 10 06:50 S30syslog -> ../init.d/syslog

    Lets examine the file S10network:

    /etc/rc.d/init.d/network start

    Configuring LILO

    $ cat /etc/lilo.conf



    *The initrd entry is needed for systems with SCSI disks. The SCSI device drivers must be installed in order for the kernel to read the disk!

    The /etc/lilo.conf on a dual-boot system is identical except for the following three lines appended to the bottom of the file:

    other=/dev/sda2
        optional
        label=win2k

    Configuring GRUB

    $ cat /boot/grub/grub.conf

    Forgot to tell grub to boot off the right disk?

    If you forgot to install grub on the MBR or told it to look at the wrong boot drive ...

    chroot /mnt/sysimage

    grub-install /dev/sda

    exit exit

    Booting Single-User

    At the LILO prompt:

    LILO: linux single
    or
    LILO: linux -s

    From GRUB splash screen:

    What is single user mode anyway?

    Multiuser operation

    BSD versus Sys V systems

    Shutdown of your machine

    There are a number of ways to shutdown you Linux machine. Here is a sampling:

    In older versions of Unix/Linux this was not the best way to shutdown a machine because processes were not allowed to exit cleanly.

    	# /sbin/halt

    # /sbin/poweroff

    Users are notified, processes are notified (and sent a SIGTERM), logins are blocked

    	# /sbin/shutdown -h now
    	# /sbin/shutdown -h +5 "going down for maintenance in 5 minutes... "
    	# /sbin/shutdown -r +5 "rebooting to clear hung mounts in 5 minutes... "
    	# /sbin/init 0	
    	# /sbin/init 6

    # /sbin/reboot

    Note: