linuxday16--startup process and kernel management

Source: Internet
Author: User
Tags md5 network function

CentOS 5 and 6 start-up process

Linux:kernel+rootfs

Kernel: Process management, memory management, network management, drivers, file systems, security features

Rootfs

glibc

Libraries: function sets, functions, calling interfaces

Procedure Call: Procedure (no return value is the result)

Functions Call: Function (must have return value that is the result)

Program

Kernel design Genre:

Single Core design: Centralized management, Linux

Integrate all functions into the same program;

Microkernel Design: Decentralized management, Windows,solaris

Each function is implemented using a separate subsystem;

Linux inside and Features:

Support modularity:. Ko

Supports dynamic loading and unloading of modules;

Part:

Core file:/boot/vmlinuz-version-release (compressed format)

RAMDisk

CentOS 5:/boot/initrd-version-release.img

CentOS 6:/boot/initrmfs-version-release.img

Module file:/lib/modules/version-release

CentOS System Start-up process: I Post: Power-on self-test;

Rom:cmos

Bios:basic Input&output System

Rom+ram

II boot Sequence: Boot load order

In order to find the boot device, the first device with a boot program is used for this boot device;

  Bootloader: Boot loader, program

Windows:ntloader

Linux:

Lilo:linux LOader (in early or Android phones)

Grub:grand Uniform Bootloader

GRUB 0.x:grub LEGAC

GRUB 1.X:GRUB2

Features: Provides a menu that allows the user to select a system to boot or a different kernel version, to load a user-selected kernel into a specific space in memory, unzip, expand, and give control of the system to the kernel;

  MBR: Master boot record (0 tracks 0 sectors)

446:bootloader

64:fat disk partition table (File system Allocation table)

2:55aa

Grub:

bootloader:1st stage is located in MBR (the main purpose is to find the second stage on the hard disk)

1.5stage (Help grub identify the partition file system) (matches the file system in the sector after the MBR is installed)

disk:2nd Stage

III Kernel:

Self-initialization:

Detect all the hardware devices that can be identified;

Load the hardware driver; (possibly with ramdisk load driver)

Mount the root file system in read-only mode;

The first application running the user control:/sbin/init

    

 Types of init programs:

Sysv:init,centos 5

Configuration file:/etc/inittab

Upstart:init,centos 6

Configuration files:/etc/inittab,/etc/init/*.conf

Systemd:systemd,centos 7

Configuration file:/usr/lib/systemd/system,/etc/systemd/system

RAMDisk

One of the features in the kernel: use buffering and caching to speed up access to files on disk;

RAMDisk-Ramfs

CentOS 5:INITRD, tool program: MKINITRD

CentOS 6:initramfs, tool program: Mkinitrd,dracut

System initialization (first half):

POST--Bootsequence (BIOS)-Bootloader (MBR)--Kernel (ramdisk)--ROOTFS (read-only)--init (depending on profile)

Iv/sbin/init

CentOS 5:

Operating level: For example system operation or maintenance and other application purposes, set:

0~6:7 A Level

0: Turn off the machine

1: Single user mode (root, no login required), one, maintenance mode;

2: Multi-user mode, will start the network function, but will not start NFS; maintenance mode;

3: Multi-user mode, normal mode, text interface;

4: Reserved level, can be the same as 3 levels;

5: Multi-user mode, Normal mode, graphical interface

6: Restart

Default Level:

3,5

Toggle Level

Init 0

viewing levels

RunLevel

Who-r

V Config file:/etc/inittab

Each row defines an action and the process that corresponds to it

Id:runlevel:action:process

Action

Wait: Switch to this level to run once;

Respawn: This process terminates, it re-pneumatics;

Initdefault: Set default runtime: Process omitted

Sysinit: Set the system initialization mode, here is generally designated/etc/rc.d/rc.sysinit;

...

Id:3:initdefaule: Set Default Level 3

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

L0:0WAIT:/ETC/RC.D/RC 0

L1:1WAIT:/ETC/RC.D/RC 1

...

L6:6WAIT:/ETC/RC.D/RC 6

Description RC 0--and means read/etc/rc.d/rc0.d

k*:k##* the order of operation; The smaller the number, the more first it runs; the smaller the number of services, usually dependent on other services;

S*:s##* the running order; the smaller the number, the more first it runs; the smaller the number of services, usually the services that are dependent on others;

For SRV in/etc/rc.d/rc0.d/k*;d o

$srv stop

Done

For SRV in/etc/rc.d/rc0.d/s*;d o

$srv Star

Done

chkconfig Command

View the start-up or ratio setting of the service at all levels;

Chkconfig--list Name

Add to:

SYSV service scripts are placed in/ETC/RC.D/INIT.D (/ETC/INIT.D)

Chkconfig--add Name

#!/bin/bash

#

# chkconfig:llll (0~6) level NN (s#) mm (k#)

Delete:

Chkconfig--del Name

Modify the specified link type

Chkconfig [--level levels] name <on|off|reset>

--level llll: Specify the level you want to set; omit default representation 2345

Note: Under normal level, the last service s99local is not linked to/etc/rc.d/init.d a service script, but instead points to the/etc/rc.d/rc.local script, so inconvenience or no need to write as service script placement in/etc/rc.d/ The rc.local file/etc/rc.d/rc.local run after the specified run level script, and can be customized according to the situation;

Tty1:2345:respawn:/usr/sbin/mingetty tty1

Tty2:2345:respawn:/usr/sbin/mingetty Tty2

...

Tty6:2345:respawn:/usr/sbin/mingetty Tty6

Mingetty will automatically invoke the login program

X:5:respawn:/etc/x11/prefdm-nodaemon

Vi/etc/rc.d/rc.sysinit: System Initialization script

(1) Design host name;

(2) Set the restore information;

(3) Activate Udev and SELinux

(4) Mount the file system defined in the/etc/fstab file;

(5) Detecting the root file system and re-mounting the root filesystem in read and write mode

(6) Setting the system clock

(7) Activate swap device

(8) Set kernel parameters according to/etc/sysctl.conf file

(9) Activating LVM and software RAID devices

(10) Loading drivers for additional devices

(11) Cleaning operation

Summary:/sbin/init----(/etc/inittab)--Set the default run level--run the system initial script, complete the system initialization--close the service you need to shut down, start the service that needs to start and set the login terminal

CentOS 6:

The INIT program is: Start its configuration file:

/etc/inittab,/etc/init/*.conf,

Note: The syntax of the/etc/init/*.conf configuration file follows the upstart profile syntax format, unlike the CentOS5

When you start the system, set its run level 1;

Enter single-user mode:

(1) Edit the Grub menu (select the title you want to edit and then use the e command)

(2) attach after selected kernel

1, S, s or single can be

(3) In the kernel line, type "B" command

(4) passwd

GRUB (Boot Loader):

Grub:grand Uniform Bootloader

GRUB 0.x:grub LEGAC

GRUB 1.X:GRUB2

Grub Legacy

Stagel:mbr

STAGE1_5:MBR sector, allowing bootloader in Stage1 to identify the filesystem on the partition where the stage2 resides

Sstage2: Disk partition (/boot/grub)

Configuration file:/boot/grub/grub.conf <--/etc/grub.conf

Stage2 and kernels are typically placed on a basic disk partition

Function

(1) menu and interactive interface available

A: Edit mode, for editing menus;

C: Command mode, interactive interface;

(2) Loading the user-selected kernel or operating system

Allow parameters to be passed to the kernel

To hide this menu

(3) provides a protection mechanism for the menu

Certification for the Edit menu

To enable authentication for the kernel or operating system

Note * If/boot is not partitioned (that is, boot is under root): Grub is looking for a file path of/boot/grub/grub.conf

If/boot standalone partition: Grub looks for file path (that is, bypass boot)/grub/grub.conf

How to identify the device:

(hd#,#)

hd#: Hard disk number, expressed in numbers; starting from 0

#: partition number, indicated by number; numbering starting from 0

(hd0,0) First hard disk first partition

grubd Command line interface

Help: Get assistance list

Help KEYWORD: Listing information in detail

Find (hd#,#)/path/to/somefile finding a file

Root (hd#,#)

Kernel/path/to/kernel_file: Set the kernel file for this boot time, and add many cmdline parameters that can be used by the kernel.

Example: init=/path/to/init,selinux=0

Initrd/path/to/kernel_file: Set RAMDisk to provide additional files for the selected kernel

Boot: booting the selected kernel;

Manually start the program on the GRUB command line interface;

Grub > Root (hd#,#)

Grub > Kernel/vmlinuz-version-release ro root=/dev/device

Grub > Initrd/initramfs-version-release.img

Grub > Boot

Configuration file:/boot/grub/grub.conf

Configuration Items

default=#: Specifies the default startup menu item, and the menu item (title) number starts at 0

timeout=#: Specifies the duration of the menu item Wait option selection

Splashimage= (hd#,#)/path/to/xpm_pic_file; Indicates the menu background picture file path

Hiddenmenu: Hide Menu

Password [--md5] STRING; menu Edit Authentication

Title Title: Defines the menu item "title". can appear multiple times

Root (hd#,#), Grub finds the device partition where the Stage2 and kernel files are located, for grub "root"

Kernel/path/to/vmlunz_file [PARAMETERS]: Boot kernel

Initrd/path/to/initramfs_file: Kernel-matched Ramfs file

Password [--MD5] STRING; authenticate when starting the selected kernel or operating system;

Grub-md5-crypt (OpenSSL) command

Enter single-user mode:

(1) Edit the Grub menu (select the title to edit, then use the e command);

(2) attach after selected kernel

1,s,s, or single can

(3) In the kernel line, type "b" command;

CENTOS7 Series Start-up process CentOS7 differs from version 6:

6:grub0.9 and Upstart

7:grub2 and Systemd

The main introduction of GRUB2 and Systemd Bar, the other start-up process almost the same

GRUB2

/etc/default/grub
/boot/grub2/grub.cfg
Grub2-mkconfig-o/boot/grub2/grub.cfg to generate GRUB2 configuration files
* Fix Grub in rescue mode
# Chroot/mnt/sysimage
# GRUB2-INSTALL/DEV/SDA
# Grub2-mkconfig-o/boot/grub2/grub.cfg

Booting the system on the GRUB command line
> Insmod XFS
> Set root= (hd0,1)
> Linux16/vmlinux-... root=/dev/sda2 selinux=0
> Initrd16/initramfs-...

Systemd

system startup and Server Daemon Manager, which is responsible for activating system resources, server processes, and other processes when the system is up or running.

SYSTEMD new Features:

Implementation of service parallel boot at System boot

Start the daemon on demand

Automated Service Dependency Management

Simultaneous socket-and d-bus-bus activation services

System State Snapshot

Unit: Represents different types of Systemd objects

/usr/lib/systemd/system: The primary startup script setting for each service, similar to the functionality of the 6 series/etc/init.d/directory

/run/systemd/system: Service scripts generated during system execution

/etc/systemd/system: Administrator-created execution script that functions like the/ETC/RC.D/RCN.D/SXX directory in the 6 series

Type:

Service Unit: (. Service), which defines system services

Target unit: (. target) for simulating implementation of RunLevel

Device unit: (. device), which defines which devices are recognized by the kernel

Mount unit: (. mount), defining file system mount points

Socket unit: (. Socket), which identifies the socket file used for interprocess communication, or delays the start of the service at system startup, enabling on-demand startup

Snapshot unit: (. Snapshot), managing system snapshots

Swap unit: (. Swap), used to identify swap devices

AutoMount unit: (. automount), automatic mount point for file system

Path unit: (. path), used to define a file or directory used in the file system, often used to delay the activation of the service when the file system changes

systemctl Command

Related Management tools:

sysctl: tools to modify kernel parameters

-P re-read into/etc/sysctl.conf

-a lists the kernel parameters that are currently in effect

-W Net.ipv4.ip_forward = 1 immediate effect

Uname

-R: Show kernel version number

-A: Show All information

-N: Display host name

lsmod: Displays the modules that have been loaded

modinfo: Display the details of the module

-N: Show module path

-P: Display module parameters

-A: Display module author

-D: Display module description information

-L: Shows the protocol that the module follows

modprobe: Load Module

-R: Unload module

depmod: kernel Module Dependency file and System Information mapping file Generation tool

insmod: Specifies the load module file but does not automatically resolve the dependent module

rmmod: Uninstalling the module

Time cmd detection command execution time spent

lscpu: Viewing CPU information

LSPCI: View PCI-related information

LSUSB: View USB-related information

lsblk: viewing block device-related information

Hal-device: View All hardware information (centos6.x)

linuxday16--startup process and kernel management

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.