Linux system boot up process

Source: Internet
Author: User
Tags uuid

Linux boot-up process:

1. Press the power button

Supplementary: The main hardware of computer case is: motherboard, hard disk, optical drive, CPU, memory, video card, sound card, network card

2. Initializing and detecting hardware using the BIOS program

BIOS basic input/output system

CMOS Semiconductor metal oxides

Detects and sets the CPU, memory, graphics card, hard disk, and various chips

Find boot media (local hard drive, optical drive I, USB flash drive, PXE chip remote boot)

Load the BIOS program, get the boot order, find the first boot device;

A boot, immediately press the ' Del ' key (desktop), the virtual machine is pressed ' F2 ' key, the notebook is pressed ' F1 ' or ' F2 ' key (depending on the machine), the server is press ' key

Hard disk boot (HDD), disc mirroring boot (CD-ROM), USB device boot (USB), network boot (PXE)

3. Load bootstrapper MBR (0-side 0-Channel 1-sector, 512-byte total) and grub boot

Boot program 446 bytes

Disk partition 64 bytes

End Identity 2 bytes

The load Stage1,stage1 is typically located in the MBR for loading stage2

Load stage1.5 for file system identification

Core program for loading Stage2,grub

Note: The stage1.5 and Stage2 files are located in the/boot/grub directory

Loading the Linux kernel with the/boot/grub/grub.conf configuration file

Read the MBR area information of the first boot device, there is grub, Lilo boot program;

The boot loader in the MBR bootloader reads the partition table, locates the location of the (master) boot partition, loads the Linux kernel

The relationship between MBR and superblock?

Stage1--->stage2--> load file system driver, you can know the files in the/boot partition.

4. Kernel boot

Load Linux kernel vmlinuz,vmlinuz is a gzip compressed file that needs to be unpacked with gzip when loading

Load initrd*.img,init*.img, usually a driver that loads device modules and disk interfaces such as USB,LVM,RAID,SCSI

System.map, the corresponding table of system parameters

Load core, core start drive hardware; (Linux kernel and image image)

The BIOS also has a lot of drivers, it will know a lot of hardware. If the battery on the motherboard is not powered up, the parameters and data in the CMOS will be lost, but the default (default) setting will be loaded on each boot

After loading the grub.conf file, I found the kernel file, then loaded the Vmlinuz-2.6.18-194.el5, and there are some basic drivers and programs in the kernel file.

Initrd/initrd-2.6.39.4.img

Will initrd-2.6.39.4.img, take out some of the space from memory when the hard disk is used (RAMDisk), and then extract the Initrd-2.6.39.4.img file into the RAMDisk,

form a temporary root directory that contains the/etc,/bin,/lib,/dev,/sbin directory. There are many module drivers under the/lib.

Configuration file:/etc/groub.conf,/etc/fstab,/etc/inittab

5. Initialization and booting of the system (some scripts that need to be run)

Run the/sbin/init program for initialization (using files in configuration files/etc/inittab and/etc/init directories)

/etc/inittab Setting the default boot level

* Run/etc/rc.sysinit

@ Get network environment

@ Initialize Hardware

@ Set Host Name

@ Device Mapper and related initialization

@ Initialize LVM

@ File System Detection

@ Enable disk quotas and update quotas

@ Mount Device (Mount according to/etc/fstab profile)

@ Clear the Junk files generated during the boot process

@ Enable swap partition

@ Write information to the/VAR/LOG/DMESG file

* What to do when running/etc/rc.local \ \ Record Boot

* Start the related service at a set level and start the service using the program in the/ETC/RC*.D directory, where * represents 7 start-up runlevel of 0-6

The files in the/ETC/RC.D/RC*.D directory are composed of the start state (S = start, K = Not started), the boot sequence, and the start service program.

User Login

* Run/sbin/mingetty Login Program

User Login (enter user name and password)-use/etc/passwd and/etc/shadow to detect correctness

--Run/ETC/PROFILE,~/.BASH_PROFILE,~/.BASHRC,/ETC/BASHRC

Go to the user desktop, run the appropriate desktop program (GDM GNOME desktop, KDE KDE desktop, XDM boot x Windows)

6. Execute/sbin/init procedure, generate init process;

7. Init executes the/etc/rc.d/rc.sysinit file;

8. Launch the core of the external module/etc/modeprobe.conf;

9. Init performs the corresponding runlevel scripts;

10. init execution/etc/rc.d/rc.local;

===============

Decompression View Initrd-2.6.18-194.el5.img file:

# cd/boot/

# Mkdir/tmp/boot

# CP Initrd-2.6.18-194.el5.img/tmp/boot

# Cd/tmp/boot

# ls

Initrd-2.6.18-194.el5.img

# file Initrd-2.6.18-194.el5.img

Initrd-2.6.18-194.el5.img:gzip compressed data, from Unix, last Modified:thu Jul 12:04:10, max compression

# gunzip <initrd-2.6.18-194.el5.img >initrd.img

]# ls

Initrd-2.6.18-194.el5.img initrd.img

# file Initrd.img

Initrd.img:ASCII Cpio Archive (SVR4 with no CRC)

# Cpio-iv <initrd.img

..................... (omitted) ....... ........

# ls

Bin etc initrd-2.6.18-194.el5.img Lib Sbin sysroot

Dev init initrd.img proc Sys

# CD Lib

# ls has ext3 file system driver module

Ata_piix.ko Dm-mod.ko Ext3.ko Ohci-hcd.ko

Dm-log.ko Dm-raid45.ko firmware Scsi_mod.ko

Dm-mem-cache.ko Dm-region_hash.ko Jbd.ko Sd_mod.ko

Dm-message.ko Ehci-hcd.ko Libata.ko Uhci-hcd.ko

=======================================

11. Executes the/bin/login program, waiting for the user to log in.

==========================

When in the character interface (run Level 3), enter init 5 (or enter start X) in the terminal, you can re-enter the graphical interface (that is, run level 5)

[[Email protected] raid-lvm]# Init 5

Enter RunLevel 5 (graphical interface, if GNOME or KDE graphics suite is installed)

Init 0 shutdown

Init 6 Restart

Init 3 enters the file interface

[[email protected] raid-lvm]# start x (Start graphical interface x program)

[Email protected] raid-lvm]# Vim/etc/inittab

[[Email protected] raid-lvm]# Init 5

[[email protected] raid-lvm]# RunLevel view RunLevel

N 5

Mount in/etc/fstab, use the Blkid command to view the UUID number of the disk you want to mount:

# Blkid/dev/sda3

/dev/sda3:uuid= "C91c42d9-bbcb-4d3b-abf1-57943c05ee90" type= "swap"

Practice:

1) automatically set the alias rm= ' RM-FR ' when the system is powered on

# Vim ~/.BASHRC

Alias rm= ' Rm-fr '

2) What if I forget my password? Require access to single user mode to remove the root user password

E--Choose the second item-->e-->1-->b--

# passwd-d Root

3) Set the default level of the system to 3

# Vim/etc/inittab

Id:3:initdefault:

4) Mount/boot the partition from the/etc/fstab file and restart the computer for recovery

# df-th

# Vim/etc/fstab

Manual editing can

5) Delete the/etc/fstab file and restart the computer for recovery (in the following two cases, be careful to restart in the case of SELinux shutdown in/etc/selinux/config)

In the case of backup (CP or DD Backup)

# dd If=/etc/fstab Of=/desktop/fstab.bak bs=512 count=1

# Rm-rf/etc/fstab

# reboot

> Insert the optical drive into the rescue mode;

:

bash-4.1# fdisk-l \ \ To view the disk, locate the/boot partition/dev/sda3

# Mkdir/back

# mount/dev/sd3/back \ \ Mounts The boot partition/dev/sda3 to the new/back directory

# df-th

# Cd/back

# CD Desktop

# dd if=fstab.conf of=/back/etc/fstab bs=512 count=1

# CD/BACK/ETC

# CP fstab/etc/

# exit \ \ Enter the other home directory in rescue mode, you need to exit with exit

# reboot

In the case of no backup:

# Rm-rf/etc/fstab

# reboot

> Insert the optical drive into the rescue mode;

:

bash-4.1# fdisk-l \ \ To view the disk, locate the/boot partition/dev/sda3

# Mkdir/back

# mount/dev/sda3/back \ \ Mounts The boot partition/dev/sda3 to the new/back directory

# df-th

# CD/BACK/ETC

# VI fstab \ Can not use VIM in rescue mode, only with VI

Manually edit the content inside

: Wq exit ># Blkid/dev/sda3 >>/back/etc/fstab \ \ Find the UUID of/dev/sda3 and append to/back/etc/fstab, other disk-like operations

# Vi/back/etc/fstab

Edit the content manually and copy and paste the UUID number that you just appended, as follows:

UUID=00D6BC1F-DA72-4935-A69F-D79416B512FB/EXT4 Defaults 1 1

Uuid=e407d3ee-cf6b-4378-9af7-d64bbb20ce5c/boot EXT4 Defaults 1 2

UUID=C91C42D9-BBCB-4D3B-ABF1-57943C05EE90 swap swap defaults 0 0

: Wq

# CP fstab/etc/

# exit

# reboot

Lvchange-ay logical volume name \ \ Active

# Vim/etc/fstab--Automatically mount local mirror on boot

/root/Desktop/king/soft/rhel6-x86_64.iso/yum iso9660 loop 0 0

# mount-a--Manually mount the options inside the/etc/fstab


This article is from the "Lonely No Color" blog, please be sure to keep this source http://tenderness.blog.51cto.com/8855468/1904340

Linux system boot up process

Related Article

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.