Introduction to Linux start-up. Hao-Ran Liu

Similar documents
Certification. System Initialization and Services

System Administration. Startup Process

The Linux Boot Process

The Linux IPL Procedure

The Early System Start-Up Process. Group Presentation by: Tianyuan Liu, Caiwei He, Krishna Parasuram Srinivasan, Wenbin Xu

RHCE BOOT CAMP. The Boot Process. Wednesday, November 28, 12

Using grub to Boot various Operating Systems

Runlevels, System Shutdown and Reboot

PL-I Assignment Broup B-Ass 5 BIOS & UEFI

Advanced Operating Systems and Virtualization. Alessandro Pellegrini A.Y. 2017/2018

CSE 265: System and Network Administration

CSE 265: System and Network Administration

grub-md5-crypt --help Usage: grub-md5-crypt [OPTION] Encrypt a password in MD5 format.

MODULE 02. Installation

Boot Process in details for (X86) Computers

CST8177 Linux II. Linux Boot Process

Booting up and Shutting down A primer for troubleshooting

University of Pennsylvania Zachary Goldberg. CIS c. More Kernel Bits. 10/03/09 Slide 1

HOW LINUX BOOTS. As it turns out, there isn t much to the boot process:

LPI EXAM LPI Level 1 Exam 101, Junior Level Linux Certification, Part 1 of 2. Buy Full Product.

Booting Up and Shutting Down. lctseng / Liang-Chi Tseng

NETW 110 Lab 3 Post-Installation Configuration Page 1

Linux+ Guide to Linux Certification, Third Edition. Chapter 2 Linux Installation and Usage

Chapter 6. Boot time configuration. Chapter 6 Boot time configuration

Chapter 2 Booting Up and Shutting Down

Linux/Citrix Virtual Environment Documentation

Booting Up and Shutting Down

Linux Boot Process. Nassim Eddequiouaq LSE Summer Week 2015

Boot. How OS boots

Managing the Linux Boot Process

SUSE Advanced Troubleshooting: The Boot Process Lecture

Booting: ROM vs RAM The term random access memory is somewhat misleading because DRAM, SRAM and ROM all qualify as random access memories We will

Please choose the best answer. More than one answer might be true, but choose the one that is best.

The kernel is not to be confused with the Basic Input/Output System (BIOS).

Chapter 4. File Systems. Part 1

Vendor: LPI. Exam Code: Exam Name: LPI Level 1 Exam 101, Junior Level Linux Certification, Part 1 of 2. Version: Demo

BOOTSTRAP, PC BIOS, AND IA32 MEMORY MODES. CS124 Operating Systems Winter , Lecture 5

If you don't care about how it works but you just would like that it works read here. Other wise jump to the next chapter.

Advanced Operating Systems

CompTIA Linux+/LPIC-1 COPYRIGHTED MATERIAL

LPIC 102. be familiar with standard runlevels in a Linux system

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

IA32 OS START-UP UEFI FIRMWARE. CS124 Operating Systems Fall , Lecture 6

CS 410/510. Mark P Jones Portland State University

Longhorn Large Sector Size Support. Anuraag Tiwari Program Manager Core File System

Thousands of Linux Installations (and only one administrator)

Oracle 1Z Enterprise Linux System Administration. Download Full Version :

Automatically Logging on a User at Linux System Boot time for Console Management

client X11 Linux workstation

Logical disks. Bach 2.2.1

Processes. CS3026 Operating Systems Lecture 05

File System Case Studies. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Console Redirection on VMware ESX Server Software and Dell PowerEdge Servers

bytes per disk block (a block is usually called sector in the disk drive literature), sectors in each track, read/write heads, and cylinders (tracks).

Manage Directories and Files in Linux. Objectives. Understand the Filesystem Hierarchy Standard (FHS)

Embedded Linux Architecture

Lab 3a Using the vi editor

Initial Bootloader. On power-up, when a computer is turned on, the following operations are performed:

Chapter 3. Booting Operating Systems

The LILO Configuration Handbook. Virgil J. Nisly

ECE 598 Advanced Operating Systems Lecture 2

Installation of Fedora 12 with CD

Kernel Internals. Course Duration: 5 days. Pre-Requisites : Course Objective: Course Outline

Booting Up & Processes

Operating Systems. II. Processes

Basic UNIX system administration

Linux Level 1. Student Manual.

How To Reinstall Grub In Windows 7 With Cd Bootcamp Partition

Installation of the OS

Advanced Unix System Administration

CHAPTER 11: IMPLEMENTING FILE SYSTEMS (COMPACT) By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

Idea6410 Ubuntu User Manual V 0.19

Disk divided into one or more partitions

Basic Shell Commands. Bok, Jong Soon

WD AV GP Large Capacity Hard Drives

ITDUMPS QUESTION & ANSWER. Accurate study guides, High passing rate! IT dumps provides update free of charge in one year!

File System Case Studies. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Initial Bootloader > Flash Drive. Warning. If not used carefully this process can be dangerous

File Systems Forensics

Exam : 1Z Title : Enterprise Linux System Administration. Version : DEMO

Unix Processes. What is a Process?

CanSecWest Nicolás A. Economou Andrés Lopez Luksenberg

Xosdev Chapter 1 [The Bootloader] by mr. xsism

CS4500/5500 Operating Systems File Systems and Implementations

CIS 191A Final Exam. Fall CIS 191 Final Exam

Chapter 7 File Operations

Slackware installation

Time Left. sec(s) Quiz Start Time: 12:13 AM. Question # 5 of 10 ( Start time: 12:18:29 AM ) Total Marks: 1

Course 55187B Linux System Administration

Integrated Lights-Out 3 Virtual Serial Port configuration and operation

Introduction to Linux Init Scripts

LiLo Crash Recovery. 1.0 Preparation Tips. 2.0 Quick Steps to recovery

ECE 471 Embedded Systems Lecture 12

412 Notes: Filesystem

minit Felix von Leitner September 2004 minit

The Extended MBR (version 1.05) (dated: 01 Nov 2018) by Benjamin David Lunt Copyright (c) Forever Young Software

BlueCat Linux Kernel Porting Guide

CS370 Operating Systems

COMP091 Operating Systems 1. File Systems

Systems Programming/ C and UNIX

Transcription:

Introduction to Linux start-up Hao-Ran Liu

Boot process overview Hardware startup BIOS LILO or bootsect.s Linux kernel Mount root file system /sbin/init LILO is a versatile boot loader, but it is functional-equivalent to bootsect.s in Linux (version 2.4 or before)

Boot process BIOS reads the first sector of the boot disk (floppy, hard disk,, according to the BIOS parameter setting) the boot sector (512 bytes) will contain program code for loading the operating system kernel (e.g., Linux Loader, LILO) boot sector ends with 0xAA55 Boot disk Floppy: the first sector Hard disk: the first sector is the master boot record (MBR)

Boot sector and MBR 0x000 0x003 0x03E 0x1FE JMP xx Disk parameters Program code loading the OS kernel 0xAA55 Boot Sector (Floppy) 0x000 0x1BE 0x1BE 0x010 0x1CE 0x010 0x1DE 0x010 0x1EE 0x010 0x1FE 0x002 Code for loading the boot sector of the active partition Partition 1 Partition 2 MBR and extended Partition 3 partition table (Hard disk) Partition 4 0xAA55

MBR (Master Boot Record) Four primary partitions only 4 partition entries Each entry is 16 bytes Extended partition If more than 4 partitions are needed The first sector of extended partition is same as MBR The first partition entry is for the first logical drive The second partition entry points to the next logical drive (MBR) The first sector of each primary or extended partition contains a boot sector

Structure of a Partition Entry 1 Boot 1 HD SEC CYL SYS HD SEC CYL low byte high byte 4 low byte high byte Boot flag: 0=not active, 0x80 active Begin: head number 2 Begin: sector and cylinder number of boot sector 1 System code: 0x83 Linux, 0x82: swap 1 End: head number 2 End: sector and cylinder number of last sector 4 Relative sector number of start sector Number of sectors in the partition

The structure of MBR and Extended Partition are the same. Extended partition table offset 0x000 Master Boot Sector Code Loading and Starting the boot sector Of the active partition Partition 2 disk space 0x1BE 0x1CE Partition 1 Partition 2 Partition 1 Partition 2 Partition 1 Partition 2 Partition 1 Partition 2 NULL Partition 3 0x1FE Partition 4 0xAA55

Active Partition Booting is carried out from the active partition which is determined by the boot flag Operations of MBR determine active partition load the boot sector of the active partition jump into the boot sector at offset 0

Linux 2.6 kernel image /arch/i386/boot/ bootsect.s /arch/i386/boot/ setup.s /arch/i386/boot/compressed head.s, misc.c /arch/i386/kernel/ head.s kernel objects /arch/i386/boot/ bzimage /arch/i386/boot/ vmlinux.bin /arch/i386/boot/compressed/ vmlinux /arch/i386/boot/compressed/ piggy.o /arch/i386/boot/compressed/ vmlinux.bin.gz /vmlinux bootsect.s: Linux floppy boot loader (only in version <= 2.4) setup.s: hardware initialization, switch to protected mode First head.s, misc.c: decompress kernel Second head.s: enable paging, setup GDT, jump to C routine start_kernel()

Loading a bzimage 4 /arch/i386/boot/ vmlinux.bin load the target into the memory 1 2 3 5 execution path jump to the target time

Starting a bzimage 3 7 load the target into the memory 1 2 4 head.s misc.c 5 6 execution path jump to the target 8 time

zimage and bzimage Both zimage and bzimage are compressed with gzip The only difference zimage is loaded low and has a size limit of 512KB Boot loader (bootsect.s) places at /arch/i386/boot/ vmlinux.bin Decompressed kernel /arch/i386/boot/compressed/ ( vmlinux.bin ) s final address zimage between 0x10000~0x90000 0x100000 bzimage above 0x100000 0x100000

The Linux/i386 boot protocol 0A0000 +------------------------+ Reserved for BIOS Do not use. Reserved for BIOS EBDA. 09A000 +------------------------+ Stack/heap/cmdline For use by the kernel real-mode code. 098000 +------------------------+ Kernel setup The kernel real-mode code. 090200 +------------------------+ Kernel boot sector The kernel legacy boot sector. 090000 +------------------------+ Protected-mode kernel The bulk of the kernel image. 010000 +------------------------+ Boot loader <- Boot sector entry point 0000:7C00 001000 +------------------------+ Reserved for MBR/BIOS 000800 +------------------------+ Typically used by MBR 000600 +------------------------+ BIOS use only 000000 +------------------------+

LILO vs. GRUB LILO Boot any file system Need regeneration of a map file if kernel changes Friendly to file system developers GRUB Boot only known file system No map file! Friendly to normal users

LILO file system unaware

GRUB file system aware

Starting the kernel After head.s and misc.c decompress kernel, it calls the first C routine start_kernel() Many hardware-independent parts of the kernel are initialized here. asmlinkage void init start_kernel(void) { char * command_line; printk(linux_banner); setup_arch(&command_line); parse_options(command_line); trap_init(); init_irq(); sched_init(); time_init(); softirq_init(); console_init();

Spawn first process - init The original process now running is process 0 It generates a kernel thread (process 1) executing init() function Subsequently, it is only concerned with using up unused computing time - cpu_idle() asmlinkage void init start_kernel(void) { kernel_thread(init, NULL, ) cpu_idle(); } Process 0 Process 1 kernel_thread() init() cpu_idle() /sbin/init

init() function Carry out the remaining initialization and open file descriptors 0, 1, 2 for the first user program being exec ed later Try to execute a boot program specified by the user or one of the programs /sbin/init, /etc/init, or /bin/init If none of these programs exists, try to start a shell so that the superuser can repair the system. If this is not possible too, the system is stopped static int init() { { do_basic_setup(); if (open /dev/console, O_RDWR, 0) < 0) printk( Warning: unable to open an initial console.\n ); (void) dup(0); (void) dup(0); if (execute_command) execve(execute_command, argv_init, envp_init); execve( /sbin/init, argv_init, envp_init); execve( /etc/init, argv_init, envp_init); execve( /bin/init, argv_init, envp_init); execve( /bin/sh, argv_init, envp_init); panic( No init found ); }

/sbin/init parent of all processes Init configures the system and create processes according to /etc/inittab A Runlevel is: A software configuration of what services to be started A state that the system can be in /etc/inittab defines several runlevels

Description of runlevels Runlevel 0 1 2 3 4 5 6 S or s a,b,c Description Halt - used to halt the system Single-user text mode Not used Full multi-user text mode Not used Full multi-user graphic mode (with an X-based login screen) Reboot used to reboot the system Used internally by scripts that run in runlevel 1 On-demand run levels - typically not used.

inittab syntax An entry in the inittab has this format: id : runlevels : action : process id: an unique id to identify the entry runlevels: a list of runlevels for which the specified action should be taken action: describes which action should be taken process: specifies the program to be executed Please refer to man page inittab(5) for details of the action field

inittab example # default runlevel is 3 id:3:initdefault: # System initialization. si::sysinit:/etc/rc.d/rc.sysinit # the start script of each runlevel l0:0:wait:/etc/rc.d/rc 0 l1:1:wait:/etc/rc.d/rc 1 l2:2:wait:/etc/rc.d/rc 2 l3:3:wait:/etc/rc.d/rc 3 l4:4:wait:/etc/rc.d/rc 4 l5:5:wait:/etc/rc.d/rc 5 l6:6:wait:/etc/rc.d/rc 6 # Trap CTRL-ALT-DELETE ca::ctrlaltdel:/sbin/shutdown -t3 -r now # Run gettys in standard runlevels 1:2345:respawn:/sbin/mingetty tty1 2:2345:respawn:/sbin/mingetty tty2 3:2345:respawn:/sbin/mingetty tty3 4:2345:respawn:/sbin/mingetty tty4 5:2345:respawn:/sbin/mingetty tty5 6:2345:respawn:/sbin/mingetty tty6 # Run xdm in runlevel 5 x:5:respawn:/etc/x11/prefdm -nodaemon

References Werner Almesberger, Booting Linux: the history and the future, Ottawa Linux Conference, 2000