linux系统典型引导过程如下:
(1) 加载并初始化内核
(2) 检测和配置设备
(3) 创建内核线程
(4) 管理员干预(手动引导时)
(5) 执行系统启动脚本
(6) 多用户模式运行
硬盘安装linux时,grub里第一条语句通常是 kernel /..路径../vmlinuz ,这就是加载内核。
init级别,传统的init有7个级别,在 /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/event.d/rcS
#
# Individual runlevels are started by /etc/event.d/rc[0-6]
#
# Ctrl-Alt-Delete is handled by /etc/event.d/control-alt-delete
#
# Terminal gettys (tty[1-6]) are handled by /etc/event.d/tty[1-6] and
# /etc/event.d/serial
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(8), initctl(8), and events(5).
#
# 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:
|
在机器引导时,init从0级开始,一级一级网上运行,直到默认的级别,系统关闭时按照相反的顺序。
启动脚本
init在每个级别会运行相应的脚本来启动或关闭系统的某项服务,在/etc/rc.d 中可以看到
# 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
|
fc系列network和ssh都是级别2,到rc2.d目录一看
K01dnsmasq K73winbind K85rpcgssd S12rsyslog
K01smartd K73ypbind K85rpcidmapd S13rpcbind
K01smolt K74haldaemon K86nfslock S15mdmonitor
K02avahi-daemon K74kerneloops K87irqbalance S22messagebus
K05atd K74lm_sensors K87multipathd S26acpid
K05saslauthd K74nscd K87restorecond S26pcscd
K10psacct K74ntpd K89netplugd S26udev-post
K15httpd K75fuse K89rdisc S27NetworkManager
K20nfs K75netfs K90network S28portreserve
K24irda K75ntpdate K91capi S55sshd
K35backuppc K76openvpn K95firstboot S80sendmail
K36mysqld K83bluetooth S00microcode_ctl S85gpm
K50netconsole K83setroubleshoot S06cpuspeed S90crond
K50snmpd K84btseed S08ip6tables S98cups
K50snmptrapd K84bttrack S08iptables S99anacron
K50vsftpd K84wpa_supplicant S09isdn S99local
K69rpcsvcgssd K85racoon S11auditd
|
以“s”开头的就是启动某项服务,“K”开头的就是关闭某项服务,这些脚本就是shell程序,要不说shell程序设计也很重要啊。
红帽系列引导会通过配置 /etc/sysconfig中的配置文件来完成
# ls /etc/sysconfig/
atd httpd modules saslauthd
auditd hw-uuid netconsole selinux
authconfig i18n network sendmail
bittorrent init networking smartmontools
bluetooth ip6tables network-scripts snmpd
cbq ip6tables-config nfs system-config-firewall
clock iptables nspluginwrapper system-config-securitylevel
console iptables-config ntpd system-config-users
cpuspeed irda ntpdate udev
crond irqbalance prelink wpa_supplicant
crontab kernel readonly-root
firstboot keyboard rsyslog
grub lm_sensors samba
|
keyboard的配置文件为
# more /etc/sysconfig/keyboard
KEYBOARDTYPE="pc"
KEYTABLE="us"
LAYOUT="us"
MODEL="pc105+inet"
OPTIONS=""
VARIANT=""
|
重新引导和关机
shutdown 命令- bring the system down
-h 停机 -r 重新引导
reboot, halt, poweroff - 重新引导,停机,关机三个命令
reboot [OPTION]...
halt [OPTION]...
poweroff [OPTION]...
telinit 命令 change runlevel
可以用来测试inittab 文件的修改
telinit 1 ,将进入单用户模式
阅读(944) | 评论(0) | 转发(0) |