Linux的开机启动流程
1、开机BIOS自检 --> 检查CPU,硬盘等硬件信息
2、MBR【Major Boot Record】引导 --> 主分区引导【读取0磁道0柱面1扇面的前446字节】
--> 确定服务器的启动方式【一般是硬盘启动,有时候也有CD_ROM启动】
3、GRUB【GRand Unified Bootloader】引导 –> 确定加载某个系统【GRUB是GUN项目的多操作系统启动程序】
4、加载内核kernal信息 --> 【cat /proc/version或uname -a即可查看内核版本信息】
5、运行INIT进程 --> Linux启动的第一个进程【ps -ef | grep /sbin/init】
6、读取cat /etc/inittab --> 确定Linux的启动级别和加载自启动设备
--> init进程执行/etc/rc.d/rc.sysinit (设置主机名,网络等信息)
7、启动内核模块,执行不同级别的脚本程序 --> 根据自启动级别加载该级别下的自启动程序 /etc/rc.d/rc3.d/*
8、执行/etc/rc.d/rc.local --> 记录系统自启动的是非系统软件、命令、环境变量等初始化信息
9、执行/bin/login登录程序,启动mingetty(终端登录进程),进入系统登陆界面
常用的命令展示
cat /etc/inittab
Linux共有7【0-6】个自启动级别,默认是3级
# 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:3:initdefault:
其他文件的展示:
[root@localhost ~]# cd /etc/rc.d/
[root@localhost rc3.d]# tail /etc/rc.local