unit1c booting

17
Linux Administration Unit 1 Booting & Shutting Down Compiled by Bhavesh Shah

Upload: swapnil-sharma

Post on 17-Nov-2015

247 views

Category:

Documents


2 download

DESCRIPTION

jai ho

TRANSCRIPT

  • Linux AdministrationUnit 1Booting & Shutting DownCompiled by Bhavesh Shah

    Compiled by Bhavesh Shah*

  • OverviewBooting ProcessBoot LoadersGRUBLILOBootstrappingINIT processRC scriptsEnabling & Disabling ServicesCompiled by Bhavesh Shah

    Compiled by Bhavesh Shah*

  • Booting ProcessPOST BIOS Active Partition MBR BOOTLoader Kernel initrd init insertion of kernelmodules to support the most essential hardwareneeded for booting mounting of root file system fromthe 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 runlevel bet 0 and 6)Compiled by Bhavesh Shah

    Compiled by Bhavesh Shah

  • Booting of a Linux System: Pictorial ViewCompiled by Bhavesh Shah

    Compiled by Bhavesh Shah

  • Bootloaders The boot loader is the first software program that runs when a computer startsIt is responsible for handing over control of the system to the operating systemThe boot loader resides in the Master Boot Record (MBR) of the disk, and it knows how to get the operating system up and runningThe 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 LILOCompiled by Bhavesh Shah

    Compiled by Bhavesh Shah*

  • GRUBMost modern Linux distributions use GRUB as the default boot loader during installationGRUB is the default boot loader for Fedora, Red Hat Enterprise Linux (RHEL), OpenSUSE, Mandrake, Ubuntu, and a host of other Linux distributionsGRUB aims to be compliant with the Multiboot Specification and offers many features likeGRUB 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 systemGRUB supports Logical Block Addressing (LBA) mode, needed to access many IDE and all SCSI hard disksGRUB'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

    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 installationThe GRUB boot process happens in 2 stagesStage 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 directlyStage 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

    Compiled by Bhavesh Shah*

  • GRUB (contd...)Compiled by Bhavesh Shah

    Compiled by Bhavesh Shah*

  • LILOLILO, short for Linux Loader, is a boot managerIt allows you to boot multiple operating systems, provided each system exists on its own partitionConfiguring LILO is straightforward: A configuration file (/etc/lilo.conf) specifies which partitions are bootable &, if a partition is Linux, which kernel to loadLILO is a two-stage boot loaderThe first stage loads LILO itself into memory & prompts you for booting instructions with the lilo: prompt or a colorized boot menuOnce 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

    Compiled by Bhavesh Shah*

  • BootstrappingThe process of bootstrapping is as followsKernel LoadingOnce GRUB has started & the operating system is selected to boot, the first thing to get loaded is the kernelAt this point, no operating system exists in memory & PCs have no easy way to access all of their memoryThus, the kernel must load completely into the first megabyte of available RAM. In order to accomplish this, the kernel is compressedThe 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

    Compiled by Bhavesh Shah*

  • Bootstrapping (contd...)Kernel ExecutionWith the kernel in memory, it can begin executingIt knows only whatever functionality is built into it, which means any parts of the kernel compiled as modules are useless at this pointAt 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

    Compiled by Bhavesh Shah*

  • The INIT processThe init process is the first non-kernel process that is started, and, therefore, it always gets the process ID number of 1init reads its configuration file, /etc/inittab, and determines the runlevel where it should startA runlevel of initdefault is selected if it exists; otherwise, you are prompted to supply a runlevel valueThe runlevel values are as follows:0Halt the system1 Enter single-user mode2 Multiuser mode, but without Network File System (NFS)3 Full multiuser mode (normal)4 Unused5 Same as runlevel 3, except using an X Window System login rather than a text based login6 Reboot the systemCompiled by Bhavesh Shah

    Compiled by Bhavesh Shah*

  • RC scriptsThe /etc/inittab file specifies which scripts to run when runlevels changeThese scripts are responsible for either starting or stopping the services that are particular to the runlevelBecause of the number of services that need to be managed, rc scripts are usedThe main one, /etc/rc.d/rc, is responsible for calling the appropriate scripts in the correct order for each runlevelFor each runlevel, a subdirectory exists in the /etc/rc.d directoryThese runlevel subdirectories follow the naming scheme of rc X .d, where X is the runlevelFor 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 serviceNote that these two letters are case sensitive

    Compiled by Bhavesh Shah

    Compiled by Bhavesh Shah*

  • RC scripts (contd...)The /etc/rc.d/rc3.d directoryCompiled by Bhavesh Shah

    Compiled by Bhavesh Shah*

  • Enabling & Disabling ServicesAt times, you may find that you simply dont need a particular service to be started at boot timeThis is especially important if you are configuring the system as a server & need only specific services & nothing moreYou can cause a service not to be started by simply renaming the symbolic link in a particular runlevel directoryOnce you are comfortable working with the command line, youll quickly find that it is easy to enable or disable a serviceThe startup runlevels of the service/program can also be managed using the chkconfig utilityTo completely disable a service, you must, at a minimum, know the name of the serviceYou can then use the chkconfig tool to permanently turn it off, thereby preventing it from starting in all runlevelsCompiled by Bhavesh Shah

    Compiled by Bhavesh Shah*

  • Enabling ServiceDisabling ServiceCompiled by Bhavesh Shah

    Compiled by Bhavesh Shah*

  • Questions?Please don't keep it to yourself ?Compiled by Bhavesh Shah

    Compiled by Bhavesh Shah**

    *

    *

    *

    *

    *

    *

    *

    *

    *

    *

    *

    *

    *

    *

    **