SysV startup sequence
|OS startup sequence (SysV)
|At startup /sbin/init executes all instructions on /etc/inittab . This script at first switches to the default runlevel…
|… then it runs the following script (same for all runlevels) which configures peripheral hardware, applies kernel parameters, sets hostname, and provides disks initialization…
|… and then, for runlevel N, it calls the script/etc/init.d/rc N (i.e. with the runlevel number as parameter) which launches all services and daemons specified in the following startup directories:
The startup directories contain symlinks to the init scripts in /etc/init.d/ which are executed in numerical order. Links starting with K are called with argument stop, links starting with S are called with argument start.
lrwxrwxrwx. 1 root root 14 Feb 11 22:32 K88sssd -> ../init.d/sssd
lrwxrwxrwx. 1 root root 15 Nov 28 14:50 K89rdisc -> ../init.d/rdisc
lrwxrwxrwx. 1 root root 17 Nov 28 15:01 S01sysstat -> ../init.d/sysstat
lrwxrwxrwx. 1 root root 18 Nov 28 14:54 S05cgconfig -> ../init.d/cgconfig
lrwxrwxrwx. 1 root root 16 Nov 28 14:52 S07iscsid -> ../init.d/iscsid
lrwxrwxrwx. 1 root root 18 Nov 28 14:42 S08iptables -> ../init.d/iptables
The last script to be run is S99local -> ../init.d/rc.local ; therefore, an easy way to run a specific program on boot is to add it to this script file.
/etc/init.d/boot.local runs only at boot time, not when switching runlevel.
/etc/init.d/before.local (SUSE) runs only at boot time, before the scripts in the startup directories.
/etc/init.d/after.local (SUSE) runs only at boot time, after the scripts in the startup directories.
|To add or remove services at boot sequence:
||update-rc.d service defaults update-rc.d -f service remove
||chkconfig –add service chkconfig –del service
||Parameters supported by the init scripts
||Start the service
||Stop the service
||Restart the service (stop, then start)
||Display daemon PID and execution status
||Reload configuration if the service supports this option, otherwise restart the service
||Restart the service only if already running
||Reload service configuration
service service start (Red Hat) Start a service
rcservice start (SUSE)
||Single user / maintenance mode
||Multi-user mode (default)
||Multi-user mode without network
||Multi-user mode with network
||Unused, for custom use
||Multi-user mode with network and X(default)
||Single user / maintenance mode (usually accessed through runlevel 1)
The default runlevels are 2 3 4 5
|Display the previous and the current runlevel
|shutdown -h now
|Halt the system
|shutdown -r now
|Reboot the system
||Shut down the system in a secure way: all logged in users are notified via a message to their terminal, and login is disabled.
This command can be run only by the root user and by those users (if any) listed in
|shutdown -h 16:00 message
||Schedule a shutdown for 4 PM and send a warning message to all logged in users
||Non-root users that are listed in /etc/shutdown.allow can use this command to shut down the system
||Skip fsck on reboot
||Force fsck on reboot
||Cancel an already running shutdown
|POST (Power-On Self Test)
||Low-level check of PC hardware.
|BIOS(Basic I/O System)
||Detection of disks and hardware.
(GRand Unified Bootloader)
|GRUB stage 1 is loaded from the MBR and executes GRUB stage 2 from filesystem.GRUB chooses which OS to boot on.The chain loader hands over to the boot sector of the partition on which resides the OS.
The chain loader also mounts initrd, an initial ramdisk (typically a compressed ext2 filesystem) to be used as the initial root device during kernel boot; this make possible to load kernel modules that recognize hard drives hardware and that are hence needed to mount the real root filesystem. Afterwards, the system runs /linuxrc with PID 1. (From Linux 2.6.13 onwards, the system instead loads into memory initramfs, a cpiocompressed image, and unpacks it into an instance of tmpfs in RAM. The kernel then executes /init from within the image.)
||Kernel decompression into memory.Kernel execution.Detection of devices.
The real root filesystem is mounted on / in place of the initial ramdisk.
||Execution of init, the first process (PID 1).The system tries to execute in the following order:/sbin/init
If none of these succeeds, the kernel will panic.
||The system loads startup scripts and runlevel scripts.
||(Optional) The X Display Manager starts the X Server.
Some newer systems use UEFI (Unified Extensible Firmware Interface). UEFI does not use the MBR boot code; it has knowledge of partition table and filesystems, and stores its application files required for launch in a EFI System Partition, mostly formatted as FAT32.
After the POST, the system loads the UEFI firmware which initializes the hardware required for booting, then reads its Boot Manager data to determine which UEFI application to launch. The launched UEFI application may then launch another application, e.g. the kernel and initramfs in case of a boot loader like the GRUB.