0% found this document useful (0 votes)
96 views

RedHat Linux - Boot Process

The Linux booting process begins when the computer is powered on and the CPU loads the BIOS. The BIOS finds bootable devices and loads the MBR from the hard disk. The MBR loads the boot loader, such as GRUB or LILO, which loads the Linux kernel. The kernel initializes devices and starts processes, including init. Init runs startup scripts to mount filesystems and start services. Shutdown and reboot are initiated through commands that change the runlevel.

Uploaded by

janardandev
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views

RedHat Linux - Boot Process

The Linux booting process begins when the computer is powered on and the CPU loads the BIOS. The BIOS finds bootable devices and loads the MBR from the hard disk. The MBR loads the boot loader, such as GRUB or LILO, which loads the Linux kernel. The kernel initializes devices and starts processes, including init. Init runs startup scripts to mount filesystems and start services. Shutdown and reboot are initiated through commands that change the runlevel.

Uploaded by

janardandev
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 23

Linux Booting

Procedure
Roadmap
 Bootstrapping
 Boot Loaders
 Startup/Init Scripts
 Reboot & Shutdown
 Q&A
How Linux boot?
Booting sequence
1. Turn on
2. CPU jump to address of BIOS (0xFFFF0)
3. BIOS runs POST (Power-On Self Test)
4. Find bootable devices
5. Loads and execute boot sector form MBR
6. Load OS
BIOS (Basic Input/Output System)
 BIOS refers to the software code run by a computer when first
powered on
 The primary function of BIOS is code program embedded on a chip
that recognises and controls various devices that make up the
computer.
MBR (Master Boot Record)
 OS is booted from a hard disk, where the Master
Boot Record (MBR) contains the primary boot
loader
 The MBR is a 512-byte sector, located in the first
sector on the disk (sector 1 of cylinder 0, head 0)
 After the MBR is loaded into RAM, the BIOS yields
control to it.
MBR (Master Boot Record)
MBR (Master Boot Record)
 The first 446 bytes are the primary boot loader, which contains both
executable code and error message text
 The next sixty-four bytes are the partition table, which contains a
record for each of four partitions
 The MBR ends with two bytes that are defined as the magic number
(0xAA55). The magic number serves as a validation check of the MBR
Boot loader
Boot loader could be more aptly called the kernel loader.
The task at this stage is to load the Linux kernel

Popular Linux boot loader:


LILO (Linux Loader)
GRUB: GRand Unified Bootloader
Boot Loaders - LILO
 Traditional and stable
 /etc/lilo.conf
 boot=/dev/hda

 root=/dev/hda1

 timeout=5

 image=/boot/vmlinuz-2.6.20

 label=Linux
 read-only
 other=/dev/hdb1

 label=Windows
 table=/dev/hdb
 To install it
 $ lilo

 lilo must be run after every reconfiguration


Boot Loaders – LILO (cont)
 At LILO prompt
 LILO: linux init=/sbin/init
 LILO: linux init=/bin/bash
 LILO: linux root=/dev/hda5
 LILO: linux single
Boot Loaders – GRUB
 GRand Unified Boot loader
 Default on Red Hat and SuSe
 Read configuration file at boot time
 Understand filesystems and kernel executable formats
 ie. Only need to know the device, disk partition and kernel

filename
 GRUB device (hd0,0) → /dev/hda1 or /dev/sda1
 To install GRUB (for the very first time)
 $ grub-install ‘(hd0,0)’

 Edit /boot/grub/grub.conf
Boot Loaders – GRUB (cont)
 /boot/grub/grub.conf
 default=0

 timeout=5

 splashimage=(hd0,0)/boot/grub/splash.xpm.gz

 title CentOS (2.6.18-8.el5)

 root (hd0,0)
 kernel /boot/vmlinuz-2.6.18-8.el5 ro root=LABEL=/
 initrd /boot/initrd-2.6.18-8.el5.img
 title Windows

 rootnoverify (hd1,0)
 chainloader +1
Boot Loaders – GRUB (cont)
 At the splash screen
 Hit ‘a’ and type “ single” to boot to single-user mode
 Hit ‘c’ to enter command-line mode
 To boot other OSes that aren’t in grub.conf
 Display system information
 Press TAB to see possible commands
Kernel Initialization
 A program itself
 /vmlinuz or /boot/vmlinuz
 Two-stage loading process
 initrd (init RAM disk)
 A transient root filesystem in RAM before a real root filesystem is
available
 Eg. It is used to install file system modules into the kernel
 The real root filesystem
 Device detection and configuration
 You tell the kernel what to expect
 The kernel probes the H/W itself
 Kernel threads creation
 Eg. init (a user process), kjournald, kswapd
Task of kernel
 Process management
 Memory management
 Device management
 System call
Single-user mode
 A manual mode after kernel initialization and before
running startup scripts
 “single” is passed to init, sulogin is run instead
 Most system processes are not running
 Users can’t log in, except root
 / is mounted read-only
 $ mount -o rw,remount /
 Check/repair the disk if there are disk problems
 $ fsck -y /dev/sda1
 Run ‘exit’ to exit single-user mode
Startup/Init Scripts
 After Kernel initialization, a process called init is
created with PID 1
 init runs startup scripts (normal shell scripts) to
perform specific tasks, eg.
 Setting the hostname, time zone, etc
 Checking and mouting the disks
 Configuring network interfaces
 Starting up daemons and network services
Startup/Init Scripts (cont)
 Startup scripts (rc files) are run based on run levels
 0 the level in which the system is completely shut down
 1 single-user mode
 2 multiuser mode w/out NFS
 3 full multiuser mode
 4 unused
 5 X11
 6 reboot level
 Starts with run level 0 to the default run level (usually 3)
 /etc/inittab tells init what to do at each level
 To find out which run level the system is current in
 $ runlevel
Startup/Init Scripts (cont)
 init runs the scripts from /etc/rc.d/rc[0-6].d/
 /etc/rc.d/rc0/K25sshd → /etc/init.d/sshd
 /etc/rc.d/rc3/S55sshd → /etc/init.d/sshd
 Each server/daemon provides a master script
 Stored in /etc/init.d
 Understands the arguments: start, stop, restart
 /etc/init.d/sshd start
 run level 0 → 3
 /etc/rc.d/rc3/S* start
 run level 3 → 0
 /etc/rc.d/rc0/K* stop
 Pretty ugly!
Startup/Init Scripts (cont)
 Use chkconfig instead. Eg.
 $ chkconfig --add sshd
 $ chkconfig --del sshd
 Before that, need to add/modify /etc/init.d/sshd
 # chkconfig: 2345 55 25
 sshd should be started/stopped at run level 2, 3, 4 and 5 with the
start priority of 55 and the stop priority of 25
Reboot & Shutdown
 To reboot
 $ shutdown -r now
 $ reboot
 $ telinit 6
 To halt
 $ shutdown -h now
 $ halt
 $ telinit 0
 $ poweroff
Reboot & Shutdown (cont)
 To shutdown gracefully
 $ shutdown -h +15 “Shutdown in 15 mins”

You might also like