CentOS6 startup process

   Why put the reference of this person in front, mainly this person The big guy’s flow chart is too detailed. Although it is not necessary to understand such details, I still admire it. Not much to say, the picture above (open the picture in a new tab)

share picture

   Let’s start to briefly understand the startup process of CentOS6.

The first step, hardware startup stage

share picture

   Briefly talk about the process of this step: turn on the power; POST self-test; BIOS check the device startup sequence one by one; if it is a hard disk boot, read the MBR of the hard disk BootLoader. (MBR partition is default here, GPT partition is not considered for the time being)

   There are three main things you need to know about the BIOS startup sequence, MBR and BootLoader. Most people should know the BIOS boot sequence, so I won’t go into details.

(1).MBR

  MBR (Main Boot Record), is the 0 cylinder, 0 track, 1 sector (the first sector) of the hard disk, called the main The boot sector, also known as the master boot record. It consists of three parts: the main boot program (BootLoader), the hard disk partition table DPT (Disk Partition table) and the hard disk valid flag (55AA).

  Note: The default size of a sector of the hard disk is 512 bytes.

   The first part, the main boot program (BootLoader) occupies 446 bytes, which is responsible for loading from the active partition and running the system boot program.

   The second part, the hard disk partition table DPT occupies 64 bytes, there are 4 partition table entries, each partition table entry occupies 16 bytes, how many partitions in the hard disk and the size of each partition Are recorded in it.

   The third part, the hard disk valid flag, occupies 2 bytes and is fixed at 55AA. If this flag bit is 0xAA55, it is considered to be MBR.

(2).BootLoader

   Different systems have different main boot programs (BootLoader). Windows uses NTLDR (NT Loader, Windows NT series operating system), Bootmgr (Boot Manager, Windows Vista, 7, 8, 10), and Linux generally uses grub (also called grub legacy) and grub2.

  CentOS6 generally uses grub. GRUB (GRand Unified Bootloader) is a multi-operating system startup program from the GNU project.

The second step, GRUB boot phase

share pictures

   Briefly talk about the process of this step: GRUB program loads and executes and guides the kernel (kernel) program, there are three of them Stages.

  The files in the grub boot stage are all in the /boot/grub/ directory

(1).Stage1 stage

   This stage actually performs system installation When pre-written to the Bootloader program of the MBR. Its task is only to read (load) the contents of cylinder 0, track 0, and sector 2 of the hard disk (/boot/grub/stage1) and execute it.

?
1
2
[[emailprotected ] ~]# ll /boot/grub/stage1
-rw-r--r--. 1 root root 512 Mar 13 2018 /boot/grub/stage1

  In this stage, the hardware is initialized, RAM space (memory space) is prepared for Stage2, and Stage2 is read to RAM space (Stage1.5 stage should be involved). It is the entrance of Stage1.5 or Stage2, leading to Stage1.5 or Stage2.

   In addition, there is no ability to identify the file system at this stage.

(2).Stage1.5 stage

   This stage is the bridge between Stage1 and Stage2, has the ability to identify the partition file system, and then the grub program has the ability to access /boot/grub/stage2, and read it to the memory for execution.

?
1
2
3
4
5
6
7
8
[[email protected] ~]# ll -h /boot/grub/stage2   //more than 512 bytes
-rw-r--r--. 1 root root 124K Mar 21 2018 /boot/grub/stage2
[[email protected] ~]# ls /boot/grub/*stage1_5   //There are various file system formats
/boot/grub/e2fs_stage1_5 /boot/grub/minix_stage1_5
/boot/grub/fat_stage1_5 /boot/grub/reiserfs_stage1_5
< code class="csharp plain">/boot/grub/ffs_stage1_5 /boot/grub/ufs2_stage1_5
/boot/grub/iso9660_stage1_5 /boot/grub/vstafs_stage1_5
/boot/grub/jfs_stage1_5 /boot/grub/xfs_stage1_5

(3).Stage2 stage

   This stage will (initialize the hardware used in this stage, detect the memory image of the system,) parse the grub configuration file /boot/grub/grub.cnf, load the kernel image into the memory according to the configuration file, establish a virtual root file system through the initrd program, and finally call (transfer) the kernel

< div id="highlighter_336269" class="syntaxhighlighter csharp">

?

1
2
3
4
5
6 < /div>

7
8
9
10
11
12

< div class="line number13 index12 alt2"> 13

14
15
16
17
18
19
20
21
[[email protected] ~]# cat /boot/grub/grub.conf
# grub.conf generated by anaconda
#< /code>
# Note that you do not have to rerun grub after making c hanges to this file
# NOTICE: You have a /boot partition. This means that < /div>

# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/mapper/vg_centos6-lv_root
# initrd /initrd -[generic-]version.img
#boot=/dev/sda
default =0   //Set the default startup item as the first kernel
timeout=5   //The waiting time for menu items is 5 seconds
splashimage=( hd0,0)/grub/splash.xpm.gz   //Menu background image
< code class="csharp plain">hiddenmenu   //Hidden menu
//Sometimes there is a passwrod parameter here, which means what is the password to enter the emergency mode (single user mode), which can be a plain text password or an encrypted password

< div class="line number16 index15 alt1"> //For example, password --md5 $1$1S9Xy$1MuGZSoPc2vAtkW.jvz0X/, this means that the password entering the emergency mode is encrypted by MD5, and the encryption password is $1 $1S9Xy$1MuGZSoPc2vAtkW.jvz0X/

title CentOS 6 (2.6.32-642.el6.x86_64)  < /code> //Menu item name
< code class="csharp plain">root (hd0,0)   //grub Find the device partition where the stage2 file and the kernel file are located, and the root of grub. The first partition of the first hard disk
//Started kernel
kernel /vmlinuz- 2.6.32-642.el6.x86_64 ro root=/dev/mapper/vg_centos6-lv_root rd_NO_LUKS rd_NO_MD rd_LVM_LV=vg_centos6/lv_swap crashkernel=128M LANG=zh_CN.UTF-8 ro root=/dev/mapper/vg_centos6-lv_root rd_NO_LUKS rd_no_MD quiet
initrd /initramfs-2.6.32- 642.el6.x86_64.img   //The ramfs file matched by the kernel, img is the image file

The third step, the kernel boot phase

share picture

   briefly talk about this step The process: Load the driver through the virtual root file system in the memory, then switch to the real root file system, and execute the /sbin/init program.

Step four, init initialization phase (also called system initialization phase)

share picture

   Briefly talk about the process of this step: The /sbin/init program will read the /etc/inittab file to confirm the run level, and then execute /etc /rc.d/rc script, start the service under the corresponding /etc/rc.d/rc#.d/ directory (# is 0~6) according to the confirmed run level, and execute the system initialization script /etc/rc at the same time .sysinit (soft link, pointing to /etc/rc.d/rc.sysinit), and /etc/rc.local (soft link, pointing to /etc/rc.d/rc.local file) user-defined service ( script).

   There is an interesting place here. The files in the /etc/rc.d/ directory almost have corresponding soft links last time (that is, the /etc/ directory), the only one that is not /etc The /rc.d/init.d/ directory seems to be exactly the same as the /etc/init.d/ directory.

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 < /div>

16
[[emailprotected] ~]# ls -ld /etc/rc*
lrwxrwxrwx. 1 root root 7 Mar 13 2018 /etc/rc -> rc.d/rc
lrwxrwxrwx. 1 root root 10 Mar 13 2018 /etc/rc0.d -> rc.d/rc0.d
lrwxrwxrwx. 1 root root 10 Mar 13 2018 /etc/rc1.d -> rc.d/rc1.d
lrwxrwxrwx. 1 root root 10 Mar 13 2018 /etc/rc2.d -> rc.d/rc2.d
lrwxrwxrwx. 1 root root 10 Mar 13 2018 /etc/rc3.d -> rc.d/rc3.d
lrwxrwxrwx. 1 root root 10 Mar 13 2018 /etc/rc4.d -> rc.d/rc4.d
lrwxrwxrwx. 1 root root 10 Mar 13 2018 /etc/rc5.d -> rc.d/rc5.d
lrwxrwxrwx. 1 root root 10 Mar 13 2018 /etc/rc6.d -> rc.d/rc6.d

drwxr-xr-x. 10 root root 4096 Feb 18 02:17 /etc/rc.d
lrwxrwxrwx. 1 root root 13 Mar 13 2018 /etc/rc.local -> rc.d/rc.local < /div>

lrwxrwxrwx. 1 root root 15 Mar 13 2018 /etc/rc.sysinit -> rc.d/rc.sysinit
[[email protected] ~]# ls /etc/rc.d/

< div class="line number14 index13 alt1"> init.d rc0.d rc2.d rc4.d rc6.d rc.sysinit

rc rc1.d rc3.d rc5.d rc.local
[[email protected] ~]# diff -ruNa /etc/rc.d/init.d/ /etc/init.d/ div>

(1)./etc/inittab file

?
1
2
3
4

5

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 < /div>
[[emailprotected] ~] # cat /etc/inittab
# inittab is only used by upstart for the default runlevel.
# code>
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl- Alt-Delete is handled by /etc/init/control-alt-delete.conf
#
# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,< /code>
# with configuration in /etc/sysconfig/init.
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(5), init(8) , and initctl(8).
#
# Default runlevel. The runlevels used are:
# 0-halt (Do NOT set initdefault to this)
# 1-Single user mode
# 2-Multiuser, without NFS (The same as 3, if you do not have networking)
# 3-Full multiuser mode
< code class="csharp preprocessor"># 4-unused
# 5-X11

# 6-reboot (Do NOT set initdefault to this)
#
id:5:initdefault:

   Just look at the number in the last line of this file, I Here is 5, which means the startup level is 5.

   In addition, you also need to understand the startup level of the system:

    0   Shutdown

    1  Single user mode, maintenance mode, emergency mode, all can

>

    2  Multi-user mode, but no network

    3  Complete multi-user mode

    4   4  Reservation level, temporarily useless, don’t consider

5   Graphical interface, XWindows

    6   restart

(2)./etc/rc.d/rc#.d/ directory

   is executed at startup The /etc/rc.d/rc script will call the files in the /etc/rc.d/rc#.d/ directory

?
1
2
3
4
5
6 < /div>

7
8
[[email protected] ~]# ls /etc/rc.d/rc5.d/ < /div>

K01smartd

K01smartd

K50dnsmasq K73winbind K88sssd S01sysstat 24 S12rsysstat 24 S12rsysstat 24 S12rsysstat number3 index2 alt2"> K02oddjobd K02oddjobd K50xinetd div

K74ntpd K89netconsole S02lvm2-monitor S13cpuspeed S24rpcgssd 28 S24rpcgssd plain”>K05wdaemon K60nfs K75ntpdate K89rdisc S08ip6tables S13irqbalance S25blk-availability S50bluetooth S90crond

K10psacct K61nfs-rdma K75quota_nld K92pppoe-server S08iptables S13rpcbind S25cups S50kdump S95atd
K10saslauthd
K10saslauthd K69rpcsvcgssd K76ypbind K95 firstboot S10network S15mdmonitor 25 S15mdmonitornet S15mdmonitornet line number7 index6 alt2"> K15htcacheclean K71cgred K84wpa_supplicant K95rdma S11auditd S22messagebus S22messagebus S22messagebus S26acpid dvagent S26acpid sp. de class="csharp plain">K15httpd K72cgconfig K87restorecond K99rngd S23NetworkManager S26haldaemon S80postfix
div>

Files starting with   K: the service to be stopped (script), start to close from 01, the smaller the number, the priority is to close

The file starting with   S: the service (script) to be started, from 01 Start to start, the smaller the number, the more priority it is to start

   These files are actually soft links, pointing to files in the /etc/rc.d/init.d/ directory

?
1
2
[[emailprotected] ~]# ll / etc/rc.d/rc5.d/K0 1smartd
lrwxrwxrwx. 1 root root 16 Mar 13 2018 /etc/rc.d/rc5.d/K01smartd -> ../init.d/smartd

< strong>第五步、启动终端

分享图片

  最后一步就是用户登录了,没什么说的。

  为什么把这位的参考放在前面,主要是这位大佬的流程图太详细了。虽说不一定要了解这么详细,但还是很佩服啊。不多说,上图(在新标签中打开图片)

分享图片

  下面开始简单的了解一下CentOS6的启动流程吧。

 第一步、硬件启动阶段

分享图片

  简单说一下这一步的流程:打开电源;POST自检;BIOS逐一排查设备启动顺序;如果是硬盘启动,读取硬盘的MBR的BootLoader。 (这里默认MBR分区,暂不考虑GPT分区)

  这里主要有三个需要了解的地方BIOS启动顺序、MBR和BootLoader。 BIOS启动顺序大部分人应该都知道,我就不赘述了。

(1).MBR

  MBR(Main Boot Record),是硬盘的0柱面,0磁道、1扇区(第一个扇区),称为主引导扇区,也称为主引导记录。它由三部分组成:主引导程序(BootLoader)、硬盘分区表DPT(Disk Partition table)和硬盘有效标志(55AA)。

  注:硬盘默认一个扇区大小为512字节。

  第一部分,主引导程序(BootLoader)占446个字节,负责从活动分区中装载,并运行系统引导程序。

  第二部分,硬盘分区表DPT占64个字节,有4个分区表项,每个分区表项占16个字节,硬盘中分区有多少以及每一个分区的大小都记录在其中。

  第三部分,硬盘有效标志,占2个字节,固定为55AA。如果这个标志位0xAA55,就认为这个是MBR。

(2).BootLoader

  不同的系统有不同的主引导程序(BootLoader)。 Windows使用的是NTLDR(NT Loader,Windows NT系列操作系统)、Bootmgr(Boot Manager,Windows Vista,7,8,10),Linux一般使用的是grub(也叫grub legacy)和grub2。

  CentOS6一般使用的是grub。 GRUB(GRand Unified Bootloader)是一个来自GNU项目的多操作系统启动程序。

第二步、GRUB引导阶段

分享图片

 

  简单说一下这一步的流程:GRUB程序加载执行并引导kernel(内核)程序,其中有三个阶段。

  grub引导阶段的文件都在/boot/grub/目录下

(1).Stage1阶段

  这一阶段其实执行的就是系统安装时预先写入到MBR的Bootloader程序。它的任务仅是读取(加载)硬盘的0柱面,0磁道,2扇区的内容(/boot/grub/stage1)并执行。

?
1
2
[[email protected] ~]# ll /boot/grub/stage1
-rw-r--r--. 1 root root 512 Mar 13  2018 /boot/grub/stage1

  这一阶段,使硬件初始化,为Stage2准备RAM空间(内存空间),读取Stage2到RAM空间(应该涉及到了Stage1.5阶段)。就是Stage1.5阶段或Stage2阶段的入口,引导进入Stage1.5阶段或Stage2阶段。

  另外,这一阶段并没有识别文件系统的能力。  

(2).Stage1.5阶段

  这一阶段是Stage1阶段和Stage2阶段的桥梁,具有识别分区文件系统的能力,此后grub程序便有能力去访问/boot/grub/stage2,并将其读取到内存执行。

?
1
2
3
4
5
6
7
8
[[email protected] ~]# ll -h /boot/grub/stage 2   //大于512字节了
-rw-r--r--. 1 root root 124K Mar 21  2018 /boot/grub/stage2
[[email protected] ~]# ls /boot/grub/*stage1_5   //有各种文件系统格式
/boot/grub/e2fs_stage1_5     /boot/grub/minix_stage1_5
/boot/grub/fat_stage1_5      /boot/grub/reiserfs_stage1_5
/boot/grub/ffs_stage1_5      /boot/grub/ufs2_stage1_5
/boot/grub/iso9660_stage1_5  /boot/grub/vstafs_stage1_5
/boot/grub/jfs_stage1_5      /boot/grub/xfs_stage1_5

(3).Stage2阶段

  这一阶段会(初始化本阶段需要用到的硬件,检测系统的内存映像,)解析grub的配置文件/boot/grub/grub.cnf,根据配置文件加载内核镜像到内存中,通过initrd程序建立虚拟根文件系统,最后调用(转交)内核

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[[email protected] ~]# cat /boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_centos6-lv_root
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default =0   //设置默认启动项为第一个内核
timeout=5   //菜单项等待选项时间为5秒
splashimage=(hd0,0)/grub/splash.xpm.gz   //菜单背景图片
hiddenmenu   //隐藏菜单
//这里有时候会有passwrod参数,意思是进入急救模式(单用户模式)的密码是多少,可以是明文密码,可以是加密密码
//例如password --md5 $1$1S9Xy$1MuGZSoPc2vAtkW.jvz0X/,这代表进入急救模式的password经过MD5加密,加密密码为$1$1S9Xy$1MuGZSoPc2vAtkW.jvz0X/
title CentOS 6 (2.6.32-642.el6.x86_64)   //菜单项名称
         root (hd0,0)   //grub查找stage2文件及kernel文件所在设备分区,grub的根。第一块硬盘的第一个分区
         //启动的内核
         kernel /vmlinuz-2.6.32-642.el6.x86_64 ro root=/dev/mapper/vg_centos6-lv_root rd_NO_LUKS rd_NO_MD rd_LVM_LV=vg_centos6/lv_swap crashkernel=128M LANG=zh_CN.UTF-8 rd_LVM_LV=vg_centos6/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
         initrd /initramfs-2.6.32-642.el6.x86_64.img   //内核匹配的ramfs文件,img是镜像文件

第三步、内核引导阶段

分享图片

  简单说一下这一步的流程:通过内存中的虚拟根文件系统,加载驱动,然后切换到真正的根文件系统,并执行/sbin/init程序。

第四步、init初始化阶段(又叫系统初始化阶段)

分享图片

  简单说一下这一步的流程:/sbin/init程序会读取/etc/inittab文件确认运行级别,然后执行/etc/rc.d/rc脚本,根据确认的运行级别启动对应/etc/rc.d/rc#.d/目录下的服务(#为0~6),与此同时执行系统初始化脚本/etc/rc.sysinit(软链接,指向/etc/rc.d/rc.sysinit),还会加载/etc/rc.local(软链接,指向/etc/rc.d/rc.local文件)用户自定义服务(脚本)。

  这里有个有意思的地方,/etc/rc.d/目录下的文件几乎在上一次都有相应的软链接(也就是/etc/目录下),唯一没有的/etc/rc.d/init.d/目录又似乎与/etc/init.d/目录完全相同

?
1
2
3
4
5
6
7
8
9

< div class="line number10 index9 alt1"> 10

11
12
13
14
15
16
[[email protected] ~]# ls -ld /etc/rc*
lrwxrwxrwx.  1 root root    7 Mar 13  2018 /etc/rc -> rc.d/rc
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc0.d -> rc.d/rc0.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc1.d -> rc.d/rc1.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc2.d -> rc.d/rc2.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc3.d -> rc.d/rc3.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc4.d -> rc.d/rc4.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc5.d -> rc.d/rc5.d
lrwxr wxrwx.  1 root root   10 Mar 13  2018 /etc/rc6.d -> rc.d/rc6.d
drwxr-xr-x. 10 root root 4096 Feb 18 02:17 /etc/rc.d
lrwxrwxrwx.  1 root root   13 Mar 13  2018 /etc/rc.local -> rc.d/rc.local
lrwxrwxrwx.  1 root root   15 Mar 13  2018 /etc/rc.sysinit -> rc.d/rc.sysinit
[[email protected] ~]# ls /etc/rc.d/
init.d  rc0.d  rc2.d  rc4.d  rc6.d     rc.sysinit
rc      rc1.d  rc3.d  rc5.d  rc.local
[[email protected] ~]# diff -ruNa /etc/rc.d/init.d/ /etc/init.d/

(1)./etc/inittab文件

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 < /div>

21
22
23
24
25
26
27
[[email protected] ~]# cat /etc/inittab
# inittab is only used by upstart for the default runlevel.
#
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/in it/control-alt-delete.conf
#
# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
# with configuration in /etc/sysconfig/init.
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(5), init(8), and initctl(8).
#
# Default runlevel. The runlevels used are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
#
id:5:initdefault:

  这个文件直接看最后一行的那个数字就好了,我这里是5,就代表启动级别是5。

  另外,还需要了解下系统的启动级别:

    0  关机

    1  单用户模式、维护模式、急救模式,都可以

    2  多用户模式,但没有网络

    3  完整的多用户模式

    4  预留级别,暂时没用,不用考虑

    5  图形界面,XWindows

    6  重启

(2)./etc/rc.d/rc#.d/目录

  在启动时执行的/etc/rc.d/rc脚本,会调用/etc/rc.d/rc#.d/目录下的文件

?
1
2
3
4
5
6
7
8
[[email protected] ~]# ls /etc/rc.d/rc5.d/
K01smartd        K50dnsmasq     K73winbind         K88sssd          S01sysstat       S12rsyslog         S24nfslock           S26udev-post       S82abrt-ccpp
K02oddjobd       K50xinetd      K74ntpd            K89netconsole    S02lvm2-monitor  S13cpuspeed        S24rpcgssd           S28autofs          S82abrtd
K05wdaemon       K60nfs         K75ntpdate         K89rdisc         S08ip6table s     S13irqbalance      S25blk-availability  S50bluetooth       S90crond
K10psacct        K61nfs-rdma    K75quota_nld       K92pppoe-server  S08iptables      S13rpcbind         S25cups              S50kdump           S95atd
K10saslauthd     K69rpcsvcgssd  K76ypbind          K95firstboot     S10network       S15mdmonitor       S25netfs             S55sshd            S99certmonger
K15htcacheclean  K71cgred       K84wpa_supplicant  K95rdma          S11auditd        S22messagebus      S26acpid             S70spice-vdagentd  S99local
K15httpd         K72cgconfig    K87restoreco nd     K99rngd          S11portreserve   S23NetworkManager  S26haldaemon         S80postfix

  K开头的文件:要停止的服务(脚本),从01开始关闭,数字越小越优先关闭

  S开头的文件:要启动的服务(脚本),从01开始启动,数字越小越优先启动

  这些文件其实都是软链接,指向的都是/etc/rc.d/init.d/目录下的文件

?
1
2
[[email protected] ~]# ll /etc/rc.d/rc5.d/K01smartd
lrwxrwxrwx. 1 root root 16 Mar 13  2018 /etc/rc.d/rc5.d/K01smartd -> ../init.d/smartd

第五步、启动终端

分享图片

  最后一步就是用户登录了,没什么说的。

  为什么把这位的参考放在前面,主要是这位大佬的流程图太详细了。虽说不一定要了解这么详细,但还是很佩服啊。不多说,上图(在新标签中打开图片)

分享图片

  下面开始简单的了解一下CentOS6的启动流程吧。

 第一步、硬件启动阶段

分享图片

  简单说一下这一步的流程:打开电源;POST自检;BIOS逐一排查设备启动顺序;如果是硬盘启动,读取硬盘的MBR的BootLoader。 (这里默认MBR分区,暂不考虑GPT分区)

  这里主要有三个需要了解的地方BIOS启动顺序、MBR和BootLoader。 BIOS启动顺序大部分人应该都知道,我就不赘述了。

(1).MBR

  MBR(Main Boot Record),是硬盘的0柱面,0磁道、1扇区(第一个扇区),称为主引导扇区,也称为主引导记录。它由三部分组成:主引导程序(BootLoader)、硬盘分区表DPT(Disk Partition table)和硬盘有效标志(55AA)。

  注:硬盘默认一个扇区大小为512字节。

  第一部分,主引导程序(BootLoader)占446个字节,负责从活动分区中装载,并运行系统引导程序。

  第二部分,硬盘分区表DPT占64个字节,有4个分区表项,每个分区表项占16个字节,硬盘中分区有多少以及每一个分区的大小都记录在其中。

  第三部分,硬盘有效标志,占2个字节,固定为55AA。如果这个标志位0xAA55,就认为这个是MBR。

(2).BootLoader

  不同的系统有不同的主引导程序(BootLoader)。 Windows使用的是NTLDR(NT Loader,Windows NT系列操作系统)、Bootmgr(Boot Manager,Windows Vista,7,8,10),Linux一般使用的是grub(也叫grub legacy)和grub2。

  CentOS6一般使用的是grub。 GRUB(GRand Unified Bootloader)是一个来自GNU项目的多操作系统启动程序。

第二步、GRUB引导阶段

分享图片

 

  简单说一下这一步的流程:GRUB程序加载执行并引导kernel(内核)程序,其中有三个阶段。

  grub引导阶段的文件都在/boot/grub/目录下

(1).Stage1阶段

  这一阶段其实执行的就是系统安装时预先写入到MBR的Bootloader程序。它的任务仅是读取(加载)硬盘的0柱面,0磁道,2扇区的内容(/boot/grub/stage1)并执行。

?
1
2
[[email protected] ~]# ll /boot/grub/stage1
-rw-r--r--. 1 root root 512 Mar 13  2018 /boot/grub/stage1

  这一阶段,使硬件初始化,为Stage2准备RAM空间(内存空间),读取Stage2到RAM空间(应该涉及到了Stage1.5阶段)。就是Stage1.5阶段或Stage2阶段的入口,引导进入Stage1.5阶段或Stage2阶段。

  另外,这一阶段并没有识别文件系统的能力。  

(2).Stage1.5阶段

  这一阶段是Stage1阶段和Stage2阶段的桥梁,具有识别分区文件系统的能力,此后grub程序便有能力去访问/boot/grub/stage2,并将其读取到内存执行。

?
1
2
3
4
5
6
7
8
[[email protected] ~]# ll -h /boot/grub/stage2   //大于512字节了
-rw-r--r--. 1 root root 124K Mar 21  2018 /boot/grub/stage2
[[email protected] ~]# ls /boot/grub/*stage1_5   //有各种文件系统格式
/boot/grub/e2fs_stage1_5     /boot/grub/minix_stage1_5
/boot/grub/fat_stage1_5      /boot/grub/reiserfs_stage1_5
/boot/grub/ffs_stage1_5      /boot/grub/ufs2_stage1_5
/boot/grub/iso9660_stage1_5  /bo ot/grub/vstafs_stage1_5
/boot/grub/jfs_stage1_5      /boot/grub/xfs_stage1_5

(3).Stage2阶段

  这一阶段会(初始化本阶段需要用到的硬件,检测系统的内存映像,)解析grub的配置文件/boot/grub/grub.cnf,根据配置文件加载内核镜像到内存中,通过initrd程序建立虚拟根文件系统,最后调用(转交)内核

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2 0
21
[[email protected] ~]# cat /boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_centos6-lv_root
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default =0   //设置默认启动项为第一个内核
timeout=5   //菜单项等待选项时间为5秒
splashimage=(hd0,0)/grub/splash.xpm.gz   //菜单背景图片
hiddenmenu   //隐藏菜单
//这里有时候会有passwrod参数,意思是进入急救模式(单用户模式)的密码是多少,可以是明文密码,可以是加密密码
//例如password --md5 $1$1S9Xy$1MuGZSoPc2vAtkW.jvz0X/,这代表进入急救模式的password经过MD5加密,加密密码为$1$1S9Xy$1MuGZSoPc2vAtkW.jvz0X/
title CentOS 6 (2.6.32-642.el6.x86_64)   //菜单项名称
         root (hd0,0)   //grub查找stage2文件及kernel文件所在设备分区,grub的根。第一块硬盘的第一个分区
         //启动的内核
         kernel /vmlinuz-2.6.32-642.el6.x86_64 ro root=/dev/mapper/vg_centos6-lv_root rd_NO_LUKS rd_NO_MD rd_LVM_LV=vg_centos6/lv_swap crashkernel=128M LANG=zh_CN.UTF-8 rd_LVM_LV=vg_centos6/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
         initrd /initramfs-2.6.32-642.el6.x86_64.img   //内核匹配的ramfs文件,img是镜像文件

第三步、内核引导阶段

分享图片

  简单说一下这一步的流程:通过内存中的虚拟根文件系统,加载驱动,然后切换到真正的根文件系统,并执行/sbin/init程序。

第四步、init初始化阶段(又叫系统初始化阶段)

分享图片

  简单说一下这一步的流程:/sbin/init程序会读取/etc/inittab文件确认运行级别,然后执行/etc/rc.d/rc脚本,根据确认的运行级别启动对应/etc/rc.d/rc#.d/目录下的服务(#为0~6),与此同时执行系统初始化脚本/etc/rc.sysinit(软链接,指向/etc/rc.d/rc.sysinit),还会加载/etc/rc.local(软链接,指向/etc/rc.d/rc.local文件)用户自定义服务(脚本)。

  这里有个有意思的地方,/etc/rc.d/目录下的文件几乎在上一次都有相应的软链接(也就是/etc/目录下),唯一没有的/etc/rc.d/init.d/目录又似乎与/etc/init.d/目录完全相同

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[[email protected] ~]# ls -ld /etc/rc*
lrwxrwxrwx.  1 root root    7 Mar 13  2018 /etc/rc -> rc.d/rc
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc0.d -> rc.d/rc0.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc1.d -> rc.d/rc1.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc2.d -> rc.d/rc2.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc3.d -> rc.d/rc3.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc4.d -> rc.d/rc4.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc5.d -> rc.d/rc5.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc6.d -> rc.d/rc6.d
drwxr-xr-x. 10 root root 4096 Feb 18 02:17 /etc/rc.d
lrwxrwxrwx.  1 root root   13 Mar 13  2018 /etc/rc.local -> rc.d/rc.local
lrwxrwxrwx.  1 root root   15 Mar 13  2018 /etc/rc.sysinit -> rc.d/rc.sysinit
[[email protected] ~]# ls /etc/rc.d/
init.d  rc0.d  rc2.d  rc4.d  rc6.d     rc.sysinit
rc      rc1.d  rc3.d  rc5.d  rc.local
[[email protected] ~]# diff -ruNa /etc/rc.d/init.d/ /etc/init.d/

(1)./etc/inittab文件

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[[email protected] ~]# cat /etc/inittab
# inittab is only used by upstart for the default runlevel.
#
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
#
# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
# with configuration in /etc/sysconfig/init.
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(5), init(8), and initctl(8).
#
# Default runlevel. The runlevels used are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this )
#
id:5:initdefault:

  这个文件直接看最后一行的那个数字就好了,我这里是5,就代表启动级别是5。

  另外,还需要了解下系统的启动级别:

    0  关机

    1  单用户模式、维护模式、急救模式,都可以

    2  多用户模式,但没有网络

    3  完整的多用户模式

    4  预留级别,暂时没用,不用考虑

    5  图形界面,XWindows

    6  重启

(2)./etc/rc.d/rc#.d/目录

  在启动时执行的/etc/rc.d/rc脚本,会调用/etc/rc.d/rc#.d/目录下的文件

?
1
2
3
4
5
6
7
8
[[email protected] ~]# ls /etc/rc.d/rc5.d/
K01smartd        K50dnsmasq     K73winbind         K88sssd          S01sysstat       S12rsyslog         S24nfslock           S26udev-post       S82abrt-ccpp
K02oddjobd       K50xinetd      K74ntpd            K89netconsole    S02lvm2-monitor  S13cpuspeed        S24rpcgssd           S28autofs          S82abrtd
K05wdaemon       K60nfs         K75ntpdate         K89rdisc         S08ip6tables     S13irqbalance      S25blk-availability  S50bluetoo th       S90crond
K10psacct        K61nfs-rdma    K75quota_nld       K92pppoe-server  S08iptables      S13rpcbind         S25cups              S50kdump           S95atd
K10saslauthd     K69rpcsvcgssd  K76ypbind          K95firstboot     S10network       S15mdmonitor       S25netfs             S55sshd            S99certmonger
K15htcacheclean  K71cgred       K84wpa_supplicant  K95rdma          S11auditd        S22messagebus      S26acpid             S70spice-vdagentd  S99local
K15httpd         K72cgconfig    K87restorecond     K99rngd          S11portreserve   S23NetworkManager  S26halda emon         S80postfix

  K开头的文件:要停止的服务(脚本),从01开始关闭,数字越小越优先关闭

  S开头的文件:要启动的服务(脚本),从01开始启动,数字越小越优先启动

  这些文件其实都是软链接,指向的都是/etc/rc.d/init.d/目录下的文件

?
1
2
[[email protected] ~]# ll /etc/rc.d/rc5.d/K01smartd
lrwxrwxrwx. 1 root root 16 Mar 13  2018 /etc/rc.d/rc5.d/K01smartd -> ../init.d/smart d

第五步、启动终端

分享图片

  最后一步就是用户登录了,没什么说的。

?
1
2
[[email protected] ~]# ll /boot/grub/stage1
-rw-r--r--. 1 root root 512 Mar 13  2018 /boot/grub/stage1

?
1
2
[[email protected] ~]# ll /boot/grub/stage1
-rw-r--r--. 1 root root 512 Mar 13  2018 /boot/grub/stage1

?

1

2

[[email protected] ~]# ll /boot/grub/stage1
-rw-r--r--. 1 root root 512 Mar 13  2018 /boot/grub/stage1

[[email protected] ~]# ll /boot/grub/stage1

-rw-r--r--. 1 root root 512 Mar 13  2018 /boot/grub/stage1

?
1
2
3
4
5
6
7
8
[[email protected] ~]# ll -h /boot/grub/stage2   //大于512字节了
-rw-r--r--. 1 root root 124K Mar 21  2018 /boot/grub/stage2
[[email protected] ~]# ls /boot/grub/*stage1_5   //有各种文件系统格式
/boot/grub/e2fs_stage1_5     /boot/grub/minix_stage1_5
/boot/grub/fat_stage1_5      /boot/grub/reiserfs_stage1_5
/boot/grub/ffs_stage1_5      /boot/grub/ufs2_stage1_5
/boot/grub/iso9660_stage1_5  /boot/grub/vstafs_stage1_5
/boot/grub/jfs_stage1_5      /boot/grub/xfs_stage1_5

?
1
2
3
4
5
6
7
8
[[email protected] ~]# ll -h /boot/grub/stage2   //大于512字节了
-rw-r--r--. 1 root root 124 K Mar 21  2018 /boot/grub/stage2
[[email protected] ~]# ls /boot/grub/*stage1_5   //有各种文件系统格式
/boot/grub/e2fs_stage1_5     /boot/grub/minix_stage1_5
/boot/grub/fat_stage1_5      /boot/grub/reiserfs_stage1_5
/boot/grub/ffs_stage1_5      /boot/grub/ufs2_stage1_5
/boot/grub/iso9660_stage1_5  /boot/grub/vstafs_stage1_5
/boot/grub/jfs_stage1_5      /boot/grub/xfs_stage1_5

?

1

2

3

4

5

6

7

8

[[email protected] ~]# ll -h /boot/grub/stage2   //大于512字节了
-rw-r--r--. 1 root root 124K Mar 21  2018 /boot/grub/stage2
[[email protected] ~]# ls /boot/grub/*stage1_5   //有各种文件系统格式
/boot/grub/e2fs_stage1_5     /boot/grub/minix_stage1_5
/boot/grub/fat_stage1_5      /boot/grub/reiserfs_stage1_5
/boot/grub/ffs_stage1_5      /boot/grub/ufs2_stage1_5
/boot/grub/iso9660_stage1_5  /boot/grub/vstafs_stage1_5
/boot/grub/jfs_stage1_5      /boot/grub/xfs_stage1_5

[[email protected] ~]# ll -h /boot/grub/stage2   //大于512字节了

-rw-r--r--. 1 root root 124K Mar 21  2018 /boot/grub/stage2

[[email protected] ~]# ls /boot/grub/*stage1_5   //有各种文件系统格式

/boot/grub/e2fs_stage1_5     /boot/grub/minix_stage1_5

/boot/grub/fat_stage1_5      /boot/grub/reiserfs_stage1_5

/boot/grub/ffs_stage1_5      /boot/grub/ufs2_stage1_5

/boot/grub/iso9660_stage1_5  /boot/grub/vstafs_stage1_5

/boot/grub/jfs_stage1_5      /boot/grub/xfs_stage1_5

?
1
2
3
4
5
6
7
8
9
10

11
12
13
14
15
16
17
18
19
20
21
[[email protected] ~]# cat /boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_centos6-lv_root
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default =0   //设置默认启动项为第一个内核
timeout=5   //菜单项等待选项时间为5秒
splashimage=(hd0,0)/grub/splash.xpm.gz   //菜单背景图片
hiddenmenu   //隐藏菜单
//这里有时候会有passwrod参数,意思是进入急救模式(单用户模式)的密码是多少,可以是明文密码,可以是加密密码
//例如password --md5 $1$1S9Xy$1MuGZSoPc2vAtkW.jvz0X/,这代表进入急救模式的password经过MD5加密,加密密码为$1$1S9Xy$1MuGZSoPc2vAtkW.jvz0X/
title CentOS 6 (2.6.32-642.el6.x86_64)   //菜单项名称
         root (hd0,0)   //grub查找stage2文件及kernel文件所在设备分区,grub的根。第一块硬盘的第一个分区
         //启动的内核
         kernel /vmlinuz-2.6.32-642.el6.x86_64 ro root=/dev/mapper/vg_centos6-lv_root rd_NO_LUKS rd_NO_MD rd_LVM_LV=vg_centos6/lv_swap crashkernel=128M LANG=zh_CN.UTF-8 rd_LVM_LV=vg_centos6/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
         initrd /initramfs-2.6.32-642.el6.x86_64.img   //内核匹配的ramfs文件,img是镜像文件

?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[[email protected] ~]# cat /boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_centos6-lv_root
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default =0   //设置默认启动项为第一个内核
timeout=5   //菜单项等待选项时间为5秒
splashimage=(hd0,0)/grub/splash.xpm.gz   //菜单背景图片
hiddenmenu   //隐藏菜单
//这里有时候会有passwrod参数,意思是进入急救模式(单用户模式)的密码是多少,可以是明文密码,可以是加密密码
//例如password --md5 $1$1S9Xy$1MuGZSoPc2vAtkW.jvz0X/,这代表进入急救模式的password经过MD5加密,加密密码为$1$1S9Xy$1MuGZSoPc2vAtkW.jvz0X/
title CentOS 6 (2.6.32-642.el6.x86_64)   //菜单项名称
         root (hd0,0)   //grub查找stage2文件及kernel文件所在设备分区,grub的根。第一块硬盘的第一个分区
         //启动的内核
         kernel /vmlinuz-2.6.32-642.el6.x86_64 ro root=/dev/mapper/vg_centos6-lv_root rd_NO_LUKS rd_NO_MD rd_LVM_LV=vg_centos6/lv_swap crashkernel=128M LANG=zh_CN.UTF-8 rd_LVM_LV=vg_centos6/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
         initrd /initramfs-2.6.32-642.el6.x86_64.img   //内核匹配的ramfs文件,img是镜像文件

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

[[email protected] ~]# cat /boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_centos6-lv_root
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default =0   //设置默认启动项为第一个内核
timeout=5   //菜单项等待选项时间为5秒
splashimage=(hd0,0)/grub/splash.xpm.gz   //菜单背景图片
hiddenmenu   //隐藏菜单
//这里有时候会有passwrod参数,意思是进入急救模式(单用户模式)的密码是多少,可以是明文密码,可以是加密密码
//例如password --md5 $1$1S9Xy$1MuGZSoPc2vAtkW.jvz0X/,这代表进入急救模式的password经过MD5加密,加密密码为$1$1S9Xy$1MuGZSoPc2vAtkW.jvz0X/
title CentOS 6 (2.6.32-642.el6.x86_64)   //菜单项名称
         root (hd0,0)   //grub查找stage2文件及kernel文件所在设备分区,grub的根。第一块硬盘的第一个分区
         //启动的内核
         kernel /vmlinuz-2.6.32-642.el6.x86_64 ro root=/dev/mapper/vg_centos6-lv_root rd_NO_LUKS rd_NO_MD rd_LVM_LV=vg_centos6/lv_swap crashkernel=128M LANG=zh_CN.UTF-8 rd_LVM_LV=vg_centos6/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
         initrd /initramfs-2.6.32-642.el6.x86_64.img   //内核匹配的ramfs文件,img是镜像文件

[[email protected] ~]# cat /boot/grub/grub.conf

# grub.conf generated by anaconda

#

# Note that you do not have to rerun grub after making changes to this file

# NOTICE:  You have a /boot partition.  This means that

#          all kernel and initrd paths are relative to /boot/, eg.

#          root (hd0,0)

#          kernel /vmlinuz-version ro root=/dev/mapper/vg_centos6-lv_root

#          initrd /initrd-[generic-]version.img

#boot=/dev/sda

default =0   //设置默认启动项为第一个内核

timeout=5   //菜单项等待选项时间为5秒

splashimage=(hd0,0)/grub/splash.xpm.gz   //菜单背景图片

hiddenmenu   //隐藏菜单

//这里有时候会有passwrod参数,意思是进入急救模式(单用户模式)的密码是多少,可以是明文密码,可以是加密密码

//例如password --md5 $1$1S9Xy$1MuGZSoPc2vAtkW.jvz0X/,这代表进入急救模式的password经过MD5加密,加密密码为$1$1S9Xy$1MuGZSoPc2vAtkW.jvz0X/

title CentOS 6 (2.6.32-642.el6.x86_64)   //菜单项名称

         root (hd0,0)   //grub查找stage2文件及kernel文件所在设备分区,grub的根。第一块硬盘的第一个分区

         //启动的内核

         kernel /vmlinuz-2.6.32-642.el6.x86_64 ro root=/dev/mapper/vg_centos6-lv_root rd_NO_LUKS rd_NO_MD rd_LVM_LV=vg_centos6/lv_swap crashkernel=128M LANG=zh_CN.UTF-8 rd_LVM_LV=vg_centos6/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet

         initrd /initramfs-2.6.32-642.el6.x86_64.img   //内核匹配的ramfs文件,img是镜像文件

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[[email protected] ~]# ls -ld /etc/rc*
lrwxrwxrwx.  1 root root    7 Mar 13  2018 /etc/rc -> rc.d/rc
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc0.d -> rc.d/rc0.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc1.d -> rc.d/rc1.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc2.d -> rc.d/rc2.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc3.d -> rc.d/rc3.d
lrwxrwxrwx.  1 root root   1 0 Mar 13  2018 /etc/rc4.d -> rc.d/rc4.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc5.d -> rc.d/rc5.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc6.d -> rc.d/rc6.d
drwxr-xr-x. 10 root root 4096 Feb 18 02:17 /etc/rc.d
lrwxrwxrwx.  1 root root   13 Mar 13  2018 /etc/rc.local -> rc.d/rc.local
lrwxrwxrwx.  1 root root   15 Mar 13  2018 /etc/rc.sysinit -> rc.d/rc.sysinit
[[email protected] ~]# ls /etc/rc.d/
init.d  rc0.d  rc2.d  rc4.d  rc6.d     rc.sysinit
rc      rc1.d  rc3.d  rc5.d  rc.local
[[email protected] ~]# diff -ruNa /etc/rc.d/init.d/ /etc/init.d/

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[[email protected] ~]# ls -ld /etc/rc*
lrwxrwxrwx.  1 root root    7 Mar 13  2018 /etc/rc -> rc.d/ rc
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc0.d -> rc.d/rc0.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc1.d -> rc.d/rc1.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc2.d -> rc.d/rc2.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc3.d -> rc.d/rc3.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc4.d -> rc.d/rc4.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc5.d -> rc.d/rc5.d < /div>

lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc6.d -> rc.d/rc6.d
drwxr-xr-x. 10 root root 4096 Feb 18 02:17 /etc/rc.d
lrwxrwxrwx.  1 root root   13 Mar 13  2018 /etc/rc.local -> rc.d/rc.local
lrwxrwxrwx.  1 root root   15 Mar 13  2018 /etc/rc.sysinit -> rc.d/rc.sysinit
[[email protected] ~]# ls /etc/rc.d/
init.d  rc0.d  rc2.d  rc4.d  rc6.d     rc.sysinit
rc      rc1.d  rc3.d  rc5.d  rc.local
[[email protected] ~]# diff -ruNa /etc/rc.d/init.d/ /etc/init.d/

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

[[email protected] ~]# ls -ld /etc/rc*
lrwxrwxrwx.  1 root root    7 Mar 13  2018 /etc/rc -> rc.d/rc
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc0.d -> rc.d/rc0.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc1.d -> rc.d/rc1.d

lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc2.d -> rc.d/rc2.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc3.d -> rc.d/rc3.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc4.d -> rc.d/rc4.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc5.d -> rc.d/rc5.d
lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc6.d -> rc.d/rc6.d
drwxr-xr-x. 10 root root 4096 Feb 18 02:17 /etc/rc.d
lrwxrwxrwx.  1 root root   13 Mar 13  2018 /etc /rc.local -> rc.d/rc.local
lrwxrwxrwx.  1 root root   15 Mar 13  2018 /etc/rc.sysinit -> rc.d/rc.sysinit
[[email protected] ~]# ls /etc/rc.d/
init.d  rc0.d  rc2.d  rc4.d  rc6.d     rc.sysinit
rc      rc1.d  rc3.d  rc5.d  rc.local
[[email protected] ~]# diff -ruNa /etc/rc.d/init.d/ /etc/init.d/

[[email protected] ~]# ls -ld /etc/rc*

lrwxrwxrwx.  1 root root    7 Mar 13  2018 /etc/rc -> rc.d/rc

lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc0.d -> rc.d/ rc0.d

lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc1.d -> rc.d/rc1.d

lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc2.d -> rc.d/rc2.d

lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc3.d -> rc.d/rc3.d

lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc4.d -> rc.d/rc4.d

lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc5.d -> rc.d/rc5.d

lrwxrwxrwx.  1 root root   10 Mar 13  2018 /etc/rc6.d -> rc.d/rc6.d

drwxr-xr-x. 10 root root 4096 Feb 18 02:17 /etc/rc.d

lrwxrwxrwx.  1 root root   13 Mar 13  2018 /etc/rc.local -> rc.d/rc.local

lrwxrwxrwx.  1 root root   15 Mar 13  2018 /etc/rc.sysinit -> rc.d/rc.sysinit

[[email protected] ~]# ls /etc/rc.d/

init.d  rc0.d  rc2.d  rc4.d  rc6.d     rc.sysinit

rc      rc1.d  rc3.d  rc5.d  rc.local

[[email protected] ~]# diff -ruNa /etc/rc.d/init.d/ /etc/init.d/

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[[email protected] ~]# cat /etc/inittab
# inittab is only used by upstart for the default runlevel.
#
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
#
# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
# with configuration in /etc/sysconfig/init.
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(5), init(8), and initctl(8).
#
# Default runlevel. The runlevels used are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
#
id:5:initdefault:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[[email protected] ~]# cat /etc/inittab
# inittab is only used by upstart for the default runlevel.
#
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
#
# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
# with configuration in /etc/sysconfig/init.
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(5), init(8), and initctl(8).
#
# Default runlevel. The runlevels used are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
#
id:5:initdefault:

?

1

2

3

4

5

6

7

8

9

10

11

12

1 3

14

15

16

17

18

19

20

21

22

23

24

25

26

27

[[email protected] ~]# cat /etc/inittab
# inittab is only used by upstart for the default runlevel.
#
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
#
# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
# with configuration in /etc/sysconfig/init.
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(5), init(8), and initctl(8).
#
# Default runlevel. The runlevels used are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
#
id:5:initdefault:

[[email protected] ~]# cat /etc/inittab

# inittab is only used by upstart for the default runlevel.

#

# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.

#

# System initialization is started by /etc/init/rcS.conf

#

# Individual runlevels are started by /etc/init/rc.conf

#

# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf

#

# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,

# with configuration in /etc/sysconfig/init.

#

# For information on how to write upstart event handlers, or how

# upstart works, see init(5), init(8), and initctl(8).

#

# Default runlevel. The runlevels used are:

#   0 - halt (Do NOT set initdefault to this)

#   1 - Single user mode

#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)

#   3 - Full multiuser mode

#   4 - unused

#   5 - X11

#   6 - reboot (Do NOT set initdefault to this)

#

id:5:initdefault:

?
1
2
3
4
5
6
7
8
[[email protected] ~]# ls /etc/rc.d/rc5.d/
K01smartd        K50dnsmasq     K73winbind         K88sssd          S01sysstat       S12rsyslog         S24nfslock           S26udev-post       S82abrt-ccpp
K02oddjobd       K50xinetd      K74ntpd            K89netconsole    S02lvm2-monitor  S13cpuspeed        S24rpcgssd           S28autofs          S82abrtd
K05wdaemon       K60nfs         K75ntpdate         K89rdisc         S08ip6tables     S13irqbalance      S25blk-availability  S50bluetooth       S90crond
K10psacct        K61nfs-rdma    K75quota_nld       K92pppoe-server  S08iptables      S13rpcbind         S25cups              S50kdump           S95atd
K10saslauthd     K69rpcsvcgssd  K76ypbind          K95firstboot     S10network       S15mdmonitor       S25netfs             S55sshd            S99certmonger
K15htcacheclean  K71cgred       K84wpa_supplicant  K95rdma          S11auditd        S22messagebus      S26acpid             S70spice-vdagentd  S99local
K15httpd         K72cgconfig    K87restorecond     K99rngd          S11portreserve   S23NetworkManager  S26haldaemon         S80postfix

?
1
2
3
4
5
6
7
8

[[email protected] ~]# ls /etc/rc.d/rc5.d/
K01smartd        K50dnsmasq     K73winbind         K88sssd          S01sysstat       S12rsyslog         S24nfslock           S26udev-post       S82abrt-ccpp
K02oddjobd       K50xinetd      K74ntpd            K89netconsole    S02lvm2-monitor  S13cpuspeed        S24rpcgssd           S28autofs          S82abrtd
K05wdaemon       K60nfs         K75ntpdate         K89rdisc         S08ip6tables     S13irqbalance      S25blk-availability  S50bluetooth       S90crond
K10psacct        K61nfs-rdma    K75quota_nld       K92pppoe-server  S08iptables      S13rpcbind         S25cups              S50kdump           S95atd
K10saslauthd     K69rpcsvcgssd  K76ypbind          K95firstboot     S10network       S15mdmonitor       S25netfs             S55sshd            S99certmonger
K15htcacheclean  K71cgred       K84wpa_supplicant  K95rdma          S11auditd        S22messagebus      S26acpid             S70spice-vdagentd  S99local
K15httpd         K72cgconfig    K87restorecond     K99rngd          S11portreserve   S23NetworkManager  S26haldaemon         S80postfix

?

1

2

3

4

5

6

7

8

[[email protected] ~]# ls /etc/rc.d/rc5.d/
K01smartd        K50dnsmasq     K73winbind         K88sssd          S01sysstat       S12rsyslog         S24nfslock           S26udev-post       S82abrt-ccpp
K02oddjobd       K50xinetd      K74ntpd            K89netconsole    S02lvm2-monitor  S13cpuspeed        S24rpcgssd           S28autofs          S82abrtd
K05wdaemon       K60nfs         K75ntpdate         K89rdisc         S08ip6tables     S13irqbalance      S25blk-availability  S50bluetooth       S90crond
K10psacct        K61nfs-rdma    K75quota_nld       K92pppoe-server  S08iptables      S1 3rpcbind         S25cups              S50kdump           S95atd
K10saslauthd     K69rpcsvcgssd  K76ypbind          K95firstboot     S10network       S15mdmonitor       S25netfs             S55sshd            S99certmonger
K15htcacheclean  K71cgred       K84wpa_supplicant  K95rdma          S11auditd        S22messagebus      S26acpid             S70spice-vdagentd  S99local
K15httpd         K72cgconfig    K87restorecond     K99rngd          S11portreserve   S23NetworkManager  S26haldaemon         S80postfix

[[email protected] ~]# ls /etc/rc.d/rc5.d/

K01smartd        K50dnsmasq     K73winbind         K88sssd          S01sysstat       S12rsyslog         S24nfslock           S26udev-post       S82abrt-ccpp

K02oddjobd       K50xinetd      K74ntpd            K89netconsole    S02lvm2-monitor  S13cpuspeed        S24rpcgssd           S28autofs          S82abrtd

K05wdaemon       K60nfs         K75ntpdate         K89rdisc         S08ip6tables     S13irqbalance      S25blk-availability  S50bluetooth       S90crond

K10psacct        K61nfs-rdma    K75quota_nld       K92pppoe-server  S08iptables      S13rpcbind         S25cups              S50kdump           S95atd

K10saslauthd     K69rpcsvcgssd  K76ypbind          K95firstboot     S10network       S15mdmonitor       S25netfs             S55sshd            S99certmonger

K15htcacheclean  K71cgred       K84wpa_supplicant  K95rdma          S11auditd        S22messagebus      S26acpid             S70spice-vdagentd  S99local

K15httpd         K72cgconfig    K87restorecond     K99rngd          S11portreserve   S23NetworkManager  S26haldaemon         S80postfix

?
1
2
[[email protected] ~]# ll /etc/rc.d/rc5.d/K01smartd
lrwxrwxrwx. 1 root root 16 Mar 13  2018 /etc/rc.d/rc5.d/K01smartd -> ../init.d/smartd

?

1
2
[[email protected] ~]# ll /etc/rc.d/rc5.d/K01smartd
lrwxrwxrwx. 1 root root 16 Mar 13  2018 /etc/rc.d/rc5.d/K01smartd -> ../init.d/smartd

?

1

2

[[email protected] ~]# ll /etc/rc.d/rc5.d/K01smartd
lrwxrwxrwx. 1 root root 16 Mar 13  2018 /etc/rc.d/rc5.d/K01smartd -> ../init.d/smartd

[[email protected] ~]# ll /etc/rc.d/rc5.d/K01smartd

lrwxrwxrwx. 1 root root 16 Mar 13  2018 /etc/rc.d/rc5.d/K01smartd -> ../init.d/smartd

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4868 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.