18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

21
18th August, 2005 18th August, 2005 CS431 Course Presentation CS431 Course Presentation 1 Booting of a Booting of a Computer System Computer System Harpreet Singh Harpreet Singh

Transcript of 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

Page 1: 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

18th August, 200518th August, 2005 CS431 Course PresentationCS431 Course Presentation 11

Booting of a Booting of a Computer SystemComputer System

Harpreet SinghHarpreet Singh

Page 2: 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

18th August, 2005 CS431 Course Presentation 2

Why is Booting Required ?Why is Booting Required ?

► Hardware doesn’t know where the operating Hardware doesn’t know where the operating system resides and how to load it.system resides and how to load it.

► Need a special program to do this job – Need a special program to do this job – BootstrapBootstrap loader. loader. E.g. BIOS – Boot Input Output System.E.g. BIOS – Boot Input Output System.

► Bootstrap loader locates the kernel, loads it into Bootstrap loader locates the kernel, loads it into main memory and starts its execution.main memory and starts its execution.

► In some systems, a simple bootstrap loader In some systems, a simple bootstrap loader fetches a more complex boot program from disk, fetches a more complex boot program from disk, which in turn loads the kernel.which in turn loads the kernel.

Page 3: 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

18th August, 2005 CS431 Course Presentation 3

How Boot process occurs ?How Boot process occurs ?

►Reset event on CPU (power up, reboot) Reset event on CPU (power up, reboot) causes instruction register to be loaded with causes instruction register to be loaded with a predefined memory location. It contains a a predefined memory location. It contains a jump instruction that transfers execution to jump instruction that transfers execution to the location of Bootstrap program. the location of Bootstrap program.

►This program is form of ROM, since RAM is This program is form of ROM, since RAM is in unknown state at system startup. ROM is in unknown state at system startup. ROM is convenient as it needs no initialization and convenient as it needs no initialization and can’t be affected by virus.can’t be affected by virus.

Page 4: 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

18th August, 2005 CS431 Course Presentation 4

BIOS InteractionBIOS Interaction

Page 5: 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

18th August, 2005 CS431 Course Presentation 5

Tasks performed at boot upTasks performed at boot up

► Run diagnostics to determine the state of Run diagnostics to determine the state of machine. If diagnostics pass, booting continues.machine. If diagnostics pass, booting continues.

► Runs a Runs a Power-On Self TestPower-On Self Test ( (POSTPOST) to check the ) to check the devices that the computer will rely on, are devices that the computer will rely on, are functioning.functioning.

► BIOS goes through a preconfigured list of devices BIOS goes through a preconfigured list of devices until it finds one that is bootable. If it finds no such until it finds one that is bootable. If it finds no such device, an error is given and the boot process device, an error is given and the boot process stops. stops.

► Initializes CPU registers, device controllers and Initializes CPU registers, device controllers and contents of the main memory. After this, it loads contents of the main memory. After this, it loads the OS.the OS.

Page 6: 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

18th August, 2005 CS431 Course Presentation 6

BIOS SetupBIOS Setup

Page 7: 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

18th August, 2005 CS431 Course Presentation 7

Boot ProcedureBoot Procedure

Page 8: 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

18th August, 2005 CS431 Course Presentation 8

Tasks performed at boot up (Contd)Tasks performed at boot up (Contd)

► On finding a bootable device, the BIOS loads and On finding a bootable device, the BIOS loads and executes its executes its boot sectorboot sector. In the case of a hard . In the case of a hard drive, this is referred to as the drive, this is referred to as the master boot recordmaster boot record ((MBRMBR) and is often not OS specific.) and is often not OS specific.

► The MBR code checks the The MBR code checks the partition tablepartition table for an for an active partition. If one is found, the MBR code active partition. If one is found, the MBR code loads that partition's loads that partition's boot sectorboot sector and executes it. and executes it.

► The boot sector is often The boot sector is often operating systemoperating system specific, specific, however in most operating systems its main however in most operating systems its main function is to load and execute a function is to load and execute a kernelkernel, which , which continues startup.continues startup.

Page 9: 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

18th August, 2005 CS431 Course Presentation 9

Secondary Boot LoadersSecondary Boot Loaders

► If there is no active partition or the active partition's If there is no active partition or the active partition's boot sector is invalid, the MBR may load a boot sector is invalid, the MBR may load a secondary boot loader and pass control to it and secondary boot loader and pass control to it and this secondary boot loader will select a partition this secondary boot loader will select a partition (often via user input) and load its boot sector.(often via user input) and load its boot sector.

► Examples of secondary boot loadersExamples of secondary boot loaders GRUB – GRand Unified BootloaderGRUB – GRand Unified Bootloader LILO – LInux LOaderLILO – LInux LOader NTLDR – NT LoaderNTLDR – NT Loader

Page 10: 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

18th August, 2005 CS431 Course Presentation 10

GRUB LoaderGRUB Loader

Page 11: 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

18th August, 2005 CS431 Course Presentation 11

Booting and ROMBooting and ROM

►System such as cellular phones, PDAs and System such as cellular phones, PDAs and game consoles stores entire OS on ROM. game consoles stores entire OS on ROM. Done only for small OS, simple supporting Done only for small OS, simple supporting hardware, and rugged operation.hardware, and rugged operation.

►Changing bootstrap code would require Changing bootstrap code would require changing ROM chips. changing ROM chips. EPROM – Erasable Programmable ROM. EPROM – Erasable Programmable ROM.

►Code execution in ROM is slower. Copied to Code execution in ROM is slower. Copied to RAM for faster execution.RAM for faster execution.

Page 12: 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

18th August, 2005 CS431 Course Presentation 12

Example : DOSExample : DOS► After identifying the location of boot files, BIOS looks at the first sector After identifying the location of boot files, BIOS looks at the first sector

(512 bytes) and copies information to specific location in RAM (7C00H) (512 bytes) and copies information to specific location in RAM (7C00H) - - Boot RecordBoot Record..

► Control passes from BIOS to a program residing in the boot record.Control passes from BIOS to a program residing in the boot record.► Boot record loads the initial system file into RAM. For DOS, it is Boot record loads the initial system file into RAM. For DOS, it is

IO.SYS .IO.SYS .► The initial file, IO.SYS includes a file called SYSINIT which loads the The initial file, IO.SYS includes a file called SYSINIT which loads the

remaining OS into the RAM.remaining OS into the RAM.► SYSINIT loads a system file MSDOS.SYS that knows how to work with SYSINIT loads a system file MSDOS.SYS that knows how to work with

BIOS.BIOS.► One of the first OS files that is loaded is the system configuration file, One of the first OS files that is loaded is the system configuration file,

CONFIG.SYS in case of DOS. Information in the configuration file tells CONFIG.SYS in case of DOS. Information in the configuration file tells loading program which OS files need to be loaded (e.g. drivers)loading program which OS files need to be loaded (e.g. drivers)

► Another special file that is loaded is one which tells what specific Another special file that is loaded is one which tells what specific applications or commands user wants to be performed as part of applications or commands user wants to be performed as part of booting process. In DOS, it is AUTOEXEC.BAT. In Windows, it’s booting process. In DOS, it is AUTOEXEC.BAT. In Windows, it’s WIN.INI .WIN.INI .

Page 13: 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

18th August, 2005 CS431 Course Presentation 13

ReferencesReferences

►Operating System Principles – Silberchatz, Operating System Principles – Silberchatz, Galvin and Gagne.Galvin and Gagne.

► http://en.wikipedia.org/wiki/Bootinghttp://en.wikipedia.org/wiki/Booting► http://computer.howstuffworks.com/bios2.htmhttp://computer.howstuffworks.com/bios2.htm

Page 14: 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

18th August, 2005 CS431 Course Presentation 14

QuestionsQuestions

► What is the effect on boot sector and boot loader when you install two What is the effect on boot sector and boot loader when you install two OS, for e.g. Windows and Linux in two separate partitions ?OS, for e.g. Windows and Linux in two separate partitions ?

► Suppose, you install Windows first. The default boot loader installed in Suppose, you install Windows first. The default boot loader installed in MBR is NTLDR and contains information regarding the active partition MBR is NTLDR and contains information regarding the active partition of Windows. When you install Linux on this system, the installation of Windows. When you install Linux on this system, the installation prompts to overwrite a new secondary boot loader which identifies both prompts to overwrite a new secondary boot loader which identifies both Windows and Linux active partitions and therefore we get a choice of Windows and Linux active partitions and therefore we get a choice of booting the desired OS when the system is started. booting the desired OS when the system is started.

In contrast, if Linux is installed first and then Windows, In contrast, if Linux is installed first and then Windows, the Windows Installer overwrites the MBR with its own boot loader the Windows Installer overwrites the MBR with its own boot loader which doesn’t recognize the Linux active partition. This creates a which doesn’t recognize the Linux active partition. This creates a problem. The problem can be corrected by using a LiveCD or any problem. The problem can be corrected by using a LiveCD or any bootable disc which can be used to reinstall a secondary boot loader bootable disc which can be used to reinstall a secondary boot loader which identifies both the OS and gives true choice.which identifies both the OS and gives true choice.

Page 15: 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

18th August, 2005 CS431 Course Presentation 15

QuestionsQuestions

► (1) Why is ROM slower than RAM ?(1) Why is ROM slower than RAM ?

(2) How is the boot loader copied from ROM to RAM ?(2) How is the boot loader copied from ROM to RAM ?

► (1)(1) Semi-conductor Technology used in constructing Semi-conductor Technology used in constructing these two type of memories gives the answer. RAM is these two type of memories gives the answer. RAM is based on positive feedback/capacitive charge for storing based on positive feedback/capacitive charge for storing the information while ROM contains permanent and non-the information while ROM contains permanent and non-changeable information stored in its structure.changeable information stored in its structure.

(2) There is a small routine loaded by the BIOS which does (2) There is a small routine loaded by the BIOS which does this task. This routine could also be part of BIOS (though this task. This routine could also be part of BIOS (though not sure).not sure).

Page 16: 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

18th August, 2005 CS431 Course Presentation 16

QuestionsQuestions

► Examples of Applications that access the BIOS Examples of Applications that access the BIOS directly.directly.

► Windows Server 2003 SP1 versions of the Windows Server 2003 SP1 versions of the Windows Preinstallation Environment (WinPE) - Windows Preinstallation Environment (WinPE) - http://www.microsoft.com/technet/prodtechnol/http://www.microsoft.com/technet/prodtechnol/windowsserver2003/library/BookofSP1/windowsserver2003/library/BookofSP1/e0f862a3-cf16-4a48-bea5-f2004d12ce35.mspxe0f862a3-cf16-4a48-bea5-f2004d12ce35.mspx

► The operating system and application programs The operating system and application programs both directly access BIOS routines to provide both directly access BIOS routines to provide better compatibility for such functions as screen better compatibility for such functions as screen display. display.

Page 17: 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

18th August, 2005 CS431 Course Presentation 17

QuestionsQuestions

► If I have only a single OS, is there a secondary boot loader If I have only a single OS, is there a secondary boot loader present on the system ?present on the system ?

► Older machines might not have this feature. But now-a-Older machines might not have this feature. But now-a-days, even Windows is installed with a default secondary days, even Windows is installed with a default secondary boot loader (NTLDR). Linux is also installed usually with boot loader (NTLDR). Linux is also installed usually with LILO or GRUB as the default boot loader.LILO or GRUB as the default boot loader.

You might have also encountered that your system You might have also encountered that your system (Windows) is not able to boot after flashing the BIOS and is (Windows) is not able to boot after flashing the BIOS and is displaying the message “NTLDR missing”. This is because displaying the message “NTLDR missing”. This is because the primary boot loader transfer to NTLDR which might the primary boot loader transfer to NTLDR which might have become corrupt or deleted by mistake.have become corrupt or deleted by mistake.

Page 18: 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

18th August, 2005 CS431 Course Presentation 18

QuestionsQuestions

► Difference between Boot Loader and Boot Difference between Boot Loader and Boot Manager ?Manager ?

► Basically, these two are different but are Basically, these two are different but are sometimes combined into a single program.sometimes combined into a single program.

► IBM's Boot Manager, PowerQuest's BootMagic IBM's Boot Manager, PowerQuest's BootMagic and V Communications' System Commander are and V Communications' System Commander are some examples of boot managers.some examples of boot managers.

► Dual bootingDual booting is the act of installing multiple is the act of installing multiple operating systemsoperating systems on a on a computercomputer, and being able , and being able to choose which one to to choose which one to bootboot when switching on when switching on the computer. The program, which makes dual the computer. The program, which makes dual booting possible is called a booting possible is called a boot loaderboot loader..

Page 19: 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

18th August, 2005 CS431 Course Presentation 19

InformationInformation► Dual BootDual Boot► In the In the OS/2OS/2 world, the term world, the term dual bootdual boot has a more specific meaning. has a more specific meaning.► In a In a dual bootdual boot installation, two (or more) installation, two (or more) operating systemsoperating systems are are

installed in a installed in a singlesingle partitionpartition. Selection of which operating system to . Selection of which operating system to boot is performed by running a boot is performed by running a dual bootdual boot utility program, which utility program, which switches around the necessary switches around the necessary boot loadersboot loaders programs (by renaming programs (by renaming files and copying files and copying boot sectorsboot sectors) to ensure that the chosen operating ) to ensure that the chosen operating system is loaded at the next boot.system is loaded at the next boot.

► In a In a boot managerboot manager installation, by contrast, the two (or more) installation, by contrast, the two (or more) operating systemsoperating systems are installed in their own, separate, individual, are installed in their own, separate, individual, partitionspartitions. Rather than booting directly into an operating system, the . Rather than booting directly into an operating system, the machine boots into a specialised, machine boots into a specialised, operating systemoperating system neutral, neutral, boot loaderboot loader program (such as IBM's eponymous program (such as IBM's eponymous Boot ManagerBoot Manager) ) installed on a floppy disk or in its own installed on a floppy disk or in its own partitionpartition on a hard disk. This on a hard disk. This boot loader program presents a list of the available bootable boot loader program presents a list of the available bootable partitionspartitions from which the user can choose, and then loads and invokes the boot from which the user can choose, and then loads and invokes the boot loader in the boot sector of the chosen partition, to boot the chosen loader in the boot sector of the chosen partition, to boot the chosen operating system.operating system.

Page 20: 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

18th August, 2005 CS431 Course Presentation 20

InformationInformation► When installing an OS on a computer from scratch, here is how the partition When installing an OS on a computer from scratch, here is how the partition

table is created.table is created.► The hard disk is denoted as “hda” where hd=hard disk, and the third letter The hard disk is denoted as “hda” where hd=hard disk, and the third letter

could mean the hard-disk on the system. For e.g. the first hard disk is “hda”, could mean the hard-disk on the system. For e.g. the first hard disk is “hda”, the second is “hdb”.the second is “hdb”.

► When the partitioning is done, “hda0” is the place of MBR. “hda1” is the primary When the partitioning is done, “hda0” is the place of MBR. “hda1” is the primary partition. Then a secondary partition may be created which is further partition. Then a secondary partition may be created which is further subdivided into logical drives. Another OS could be installed on any of these subdivided into logical drives. Another OS could be installed on any of these logical drives. logical drives.

► hda0 – MBRhda0 – MBRhda1 – Primary Partition e.g. Windows XPhda1 – Primary Partition e.g. Windows XPhda2 – Secondary Partitionhda2 – Secondary Partition

hda3 – Logical Drive 1 (FAT32 or NTFS partition)hda3 – Logical Drive 1 (FAT32 or NTFS partition)hda4 – Logical Drive 2 (FAT32 or NTFS partition)hda4 – Logical Drive 2 (FAT32 or NTFS partition)hda5 – Logical Drive 3 (Swap for Linux Partition)hda5 – Logical Drive 3 (Swap for Linux Partition)hda6 – Logical Drive 4 (Root for Linux Partition)hda6 – Logical Drive 4 (Root for Linux Partition)

The above example is a simple example. Specific cases can be different.The above example is a simple example. Specific cases can be different.

Page 21: 18th August, 2005 CS431 Course Presentation 1 Booting of a Computer System Harpreet Singh.

18th August, 2005 CS431 Course Presentation 21

InformationInformation

► When the kernel is being loaded, the control is in When the kernel is being loaded, the control is in the privileged mode. If the user is allowed to login the privileged mode. If the user is allowed to login in the same mode, any user will be “root” or in the same mode, any user will be “root” or “administrator” (super-user). When the booting is “administrator” (super-user). When the booting is almost complete, which is with the privileged right. almost complete, which is with the privileged right. But this login program, after verifying your But this login program, after verifying your password, gives you a shell by creating another password, gives you a shell by creating another process which intentionally drops the super-user process which intentionally drops the super-user privileges and assume the privileges of this user. privileges and assume the privileges of this user. Login program is trusted by the kernel. If that is Login program is trusted by the kernel. If that is hacked or replaced, you can get a root shell from hacked or replaced, you can get a root shell from any login.any login.