Course's Plan:
- Boot sequence. The x86 family bootstrapping.
- Runlevel implementation. Init and rc.
Boot sequence
Description
Linux bootup steps:- BIOS : Tests and MBR chain-up
- Bootloader: Kernel selection
- Kernel startup
- /sbin/init: Userland loading
BIOS (Basic Input Output System)
- POST (Power On Self Test):
- Detect hardware
- Accessing bootable devices
- Read MBR (Master Boot Record)
- 512 first bytes
- Hosts the partition table
- Hosts the starting procedure (to launch the boot manager)
- Start Boot manager (GRUB/LILO)
System Boot
From BIOS to Kernel:
And the kernel makes its way to init
Kernel
/boot/vmlinuz
- Uncompress it self.
- organizes and takes control of the continued booting of system
- Checks and sets the console, reads BIOS settings
- initializes basic hardware interfaces.
- Drivers (included into the kernel) probe existing hardware and initialize it accordingly.
About the initrd
Early
userland and pivot_root.
- initial ram disk
- Filesystem image
- CPIO archive
- Compressed
- Early userland
- linuxrc script
- “fake” init
- Load drivers
- Pivot_root to real root fs.
- Distros provide creation tools
/sbin/init
Userland
entry point.
The parent of all other processus (PID number 1). Allocate VT’s and run rc to switch to default runlevel.
relies
on the /etc/inittab
file → Read the default runlevel
↓
/etc/init.d/boot
script → Main services
↓
starts
the /etc/init.d/rc script → Runlevel specific services
Runlevels implementation
About runlevels
System “profiles”.
- Identifiers for system state
- Numeric (most distros)
- 0 -> 6
- Used by init and rc
- Start/Stop services
- Enable/Disable multiuser
- /etc/inittab
- /etc/rcX.d/
Runlevels
The seven runlevels:
0 : System Halted.
1 : Singler User Mode.
2-5 : Custom levels used by distributions. Run services.
6 : System reboot.
/etc/inittab
Init
configuration file syntax:
id : runlevels : action : command
Some actions:
Action | Definitions |
---|---|
once | Run the command and continue to next entry |
wait | Run the command and wait for completion before continuing to the next entry. |
respawn | Run the command, continue to the next entry and restart the process if it dies. |
Working with runlevels
Common Commands
[root@linux
~]# runlevel
N 3
[root@linux
~]# who
-r
run-level
3 2011-09-21 08:35 last=S
[root@linux
~]# init
2
[root@linux
~]# telinit
1
[root@linux
~]# halt
[root@linux
~]# reboot
0 commentaires:
Post a Comment