Linux startup process details

Source: Internet
Author: User
1. the system loads the bios and loads coms through the bios. the hardware information of the host is obtained from the settings in coms, then the bios conducts self-check. 2. the bios reads the MBR through the INT13 middle-end function of the hardware, and the bootloader is loaded by the MBR. 1. bootloader can be installed in the root partition and magnetic field of the file system...

 

1. the system loads the bios and loads coms through the bios. the hardware information of the host is obtained from the settings in the coms, and the bios performs self-check.

2. the bios reads MBR through the INT 13 middle-end function of the hardware, and the MBR loads bootloader.

1. bootloader can be installed on the root partition of the file system and the MBR of the disk, in the environment where multiple systems are started, such as windows

In combination with linux, you must first install windows and then linux, because windows will install bootloader on both the MBR and the root partition of the system by default, during linux installation, you can choose to install bootloader to MBR or choose not to install it. in multiple boot environments, MBR is often overwritten by bootloader of different systems.

2. main functions of bootloader:

1. provide options: for multi-boot

2. load the system kernel

3. transfer another bootloader

3. by default, the windows bootloader does not have the transfer function. Therefore, we first install windows and then install linux, so that the linux bootloader overwrites the bootloader installed on the MBR by windows, in this way, we can use bootloader to start linux or the bootloader that can be transferred to windows to start windows.

3. bootloader loads the kernel, decompress the kernel in the memory, and use the kernel function to drive various hardware devices.

Main work of kernel: 1. Hardware probe 2. driver initialization 3. loading the root file system in read-only mode 4. starting the init process

All information about kernel startup is stored in/var/log/demesg.

The position of boot cannot be lvm or raid (soft). The maximum value is raid1. The first 446 bytes of MBR are not redundant and other drivers are loaded, otherwise, the kernel cannot be loaded.

1. the kernel is placed in the/boot directory. driver kernels of some devices are loaded in modular mode, and these modules are placed in the/lib/modules Directory, therefore, when installing the system,/lib and/must be in the same partition, because the kernel reads the module load by mounting the root, and the root directory is mounted in read-only mode during the boot process.

2. the kernel contains only drivers of the basic device, while others are made into modules and placed in/lib/modules for dynamic loading. if the/directory is on a special device, such as a SATA hard disk, on LVM or RAID, the kernel does not have drivers built into these devices. at this time, the kernel needs to use initrd to mount the root.

3. initrd is called a virtual file system, which has various built-in drivers. it has the significance of providing drivers to ensure smooth mounting/directory of Inner nuclear energy, the initrd version must be the same as the kernel version. Initrd is not always used. for example, when the/file system is on the hard disk of the IDE interface, the kernel is directly mounted.

4. start the init process. init reads the/etc/inittab configuration file and completes a series of tasks based on the content of the configuration file.

Main content of the inittab file

Id: 3: initdefault: Read system startup level

Si: sysinit:/etc/rc. d/rc. sysinit: execute the system initialization script

1. activate udev and selinux.

2. set kernel parameters by reading/etc/sysct1.conf.

3. set the system to always

4. load key ing

5. enable swap partition

6. set the host name

7. check the root file system and re-mount the root file system in read/write mode if no error occurs.

8. activate RAID and LVM devices.

9. disk quota

10. Mount other file systems

11. clear outdated file locks and PID files

Execute scripts at the corresponding startup level based on the startup level of the response, mainly at which Startup levels to start which system services,/etc/rc. d/rc {0, 1, 2, 3, 4, 5, 6} names starting with K are all closed. The smaller the number, the sooner it is closed, and all the values starting with S are enabled. the smaller the number, the earlier it starts, all these files are linked to/etc/init. d/directory to describe which programs are started

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

Set ctrl + alt + del.

Ca: ctrlaltdel:/sbin/shutdown-t3-r now

Two power options are set

Pf: powerfail:/sbin/shutdown-f-h + 2 "Power Failure; System Shutting Down"

Pr: 12345: powerokwait:/sbin/shutdown-c "Power Restored; Shutdown Cancelled"

Open six virtual terminals for the user. mingetty opens a virtual terminal and calls login to print a logon prompt.

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

If the startup level is fifth, the graphic desktop is started.

X: 5: respawn:/etc/X11/preofdm-nodaemon

5. run the/etc/rc. d/rc. local command. you can set the position of the startup program.

Configuration files used during boot

/Etc/modprobe. conf

/Etc/sysconfig /*

The main configuration files include:

Authconfig: Provides an identity authentication mechanism, whether to use/etc/passwd,/etc/shadow to provide identity authentication,

/Etc/shadow encryption algorithm (MD5 by default), whether there are other identity authentication methods such as NIS and LDAP

Clock: set the system time zone

I18n: specifies the language family to use.

Network: Set network information

About bootloader

Since the MBR only has 512 bytes, the partition table occupies 64 bytes, and there are two bytes of check bit, only 446 bytes are left. can these 446 bytes store bootloader? In fact, bootloader

Loading requires two phases

Stage 1: minimum main program for loading bootloader

Stage 2: load the configuration file of bootloader

[Root @ server30 ~] # Ls-l/boot/grub/

Total 234

-Rw-r -- 1 root 63 Aug 6 device. map grub device file

-Rw-r -- 1 root 7584 Aug 6 e2fs_stage1_5 ext2/ext3 file system support

-Rw-r -- 1 root 7456 Aug 6 fat_stage00005 fat support

-Rw-r -- 1 root 6720 Aug 6 ffs_stage1_5 ffs support

-Rw ------- 1 root 812 Aug 6 grub. conf grub configuration file

-Rw-r -- 1 root 6720 Aug 6 iso9660_stage00005 supported

-Rw-r -- 1 root 8192 Aug 6 jfs_stage1_5 jfs support

Lrwxrwxrwx 1 root 11 Aug 6 :04 menu. lst->./grub. conf

-Rw-r -- 1 root 6880 Aug 6 minix_stage00005 mini file system support

-Rw-r -- 1 root 9248 Aug 6 reiserfs_stage1_5 reiserfs file system support

-Rw-r -- 1 root 32428 Jan 5 2007 splash.xpm.gz boot image

-Rw-r -- 1 root 512 Aug 6 stage1 stage 1 description

-Rw-r -- 1 root 104988 Aug 6 stage2 stage 2 description

-Rw-r -- 1 root 7072 Aug 6 ufs2_stage00005 ufs file system support

-Rw-r -- 1 root 6272 Aug 6 vstafs_stage00005 vstafs support

-Rw-r -- 1 root 8904 Aug 6 xfs_stage00005 xfs support

About GRUB, grub. conf

Default = 0 indicates the title used for boot. The first title is used by default.

Timeout = if title is not selected after 5 5s delay, the first title will be used to enter the system by default.

Splashimage = (hd0, 0)/grub/splash.xpm.gz boot image (640*480 14bit color, save as xpm and compress it with gzip)

Hiddenmenu hide titile

Title Red Hat Enterprise Linux Server (2.6.18-164. el5) title name

Root (hd0, 0) is the first partition of the first disk. grub considers all disks as hd devices, and the disk number and partition number start from 0.

Kernel/vmlinuz-2.6.18-164.el5 ro root =/dev/vol0/root rhgb quiet kernel name and location, root specifies the root directory, rhgb is displayed as color

Quiet, does not display the output of the information detected by the kernel

Initrd/initrd-2.6.18-164.el5.img initrd name and placement

Grub encryption grub-md5-crypt

Write under hiddenmenu

Password -- md5 ciphertext

Grub damage due to misoperations

1. enter the grub command mode root (hd0, 0); setup (hd0); quite

2. grub-install -- root-directory =/(the directory here is the parent directory of boot)/dev/sda

Dd if =/dev/sda of =/backup/mbr bs = 512 count = 1 backup MRB

Dd if =/dev/zero of =/dev/sda bs = 512 count = 1 destroy MBR, all partition information on the disk and bootloader will be deleted

This article is from the "growth full record" blog

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.