CentOS 系统启动流程

前端之家收集整理的这篇文章主要介绍了CentOS 系统启动流程前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

CentOS 系统启动流程 POST:加电自检; ROM:CMOS BIOS:Basic Input and Output System ROM+RAM BOOT Sequence: 按次序查找各引导设备,第一个有引导程序的设备即为本次启动用到设备; bootloader: 引导加载器,程序 windows: ntloader Linux: LILO:LInux LOader GRUB: GRand Uniform Bootloader GRUB 0.X: GRUB Legacy GRUB 1.x: GRUB2 功能:提供一个菜单,允许用户选择要启动系统或不同的内核版本;把用户选定的内核装载到内存中的特定空间中,解压、展开,并把系统控制权移交给内核; MBR: 446: bootloader 64: fat 2: 55AA GRUB: bootloader: 1st stage disk: 2nd stage kernel: 自身初始化: 探测可识别到的所有硬件设备; 加载硬件驱动程序;(有可能会借助于ramdisk加载驱动) 以只读方式挂载根文件系统; 运行用户空间的第一个应用程序:/sbin/init init程序的类型: SysV: init,CentOS 5 配置文件:/etc/inittab Upstart: init,CentOS 6 配置文件:/etc/inittab,/etc/init/*.conf Systemd:systemd,CentOS 7 配置文件:/usr/lib/systemd/system,/etc/systemd/system ramdisk: 内核中的特性之一:使用缓冲和缓存来回事对磁盘上的文件访问; ramdisk --> ramfs CentOS 5: initrd,工具程序:mkinitrd CentOS 6: initramfs, 工具程序:mkinitrd,dracut 系统初始化: POST --> BootSequence (BIOS) --> Bootloader(MBR) --> kernel(ramdisk) --> rootfs(只读) --> init /sbin/init CentOS 5: 运行级别:为了系统的运行或维护等应用目的而设定; 0-6:7个级别 0:关机 1:单用户模式(root,无须登录),single,维护模式; 2: 多用户模式,会启动网络功能,但不会启动NFS;维护模式; 3:多用户模式,正常模式;文本界面; 4:预留级别;可同3级别; 5:多用户模式,正常模式;图形界面; 6:重启 默认级别: 3,5 切换级别: init # 查看级别: runlevel who -r 配置文件:/etc/inittab 每一行定义一种action以及与之对应的process id:runlevel:action:process action: wait: 切换至此级别运行一次; respawn:此process终止,就重新启动之; initdefault:设定默认运行级别;process省略; sysinit:设定系统初始化方式,此处一般为指定/etc/rc.d/rc.sysinit; ...[root@slave ~]# ll /etc/rc.d/total 60drwxr-xr-x. 2 root root 4096 Jan 29 2015 init.d-rwxr-xr-x. 1 root root 2617 Oct 16 2014 rcdrwxr-xr-x. 2 root root 4096 Jan 31 2015 rc0.ddrwxr-xr-x. 2 root root 4096 Jan 31 2015 rc1.ddrwxr-xr-x. 2 root root 4096 Jan 31 2015 rc2.ddrwxr-xr-x. 2 root root 4096 Jan 31 2015 rc3.ddrwxr-xr-x. 2 root root 4096 Jan 31 2015 rc4.ddrwxr-xr-x. 2 root root 4096 Jan 31 2015 rc5.ddrwxr-xr-x. 2 root root 4096 Jan 31 2015 rc6.d-rwxr-xr-x. 1 root root 259 Jul 31 00:53 rc.local-rwxr-xr-x. 1 root root 19914 Oct 16 2014 rc.sysinit id:3:initdefault: si::sysinit:/etc/rc.d/rc.sysinit l0:0:wait:/etc/rc.d/rc 0 l1:1:wait:/etc/rc.d/rc 1 ... l6:6:wait:/etc/rc.d/rc 6 说明:rc 0 --> 意味着读取/etc/rc.d/rc0.d/ K*: K##*:##运行次序;数字越小,越先运行;数字越小的服务,通常为依赖到别的服务; S*: S##*:##运行次序;数字越小,越先运行;数字越小的服务,通常为被依赖到的服务; for srv in /etc/rc.d/rc0.d/K*; do $srv stop done for srv in /etc/rc.d/rc0.d/S*; do $srv start done[root@slave ~]# ll /etc/rc.d/init.d/total 356-rwxr-xr-x. 1 root root 1288 Oct 16 2014 abrt-ccpp-rwxr-xr-x. 1 root root 1628 Oct 16 2014 abrtd-rwxr-xr-x. 1 root root 1642 Oct 16 2014 abrt-oops-rwxr-xr-x. 1 root root 1725 Aug 18 2010 acpid-rwxr-xr-x. 1 root root 2062 Jan 30 2012 atd-rwxr-xr-x. 1 root root 3580 Oct 15 2014 auditd-r-xr-xr-x. 1 root root 1340 Oct 15 2014 blk-availability-rwxr-xr-x. 1 root root 710 Nov 10 2010 bluetooth-rwxr-xr-x. 1 root root 11355 Aug 13 2013 cpuspeed-rwxr-xr-x. 1 root root 2826 Nov 23 2013 crond-rwxr-xr-x. 1 root root 3034 Oct 15 2014 cups-rwxr-xr-x. 1 root root 1734 Jun 16 2014 dnsmasq-rwxr-xr-x. 1 root root 3245 Jul 9 2013 firstboot-rw-r--r--. 1 root root 19295 Jul 22 2014 functions-rwxr-xr-x. 1 root root 1801 Oct 15 2014 haldaemon-rwxr-xr-x. 1 root root 5866 Jul 22 2014 halt-rwxr-xr-x. 1 root root 2001 Oct 16 2014 htcacheclean-rwxr-xr-x. 1 root root 3371 Oct 16 2014 httpd-rwxr-xr-x. 1 root root 10804 Oct 15 2014 ip6tables-rwxr-xr-x. 1 root root 10688 Oct 15 2014 iptables-rwxr-xr-x. 1 root root 1938 Jun 2 2014 irqbalance-rwxr-xr-x 1 root root 9980 Dec 18 2014 jexec-rwxr-xr-x. 1 root root 19476 Oct 15 2014 kdump-rwxr-xr-x. 1 root root 652 Jul 22 2014 killall-r-xr-xr-x. 1 root root 2134 Oct 15 2014 lvm2-lvMetad-r-xr-xr-x. 1 root root 2757 Oct 15 2014 lvm2-monitor-rwxr-xr-x. 1 root root 2571 Sep 4 2014 mdmonitor-rwxr-xr-x. 1 root root 2200 Sep 13 2012 messagebus-rwxr-xr-x. 1 root root 2989 Jul 22 2014 netconsole-rwxr-xr-x. 1 root root 6064 Jul 22 2014 netfs-rwxr-xr-x. 1 root root 6334 Jul 22 2014 network-rwxr-xr-x. 1 root root 2205 Oct 15 2014 NetworkManager-rwxr-xr-x. 1 root root 1923 Jul 15 2013 ntpd-rwxr-xr-x. 1 root root 2043 Jul 15 2013 ntpdate-rwxr-xr-x. 1 root root 2023 Apr 3 2012 portreserve-rwxr-xr-x. 1 root root 3912 Feb 20 2014 postfix-rwxr-xr-x. 1 root root 1556 Jul 17 2012 psacct-rwxr-xr-x. 1 root root 2034 Mar 5 2014 quota_nld-rwxr-xr-x. 1 root root 1513 Sep 17 2013 rdisc-rwxr-xr-x. 1 root root 1822 Oct 15 2014 restorecond-rwxr-xr-x. 1 root root 1808 Dec 17 2011 rngd-rwxr-xr-x. 1 root root 2011 Aug 15 2013 rsyslog-rwxr-xr-x. 1 root root 1698 Oct 15 2014 sandBox-rwxr-xr-x. 1 root root 2056 Jun 23 2014 saslauthd-rwxr-xr-x. 1 root root 647 Jul 22 2014 single-rwxr-xr-x. 1 root root 3002 Feb 21 2013 smartd-rwxr-xr-x. 1 root root 2162 Sep 14 2014 snmpd-rwxr-xr-x. 1 root root 1738 Sep 14 2014 snmptrapd-rwxr-xr-x. 1 root root 2472 Oct 15 2014 spice-vdagentd-rwxr-xr-x. 1 root root 4621 Oct 15 2014 sshd-rwxr-xr-x. 1 root root 1144 Oct 16 2014 sysstat-rwxr-xr-x. 1 root root 2294 Oct 15 2014 udev-post-rwxr-xr-x. 1 root root 39800 Jan 27 2015 vmware-tools-rwxr-xr-x. 1 root root 15208 Jan 27 2015 vmware-tools-thinprint-rwxr-xr-x. 1 root root 1674 Feb 21 2013 wdaemon-rwxr-xr-x. 1 root root 1608 Oct 15 2014 winbind-rwxr-xr-x. 1 root root 1866 Feb 4 2013 wpa_supplicant chkconfig命令 查看服务在所有级别的启动或关闭设定情形: chkconfig [--list] [name][root@slave ~]# chkconfig --level 3 NetworkManager on[root@slave ~]# chkconfig --list[root@slave ~]# chkconfig --level 3 NetworkManager off 添加: SysV的服务脚本放置于/etc/rc.d/init.d (/etc/init.d) chkconfig --add name #!/bin/bash # # chkconfig: LLLL nn nnchkconfig: 2345 10 90 删除: chkconfig --del name 修改指定的链接类型 chkconfig [--level levels] name <on|off|reset> --level LLLL: 指定要设置的级别;省略时表示2345; 注意:正常级别下,最后启动一个服务S99local没有链接至/etc/rc.d/init.d一个服务脚本,而是指向了/etc/rc.d/rc.local脚本;因此,不便或不需写为服务脚本放置于/etc/rc.d/init.d/目录,且又想开机时自动运行的命令,可直接放置于/etc/rc.d/rc.local文件中;[root@slave ~]# ll /etc/rc.local lrwxrwxrwx. 1 root root 13 Jan 27 2015 /etc/rc.local -> rc.d/rc.local tty1:2345:respawn:/usr/sbin/mingetty tty1 tty2:2345:respawn:/usr/sbin/mingetty tty2 ... tty6:2345:respawn:/usr/sbin/mingetty tty6 mingetty会调用login程序 /etc/rc.d/rc.sysinit: 系统初始化脚本 (1) 设置主机名; (2) 设置欢迎信息; (3) 激活udev和selinux; (4) 挂载/etc/fstab文件中定义的文件系统; (5) 检测根文件系统,并以读写方式重新挂载根文件系统; (6) 设置系统时钟; (7) 激活swap设备; (8) 根据/etc/sysctl.conf文件设置内核参数; (9) 激活lvm及software raid设备; (10) 加载额外设备的驱动程序; (11) 清理操作; 总结:/sbin/init --> (/etc/inittab) --> 设置默认运行级别 --> 运行系统初始脚本、完成系统初始化 --> 关闭对应下需要关闭的服务,启动需要启动服务 --> 设置登录终端

原文链接:/centos/381173.html

猜你在找的CentOS相关文章