unit 4 booting & shut down

27
Booting and Shut Down of Operating System Prepared By Prof. Bhushan Pawar www.bhushanpawar.com 1 Prof.Bhushan Pawar www.bhushanpawar.com

Upload: bhushan-pawar

Post on 15-Aug-2015

46 views

Category:

Engineering


0 download

TRANSCRIPT

Page 1: Unit 4 booting & shut down

Booting and Shut Downof

Operating System

Prepared ByProf. Bhushan Pawar

www.bhushanpawar.com

1Prof.Bhushan Pawar

www.bhushanpawar.com

Page 2: Unit 4 booting & shut down

BootstrappingStandard term for starting up a computer.

During bootstrapping, the kernel is loaded intomemory and begins to execute.

When a computer is turned on, it first executesboot code that is stored in ROM.

The kernel probes the system’s hardware andthen spawns the system’s init process, whichis always process number 1.

2Prof.Bhushan Pawar

www.bhushanpawar.com

Page 3: Unit 4 booting & shut down

Recovery boot to a shell

In normal operation, systems boot themselvesindependently and are then accessed remotely byadministrators.

If a disk crashes, administrators need a recovery tool.

Then instead of shooting for full system operation,UNIX systems can boot just run a shell on the systemconsole known as booting to single-user mode, recoverymode, or maintenance mode.

Single-user mode does not allow network operation weneed physical access to the system console to use it.

3Prof.Bhushan Pawar

www.bhushanpawar.com

Page 4: Unit 4 booting & shut down

Recovery boot to a shell (Contin…)

On most systems, you request a boot to single-user mode by passing an argument to thekernel at boot time. If the system is already upand running, you can bring it down to single-user mode with the shutdown or telinitcommand.

4Prof.Bhushan Pawar

www.bhushanpawar.com

Page 5: Unit 4 booting & shut down

Steps in the boot process

• consists of 6 distinct phases

– Reading of the boot loader from the master boot record

– Loading and initialization of the kernel

– Device detection and configuration

– Creation of kernel processes

– Administrator intervention (single-user mode only)

– Execution of system startup scripts

5Prof.Bhushan Pawar

www.bhushanpawar.com

Page 6: Unit 4 booting & shut down

Kernel initialization

• First bootstrapping task is to get kernel intomemory so that it can be executed.

• The pathname of the kernel /boot/vmlinuz

• System ROM loads a small boot program intomemory from disk. This program is called asboot loader.

6Prof.Bhushan Pawar

www.bhushanpawar.com

Page 7: Unit 4 booting & shut down

Creation of kernel processes

Kernel process created through the normal system fork mechanism

init is always pid 1. Most UNIX systems have sched as process 0.

7Prof.Bhushan Pawar

www.bhushanpawar.com

Page 8: Unit 4 booting & shut down

Operator intervention (recovery mode only)

• If the system is to be brought in recoverymode, a command-line flag passed by thekernel.

• During a single-user boot on same systems,you are prompted to enter the root password.If you enter the right password, the systemspawns a root shell.

• You can execute commands in same way aswhen logged in on a fully booted system.

8Prof.Bhushan Pawar

www.bhushanpawar.com

Page 9: Unit 4 booting & shut down

Booting PC

• When a machine boots, it begins by executingcode stored in ROMs.

• The initial boot code is generally called a BIOS(Basic Input/Output System)

• Actually, a PC has several levels of BIOS: onefor the machine itself, one for the video card,one for the SCSI card if the system has one,and sometimes components for otherperipherals such as network cards.

9Prof.Bhushan Pawar

www.bhushanpawar.com

Page 10: Unit 4 booting & shut down

Booting PC (Continue…)

• Built-in BIOS knows about some of the devicesthat live on the motherboard. E.g. IDE(integrateddevelopment environment), SATA Controller,network interfaces.

• The BIOS normally lets you select which devicesyou want the system to try to boot from. You canusually specify an ordered list of preferences suchas “Try to boot from a DVD, then a USB drive,then the hard disk.” Network booting withPXE(Preboot eXecution Environment) is also acommon option.

10Prof.Bhushan Pawar

www.bhushanpawar.com

Page 11: Unit 4 booting & shut down

Booting PC (Continue…)

• Once the BIOS has figured device to boot fromit tries to read the first block of the device.This 512-byte segment is known as the masterboot record or MBR. The MBR contains aprogram that tells the computer from whichpartition to load a secondary boot program,the “boot loader.”

11Prof.Bhushan Pawar

www.bhushanpawar.com

Page 12: Unit 4 booting & shut down

Booting PC (Continue…)

• The default MBR contains a simple programthat tells the computer to get its boot loaderfrom the first partition on the disk.

• Once the MBR has chosen a partition to bootfrom, it tries to load the boot loader specificto that partition. This loader is thenresponsible for loading the kernel.

12Prof.Bhushan Pawar

www.bhushanpawar.com

Page 13: Unit 4 booting & shut down

GRUB: GRAND UNIFIED BOOT LOADER

• GRUB, developed by the GNU project

• It is the default boot loader for UNIX & LINUXsystems with Intel Processors.

• GRUB’s job is to choose a kernel from apreviously assembled list and to load thatkernel with options specified by theadministrator.

13Prof.Bhushan Pawar

www.bhushanpawar.com

Page 14: Unit 4 booting & shut down

14

GRUB Loader

Prof.Bhushan Pawar

www.bhushanpawar.com

Page 15: Unit 4 booting & shut down

GRUB Loader (Continue..)

• By default, GRUB reads its default bootconfiguration from /boot/grub/menu.lst or/boot/grub/grub.conf

• GRUB allows dynamic changes at each systemboot.

• The menu.lst and grub.conf files are slightlydifferent but have a similar syntax. Red Hatsystems use grub.conf, and Solaris, SUSE, andUbuntu still use menu.lst

15Prof.Bhushan Pawar

www.bhushanpawar.com

Page 16: Unit 4 booting & shut down

GRUB Loader (Continue..)

• To enter command-line mode, type c from the GRUB boot screen.

GRUB command-line options

Command Meaning

reboot Reboots the system

find Finds files on all mountable partitions

root Specifies the root device (a partition)

kernel Loads a kernel from the root device

help Gets interactive help for a command

boot Boots the system from the specified kernel image

16Prof.Bhushan Pawar

www.bhushanpawar.com

Page 17: Unit 4 booting & shut down

BOOTING TO SINGLE-USER MODE

• The beginnings of the boot process are systemdependent. Systems with non-Intel processors havecustom boot loader software.

• Single-user mode with GRUB

– don’t need to use the command line.

– boot options should be easily modifiable and

decided on the ‘a’ key as the appropriate tool.

– At the GRUB splash screen, highlight the desiredkernel and press ‘a’ to append to the bootoptions.

17Prof.Bhushan Pawar

www.bhushanpawar.com

Page 18: Unit 4 booting & shut down

Single-user mode with GRUB(Continue..)

• To boot into single-user mode, add the single (or -s on Solaris) flag to the end of the existingkernel options.

• E.g

grub append> ro root=LABEL=/ rhgb quiet single

18Prof.Bhushan Pawar

www.bhushanpawar.com

Page 19: Unit 4 booting & shut down

Single-user mode with GRUB(Continue..)

• rhgb = redhat graphical boot - This is a GUI mode booting screen with most of the information hidden while the user sees a rotating activity icon spining and brief information as to what the computer is doing.

quiet = hides the majority of boot messages before rhgb starts. These are supposed to make the common user more comfortable. They get alarmed about seeing the kernel and initializing messages, so they hide them for their comfort.

19Prof.Bhushan Pawar

www.bhushanpawar.com

Page 20: Unit 4 booting & shut down

Single-user mode on SPARC(scalable processor architecture)

• To interrupt the boot procedure and enter theOpenBoot PROM on Sun hardware, press the L1 and‘a’ keys simultaneously. L1 is sometimes labeledSTOP on modern Sun keyboards.

• Type boot -s to boot to single-user mode.

20Prof.Bhushan Pawar

www.bhushanpawar.com

Page 21: Unit 4 booting & shut down

WORKING WITH STARTUP SCRIPTS

• After exiting from single-user mode init executes the system startup scripts & that are interpreted by sh or bash.

• Systems use approach in which scripts are numbered and executed.

• Scripts are kept in /etc/init.d, and links to them are made in the directories /etc/rc0.d, /etc/rc1.d

21Prof.Bhushan Pawar

www.bhushanpawar.com

Page 22: Unit 4 booting & shut down

WORKING WITH STARTUP SCRIPTS (Continue…)

• Tasks that are often performed in the startup scripts

Setting the name of the computer

Setting the time zone

Checking the disks with fsck (i.e file system check)

Mounting the system’s disks

Removing old files from the /tmp directory

Configuring network interfaces

Starting up daemons and network servicesProf.Bhushan Pawar

www.bhushanpawar.com22

Page 23: Unit 4 booting & shut down

Rebooting & Shutting Down

• On consumer-oriented operating systems,rebooting the operating system is anappropriate first course of treatment for manyproblems.

• Whenever we modify a startup script or makesignificant system changes, we should rebootjust to make sure that the system comes upsuccessfully.

Prof.Bhushan Pawar

www.bhushanpawar.com23

Page 24: Unit 4 booting & shut down

Shutdown: the proper way to halt the system

• It is the safest, most considerate, and most thoroughcommand to initiate a halt or reboot or to return thesystem to single-user mode.

• You can ask shutdown to wait awhile before shuttingdown the system. During the waiting period,shutdown sends messages to logged-in users atprogressively shorter intervals, warning them of theimpending downtime.

• Most versions of shutdown, specify whether themachine should halt, go to single-user mode, orreboot. (Path is /sbin/shutdown)

Prof.Bhushan Pawar

www.bhushanpawar.com24

Page 25: Unit 4 booting & shut down

Halt and Reboot: simpler ways to shut down

• The halt command performs the essential dutiesrequired to shut the system down. It is called byshutdown -h but can also be used by itself.

• Halt logs the shutdown, kills nonessential processes,executes the sync system call (called by andequivalent to the sync command), waits for filesystem writes to complete, and then halts the kernel.

• halt -n prevents the sync call.

Prof.Bhushan Pawar

www.bhushanpawar.com25

Page 26: Unit 4 booting & shut down

Halt and Reboot: simpler ways to shut down (Continue…)

• reboot is almost identical to halt, but it causes the machine to reboot instead of halting.

• Reboot is called by shutdown -r.

Prof.Bhushan Pawar

www.bhushanpawar.com26

Page 27: Unit 4 booting & shut down

Any Question???• If you having any doubt then you can freely

ask me question on

[email protected]

Or

contact me on (+91)-7588318728

Prof.Bhushan Pawar

www.bhushanpawar.com27