# PowerUp Chalk Talk # Michael Meffie # August 20, 2002 # # Presentation on Linux power-up to user prompt. First # hour will be a general overview for Linux users with some diagrams. The second # hour will be more detailed for those with more technical interests and will # include some code fragments. # Linux System Initialization: * Booting * Kernel Startup * User Space Initialization (general) * User Login (console) Topics Not Covered: * Distribution Specifics * X Windows * Desktops Booting: Booting is hardware specific (of course). We will be looking at Intel processors. Kernel can be loaded from variety of media * Floppy * CDROM * Harddrive (see LILO Users Guide) * Network Booting, Power Up: 1. Power Up circuit resets the CPU. 2. The CPU is placed into "Real Mode". 3. The CPU jumps to a hardcoded memory address (0xfffffff0) which contains a block of Read-Only-Memory (ROM). The program stored in this ROM is called the Basic Input/Output System (BIOS). Booting, BIOS Start Up: 1. BIOS runs a Power On Self Test (POST) to detect and test the hardware. Messages may be displayed. 2. Hardware initialization. BIOS initializes the PCI devices 3. Search for an operating system. Load the first sector of the floppy, cdrom, harddrive, network card, etc. Boot sectors are marked with a "signature" (0xAA55). 4. BIOS loads the boot sector into memory at address 0x00007c00 and then jumps to that address. Booting from Floppy: First sector (512) bytes is the boot sector * Program code to load OS * Disk Parameter Data (DOS, not Linux) * Magic Number (0xAA55) Example: +---------------------------+ |Boot sector | | |-------------+ | | | | Data area | | | | | +---------------------------+ Booting, Integrated Boot Loader: * Source Code: arch/i386/boot/bootsect.S * Placed at the front of the kernel image * Raw copying the kernel image to a floppy creates a bootable floppy disk * A separate root disk can be used for the initial root directory to load modules Harddrive Partitions: Example: +--------------------------------------------+ | Partition table /dev/hda | | +------------------------------------------| | | Partition 1 /dev/hda1 | | |------------------------------------------| | | Partition 2 /dev/hda2 | | |------------------------------------------| | | Extended partition /dev/hda3 | | | +----------------------------------------| | | | Extended partition table | | | |----------------------------------------| | | | Partition 3 /dev/hda5 | | | |----------------------------------------| | | | Extended partition table | | | |----------------------------------------| | | | Partition 4 /dev/hda6 | +--------------------------------------------+ Boot Options: * LILO (LInux LOader) and Grub are the most popular boot loaders * LILO first stage in the MBR or the "active" boot sector * LILO second stage provides a menu to select which OS or kernel to load * LILO loads the selected kernel image into memory * Jumps to the kernel setup code Example: +------------------------------------------------------------+ | Master Boot Record Boot sector Operating system | |------------------------------------------------------------| | DOS-MBR ------------> MS-DOS ------> COMMAND.COM | | ---> LOADLIN ------> Linux | | ---> LILO --------> Linux | | ---> MS-DOS --- ... | +------------------------------------------------------------+ +----------------------------------------+ | Master Boot Record Operating system | |----------------------------------------| | LILO ---------------> Linux | | ---> other OS | +----------------------------------------+ Kernel Startup: * setup() - set up the hardware and switch the processor to protected mode * startup_32() - decompress the kernel, prepare for start_kernel * start_kernel() - initialize all kernel components, start /sbin/init Kernel, setup: * gets the amount of RAM available (BIOS call) * sets keyboard repeat rate * initializes video adapter * initializes harddrive controller and get disk geometry * set up provisional IDT and GDT * programs the PIC * here we go.... switch to protected mode! * jump to startup_32 Kernel, startup_32: * clears the reserved memory page frames * decompresses the kernel image * initializes the stack for process 0 * saves the systems parameters obtained from the BIOS to first page frame * finds the processor model * jumps to start_kernel Kernel, start_kernel: Final set up all the kernel components * memory paging * interrupt and exceptions * timers and time keeping * create process 1 and executes /sbin/init (or specified init program) User Space Initialization: * process 1 - /sbin/init See init.png Init Process: * starts up user mode programs * root process for all user mode programs * default process reaper User Login: See login.png More Information: * Power-up to bash Prompt HOWTO * LILO User's Guide * init scripts * kernel sources Summary: * Booting * Kernel Startup * User Space Initialization * User Login