1 / 23

Linux Booting

Linux Booting. The booting procedure. Logging in to the machine. Control flow in the machine. Linux Booting. The booting procedure. Logging in to the machine. Control flow in the machine. The booting procedure.

rich
Télécharger la présentation

Linux Booting

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Linux Booting • The booting procedure. • Logging in to the machine. • Control flow in the machine.

  2. Linux Booting • The booting procedure. • Logging in to the machine. • Control flow in the machine.

  3. The booting procedure. • Every computer has sequence of instructions that are executed when computer is powered up. • determined by the hardware designers • Every OS has a sequence of instructions that it executes prior to normal operation.

  4. The booting procedure. • i386 machines incorporate the Basic Input/Output System (BIOS) • stored at a prespecified location in system ROM. • when computer started, begins executing BIOS code • BIOS code executes the Power-On Self Test (POST) • POST performs various diagnostic tests to check memory and devices for their presence and correct operation. • when POST is completed, machine ready to load and start OS.

  5. The booting procedure. • The boot sector. • OS loaded from the system’s boot disk. • i386 treats A: as default disk if it contains a diskette. • Otherwise depends on how you’ve set the BIOS.

  6. The booting procedure. • The boot disk • must contain a boot record at the disk’s first logical sector. • The boot record fits onto a single 512-byte disk sector (called the boot sector): 0x000 0x002 <a jump instr to 0x0XX> 0x003 …. Disk parameters (used by BIOS) program 0x0XX 0x1fd Bootstrap program 0x1fe 0x1ff 0xaa55 (the magic number for BIOS)

  7. The booting procedure. • After POST BIOS copies the boot record from disk into memory • Bios then reads boot record parameters: • Boot record contains parameters that describe disk’s physical layout • Parameters are stored in well-know locations in boot record • Parameters include number of tracks and number of sectors per track.

  8. The booting procedure. • After parameters read BIOS branches to the first location in program • then immediately branches to location 0x0XX • the value XX for Linux is 3e • the value XX for MS-DOS is 1e • The small program at address 0x0XX loads a more sophisticated loader from other sectors on the disk • The sophisticated loader loads the OS

  9. The booting procedure. • Disk partitioning • can have up to 4 primary partitions on one physical disk • each primary disk can have logical sub-partitions • each partition treated like a physical disk below the abstract machine that accesses the physical disk (eg, BIOS in MS-DOS) • if partition is bootable then its logical sector number 0 will be a boot sector.

  10. The booting procedure. • Disk partitioning • when hardware is powered up goes to head 0, track 0, sector 1 and begins executing code. • an unpartitioned disk has a jump instruction at head 0, track 0, sector 1 which jumps to location 0x0XX and starts the execution of the boot program • in a partitioned disk, physical head 0, track 0, sector 1 (first logical disk sector) describes how hard disk is partitioned into logical disks.

  11. The booting procedure. • A partitioned disk has a 446-byte bootstrap program starting at first byte in the sector. • next is a 65-byte partition table for the disk • Table contains the 4 partition entries, each of which describes the portion of the physical disk that is used for its partition (starting sector of the partition, ending sector, number of sectors, etc.) • last 2 bytes of partition sector contain a magic number, 0xaa55 to identify the partition sector.

  12. head 0 track 0 sector 1 Partitioned Disk 446-byte bootstrap program 4 partition entries, each describes the portion of the physical disk used for its partition 65-byte partition table 2 bytes: magic number, 0xaa55 for MS-DOS

  13. The booting procedure. • Partitioning with different OS’s • i386 can be booted with Linux from boot floppy. • contains a Linux boot program. • Can have different OS in different partitions • Windows handles by designating one partition as an active partition. System always boots from this partition.

  14. The booting procedure. • Partitioning with different OS’s • can have a special program, Linux Loader (LILO) in system boot record. • program allows user to choose at boot time which partition is to be the active partition. • LILO is loaded in the boot record so that BIOS runs it after the POST.

  15. Starting the Kernel • machine is powered up • hardware fetch-decode-execute cycle begins. • called the “hardware process” • this is not a Linux process; Linux has not yet started. • POST is completed • boot record read • loader places OS into primary memory • the booting procedure begins to run kernel code to initialize the computer’s hardware.

  16. Starting the Kernel • Computer then starts kernel by setting supervisor mode and branching to main entry point in kernel. • main entry point is not a C program. • kernel initializes • trap table • interrupt handler • scheduler • clock • modules • etc.

  17. Starting the Kernel • near end of kernel initialization start process manager • now ready for normal process abstraction • PM starts the initial process • initial process is first entry in kernel’s process descriptor table • referred to as process 0, task[0], or INIT_TASK • initial process then creates first useful Linux process to run: the init program • after init runs it executes an idle loop • only other duties of init is to use idle CPU time….runs when no other process wants CPU.

  18. Starting the Kernel • init process initializes system • starts daemons • starts file manager • creates system console • runs other init programs from /etc, /bin and/or /sbin, and runs /etc/rc

  19. Logging in to the machine • during initialization kernel creates one process on each communication port that can be used to support user logins • uses the getty program • getty • waits for a user to begin using the port • then runs login program • login expects user id on first line, passwd on next • login verifies user by looking in /etc/passwd file

  20. Logging in to the machine • getty • /etc/passwd file. Each entry separated by colon jbarr:eNcrYpt123:3348:35:John Barr:/home/barr:/bin/bash • jbarr account name • eNcrYpt123 encrypted password • 3348 and 35 user ID and group ID • John Barr real name • /home/barr user’s home directory • /bin/bash path to shell command preferred by user

  21. Logging in to the machine • getty • once login verifies it changes current directory to user’s home directory • and executes the specified shell program • now user interacts directly with login process via shell. • user who logs in is using a process that was created when the machine was started • starting shell is complicated; data and stack segments created etc. • data includes user’s environmental variables (eg, PATH) • when user logs off, return from shell call to the login process

  22. 2 login 1 login login 4 3 5 login /bin/bash /bin/bash Logging in to the machine 6 Serial Port A Serial Port B getty Serial Port C Serial Port Z /etc/passwd

  23. Control Flow hardware process starts Idle Proc kernel ISRs Proc i Proc j program hardware process context switch

More Related