Linux System Boot Process

Source: Internet
Author: User

System Boot Process:


Post (Power on Self test) hardware detection is not a problem, if it is hard disk boot will find the MBR (bootloader:446 bytes), through the MBR to find the partition and loading m, you need to load the boot directory of the partition, The partition where the boot directory resides is placed in the file system, the boot partition needs to be driven, and the Initramfs/file system driver is saved.



A template file is required before you can use the following fix

grub> Root (hd0,0)

grub> Setup (hd0)


System Boot Process:

1.POST (Power on auto test) hardware self-test

2. Read MBR (bootloader:446 byte disk partition: 64 byte partition flag bit: 2 bytes (55AA))

By reading the bootloader loaded into memory in the MBR, the bootloader program is usually grub,

Grub's main function is to load the system kernel (the menu option that goes to the operating system prompt), and the kernel on the boot partition can find the boot partition through the partition table (because the/boot partition needs to be created before the operating system is installed) and the/boot/ vmlinuz-2.6.32-696.el6.x86_64 the kernel file to extract and load the kernel, the kernel needs to boot the operating system after loading the memory (the kernel does not contain all the driver packages, so/boot/initramfs-2.6.32-696.el6.x86_ 64.img is another file that provides the operating system driver, which contains the driver of the filesystem, and the driver of the operating system/file system is in Initramfs, and the access INITRAMFS needs the operating system first, so there is a virtual file system to boot, That is, there is a virtual file system in Initramfs that can be loaded/partitioned to find the/sbin/init program to load the file system


Add: To view the contents of the Initramfs-2.6.32-696.el6.x86_64.img file:

First of all # file initramfs-2.6.32-696.el6.x86_64.img View files Type is gzip compressed file, compressed files need to view the file suffix name when extracting, so first to modify the file suffix named. gz.

1.MV initramfs-2.6.32-696.el6.x86_64.img initramfs-2.6.32-696.el6.x86_64.gz

2.gunzip initramfs-2.6.32-696.el6.x86_64.img Decompression

3.file initramfs-2.6.32-696.el6.x86_64 found file is of type Cpio compression type

4.cpio-tv < initramfs-2.6.32-696.el6.x86_64 view Compressed file internal content

5.cpio-idv < initramfs-2.6.32-696.el6.x86_64 unzip the file to the current folder


By looking at the iinitramfs-2.6.32-696.el6.x86_64 content you will find a directory structure similar to the operating system directory structure, and there are a large number of Ko suffix library files, including the driver for loading/file system


/etc/initab configuration file for REHL5

********************************************************************************************

[Email protected] grub]# Cat/etc/inittab

#

# Inittab This file describes how the INIT process should set up

# The system in a certain run-level.

#

# Author:miquel van Smoorenburg, <[email protected]>

# Modified for RHS Linux by Marc Ewing and Donnie Barnes

#


# Default RunLevel. The runlevels used by RHS is:

# 0-halt (do not set Initdefault to this)

# 1-single User mode

# 2-multiuser, without NFS (the same as 3, if you don't have networking)

# 3-full Multiuser mode

# 4-unused

# 5-x11

# 6-reboot (do not set Initdefault to this)

#

Id:5:initdefault:


# System initialization.

Si::sysinit:/etc/rc.d/rc.sysinit


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


# when our UPS tells us Power had failed, assume we have a few minutes

# of Power left. Schedule a shutdown for 2 minutes.

# This does, the course, assume you have Powerd installed and your

# UPS connected and working correctly.

PF::p owerfail:/sbin/shutdown-f-H +2 "Power Failure; System shutting down #UPS电源在失败前发送的警告信息, prompting the user to shut down after 2 minutes


# If Power was restored before the shutdown kicked in, cancel it.

Pr:12345:powerokwait:/sbin/shutdown-c "Power restored; Shutdown Cancelled "#如果UPS电源在关机前修复发送消息提示用户" Power recovery, shutdown cancel "



# 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

********************************************************************************************************

3. After loading the file system, try to drive all the hardware devices and execute the/SBIN/INIT program to get the default running information (Id:5:initdefault:)

4.init Program Execution/etc/rc.d/rc.sysinit

Si::sysinit:/etc/rc.d/rc.sysinit

5. Start the core service module, such as the operating interface 3, then locate the/etc/rc.d/rc3.d below to start the service module

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


([email protected] rc3.d]# pwd

/etc/rc.d/rc3.d

[[email protected] rc3.d]# ls

K01DNSMASQ K24irda k74ntpd k89rdisc s08iptables s13portmap s25netfs S55sshd S95anacron

K02AVAHI-DNSCONFD k35vncserver k80kdump k91capi s08mcstrans s14nfslock S25PCSCD S56cups S95ATD

K02networkmanager k35winbind k85mdmpd k99readahead_later s09isdn s15mdmonitor s26acpid S56rawdevices S97RHNSD

K05conman k50netconsole k87multipathd s02lvm2-monitor s10network S18RPCIDMAPD S26APMD S56XINETD S97YUM-UPDATESD

K05SASLAUTHD K69RPCSVCGSSD k88wpa_supplicant s04readahead_early s11auditd S19RPCGSSD S26haldaemon S80sendmail S98avahi-daemon

K05wdaemon k73ypbind k89dund s05kudzu s12restorecond s22messagebus S26hidd S85GPM S99firstboot

K10psacct k74ipmi k89netplugd s06cpuspeed s12syslog s23setroubleshoot s28autofs S90crond s99local

K20nfs k74nscd k89pand s08ip6tables s13irqbalance s25bluetooth s50hplip S90XFS S99SMARTD

)


K (Kill) file, indicating that the service is not started by default, the start of the file, indicating that the service is started by default, the number after the flag bit is the order of starting the service or shutting down the service

6. Booting to the last service will find that S99local executes another executable script that differs from other services

[Email protected] ~]# ll/etc/rc.d/rc3.d/

lrwxrwxrwx 1 root root 2-s99local. /rc.local #指向父目录的rc. local file

lrwxrwxrwx 1 root root 2-s99smartd. /INIT.D/SMARTD #指向父目录的init. D The SMATD service script below


[Email protected] ~]# cat/etc/rc.local

#!/bin/sh

#

# This script is executed *after* all and the other init scripts.

# can put your own initialization stuff in here if you don ' t

# want to does the full Sys V style init stuff.


Touch/var/lock/subsys/local


Centos7 need to manually add execute permissions to the file, CENTOS6 default has execute permissions, you can edit the script to enable the scripts to execute before booting

7. Execute the/bin/login program and wait for the user to log in

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


Respawn (regeneration),/sbin/mingetty login terminal cannot be killed


Linux system Boot Process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.