linux系统引导流程
更新时间:2023-05-27 03:43:01 阅读量: 实用文档 文档下载
- linux系统的启动流程推荐度:
- 相关推荐
linux系统引导流程
linux 查看软件时间 date
[root@localhost test]# date
Sun Jan 15 19:20:01 PST 2012
[root@localhost test]#
hwclock 软件时钟
[root@localhost test]# hwclock --help
hwclock - query and set the hardware clock (RTC)
Usage: hwclock [function] [options...]
Functions:
--help show this help
--show read hardware clock and print result
--set set the rtc to the time given with --date
--hctosys set the system time from the hardware clock 依据硬件时钟设置软件时钟 --systohc set the hardware clock to the current system time 依据软件时钟设置硬件时钟
--adjust adjust the rtc to account for systematic drift since
the clock was last set or adjusted
--getepoch print out the kernel's hardware clock epoch value
--setepoch set the kernel's hardware clock epoch value to the
value given with --epoch
--version print out the version of hwclock to stdout
Options:
--utc the hardware clock is kept in coordinated universal time
--localtime the hardware clock is kept in local time
--directisa access the ISA bus directly instead of /dev/rtc
--badyear ignore rtc's year because the bios is broken
--date specifies the time to which to set the hardware clock
--epoch=year specifies the year which is the beginning of the
hardware clock's epoch value
--noadjfile do not access /etc/adjtime. Requires the use of
either --utc or --localtime
[root@localhost test]#
Eg.
[root@localhost test]# date
Sun Jan 15 19:26:05 PST 2012
[root@localhost test]# hwclock
Sun 15 Jan 2012 07:26:10 PM PST -0.128598 seconds
[root@localhost test]# hwclock --hctosys
[root@localhost test]# date
linux系统引导流程
Sun Jan 15 19:26:50 PST 2012
[root@localhost test]# hwclock
Sun 15 Jan 2012 07:26:58 PM PST -0.997218 seconds
[root@localhost test]# hwclock --systohc
[root@localhost test]# date
Sun Jan 15 19:27:41 PST 2012
[root@localhost test]# hwclock
Sun 15 Jan 2012 07:27:48 PM PST -0.322978 seconds
[root@localhost test]#
内核 kernel
内核只有两个作用,载入驱动程序,驱动硬件
启动进程init (很重要的进程 ,其PID)始终为1
# 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/sda2
# initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-194.32.1.el5)
linux系统引导流程
root (hd0,0)
kernel /vmlinuz-2.6.18-194.32.1.el5 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.18-194.32.1.el5.img
title CentOS (2.6.18-194.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-194.el5 ro root=LABEL=/ rhgb quiet 为内核的版本号,为一个单独的文件,是可执行文件,主要放了硬件驱动2:表示主版本号,6:表示副版本号,18:表示末版本号,副版本号为奇数时为测试版,偶数的稳定版
initrd /initrd-2.6.18-194.el5.img
~
~
查看分别修改硬件时钟和软件时钟
Man date
Man hwclock
然后依据其中一个正确的进行修改
在进程中父进程终止,子进程由于某种特殊的原因没有终止,而存在,即变成孤儿进程,但linux 系统中不允许存在孤儿进程,这时孤儿进程会自动指向init 进成为init 的进程
另一种情况是子进程死亡,但父进程还尝试与子进程取得联系,这时子进程就是变成僵尸进程,Z
NFS: network files system 可以进行linux windows 文件共享
Init 进程 配置文件
9 # Default runlevel. The runlevels used by RHS are:
10 # 0 - halt (Do NOT set initdefault to this) 如果设置缺省为0 ,则在开机posts 自检,进入grub 引导kernel ,kernel 加载硬件驱动,加载init进程,这是缺省为0 ,刚在加载init进程时就会关机,缺省为5 为xwindos 图形环境,可用runlevel
11 # 1 - Single user mode
12 # 2 - Multiuser, without NFS (The same as 3, if you do not have networking)没有NFS服务
13 # 3 - Full multiuser mode
14 # 4 - unused
15 # 5 - X11
16 # 6 - reboot (Do NOT set initdefault to this)
17 #
18 id:5:initdefault:
19
20 # System initialization.
21 si::sysinit:/etc/rc.d/rc.sysinit
linux系统引导流程
22
Sysinit 脚本文件
#!/bin/bash
#
# /etc/rc.d/rc.sysinit - run once at boot time
#
# Taken in part from Miquel van Smoorenburg's bcheckrc.
#
HOSTNAME=`/bin/hostname`
HOSTTYPE=`uname -m`
unamer=`uname -r`
set -m
if [ -f /etc/sysconfig/network ]; then
. /etc/sysconfig/network
fi
if [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" ]; then
HOSTNAME=localhost
fi
if [ ! -e /proc/mounts ]; then
mount -n -t proc /proc /proc
mount -n -t sysfs /sys /sys >/dev/null 2>&1
fi
if [ ! -d /proc/bus/usb ]; then
modprobe usbcore >/dev/null 2>&1 && mount -n -t usbfs /proc/bus/usb /proc/bus/usb else
mount -n -t usbfs /proc/bus/usb /proc/bus/usb
fi
. /etc/init.d/functions
# Check SELinux status
查看当前运行级别
Runlevel
[root@localhost test]# runlevel
S 5
[root@localhost test]#
可以切换运行级别
Init 3 加上运行级别就可以了
另telinit 实际上是init的一个软链接
linux系统引导流程
[root@localhost ~]# ls -l `which telinit`
lrwxrwxrwx 1 root root 4 Jan 10 11:30 /sbin/telinit -> init
[root@localhost ~]#
[root@localhost test]# grep -v "^#" inittab | more查看文件除去行首的#
Man 不写文件的绝对路径,只写文件名就可以
Man inittab
Inittab
Id:run-levels:action:process
Id:标识符,一般为两位字母或字符
Run-levels:指定运行的级别,可以指定多个
Action:指定运行时的状态
Process:指定要运行时的脚本/命令
关于系统启动
Firmware 启动固件,post加电自检,这个是在硬件层面的检测
Bootloader 加电自检没有问题时,加载硬盘上第一分区第一个位置,启用引导程
序,在widows中为bootini (NT) 在linux 中为grub
Kernel 加载内核,内核有两个作用,一个是加载系统的驱动程序 ,一个是加
载一个进程,init
Init 由内核加载的Init进程,其父进程为内核调度器
/etc/inittab 读取配置文件,Init进程加载/etc/inittab文件,其有7种运行级别 0-6
Initdefault 设置系统默认的运行级别缺省加载的选项
/etc/rc.d/rc.sysinit 加载系统默认加载的脚本,在每个运行级别都会加载,这个在第一次
启动都会加载,如果要某个
在每一个启动时都启动,可以把服务脚本写在该文件下方 /etc/rc.d/rc 判断系统默认的运行级别,以加载相应的运行级别
/etc/rc.d/rcn.d n=0-6 加载相应的级别下的服务,其有一个软链接在/etc/init.d Username 加载完成,登陆界面
Password
关于rcn.d文件
[toshiba@localhost ~]$ ls /etc/rc.d/rc3.d
K01dnsmasq K74ntpd S12restorecond S28autofs
K02avahi-dnsconfd K85mdmpd S12syslog S55sshd
K02NetworkManager K87multipathd S13cpuspeed S56cups
K02oddjobd K88wpa_supplicant S13irqbalance S56rawdevices
K05conman K89dund S13portmap S80sendmail
K05saslauthd K89netplugd S14nfslock S85gpm
K05wdaemon K89pand S15mdmonitor S90crond
K10psacct K89rdisc S18rpcidmapd S90xfs
K10tcsd K99readahead_later S19rpcgssd S95anacron
K15httpd S00microcode_ctl S22messagebus S95atd
K20nfs S03vmware-tools S25bluetooth S97yum-updatesd
K24irda S04readahead_early S25netfs S98avahi-daemon
linux系统引导流程
K35vncserver S05kudzu S25pcscd S99firstboot
K50ibmasm S08ip6tables S26acpid S99local
K50netconsole S08iptables S26apmd S99smartd
K69rpcsvcgssd S08mcstrans S26haldaemon
K73ypbind S10network S26hidd
K74nscd S11auditd S26lvm2-monitor
[toshiba@localhost ~]$
可以看到,K = kill S = start 大写开头时的时候是在这个运行级别上的启动的,数字越小越优先启动
K用来判断在切换运行别时,需要关闭的服务
对现在的服务进行打开或关闭
如果要关闭某一个服务,直接把名字前面的S改掉就可以,启动将K变成S 一般如果关闭某个服务,将S变成s即可,方便以后操作
设置自启动方法
1.ln –s 即创建一个软链接
2.chkconfig
3.ntsysv
1. Ln –s 创建一个软链接
Vi /etc/rc.d/init.d/msg.script 创建一个要启动的文件
Date >> /root/msg.today 将date 放入msg.today 文件中
Free >> /root/msg.today 查看内存情况
Who >> /root/msg.today 查看当前在线的管理员
Chmod u+x /etc/rc.d/init.d/msg.script 给这个文件以可执行权限
Ln –s /etc/rc.d/init.d/msg.script /etc/rc.d/rc3.d/S100msg.script 在运行级别下创建一个软链接,以在这个运行级别运行时,运行 如rc3.d/S100msg.script
S: start 后写文件名
2. [root@localhost ~]# chkconfig
chkconfig version 1.3.30.2 - Copyright (C) 1997-2000 Red Hat, Inc.
This may be freely redistributed under the terms of the GNU Public License.
usage: chkconfig --list [name]
chkconfig --add <name>
chkconfig --del <name>
chkconfig [--level <levels>] <name> <on|off|reset|resetpriorities>
3.ntsysv
linux系统引导流程
另两个应用
Dmesg 内核驱动硬件的信息
[root@localhost ~]# dmesg | grep sda
SCSI device sda: 20971520 512-byte hdwr sectors (10737 MB)
sda: Write Protect is off
sda: Mode Sense: 61 00 00 00
sda: cache data unavailable
sda: assuming drive cache: write through
SCSI device sda: 20971520 512-byte hdwr sectors (10737 MB)
sda: Write Protect is off
sda: Mode Sense: 61 00 00 00
sda: cache data unavailable
sda: assuming drive cache: write through
sda: sda1 sda2 sda3 sda4 < sda5 >
sd 0:0:0:0: Attached scsi disk sda
SELinux: initialized (dev sda2, type ext3), uses xattr
EXT3 FS on sda2, internal journal
EXT3 FS on sda5, internal journal
SELinux: initialized (dev sda5, type ext3), uses xattr
EXT3 FS on sda1, internal journal
SELinux: initialized (dev sda1, type ext3), uses xattr
Adding 2096472k swap on /dev/sda3. Priority:-1 extents:1 across:2096472k
通过这个命令可以判断硬件是否可以被识别
/var/log 这个文件里放的都是系统的日志,文件
Grep sshd /var/log/messages
正在阅读:
linux系统引导流程05-27
STM32F407 - DP83848 - Lwip移植方法11-25
电工考试复习题大全(填空题)附答案05-11
黑盒测试试题及答案10-23
PN结正向伏安特性曲线随温度的变化07-17
基于安卓的蓝牙通信系统开发05-07
国网湖北电力2015年-北京电力交易中心-国家电网公司12-27
大学化学A实验讲义(2009年)04-24
- 教学能力大赛决赛获奖-教学实施报告-(完整图文版)
- 互联网+数据中心行业分析报告
- 2017上海杨浦区高三一模数学试题及答案
- 招商部差旅接待管理制度(4-25)
- 学生游玩安全注意事项
- 学生信息管理系统(文档模板供参考)
- 叉车门架有限元分析及系统设计
- 2014帮助残疾人志愿者服务情况记录
- 叶绿体中色素的提取和分离实验
- 中国食物成分表2020年最新权威完整改进版
- 推动国土资源领域生态文明建设
- 给水管道冲洗和消毒记录
- 计算机软件专业自我评价
- 高中数学必修1-5知识点归纳
- 2018-2022年中国第五代移动通信技术(5G)产业深度分析及发展前景研究报告发展趋势(目录)
- 生产车间巡查制度
- 2018版中国光热发电行业深度研究报告目录
- (通用)2019年中考数学总复习 第一章 第四节 数的开方与二次根式课件
- 2017_2018学年高中语文第二单元第4课说数课件粤教版
- 上市新药Lumateperone(卢美哌隆)合成检索总结报告
- 引导
- 流程
- 系统
- linux
- 宁波市基础地理信息系统的设计
- 苏州一阳能源科技有限公司章程
- 竞价数据分析(全)
- 2011年中国海洋大学秋季学期高数II上期末考试题(B卷)及参考答案
- 1.管道敷设距墙距离
- 谈高三生物试卷讲评课的优化 - 成长博客CERSP BLOG
- 云南省工业园区相关政策
- 2011年县特克斯县质监局治理商业贿赂查自纠工作总结
- 影视动画的后期制作流程
- 历史教学中学生人格教育的“另类”探析
- 体格检查与操作答案150
- 淘宝开店成本预算
- 人民币汇率的制度选择
- 超细水泥灌浆料在混凝土路面裂缝修补中的应用
- 普通高校音乐教育专业的舞蹈教学初探
- 淮南矿业集团地面钻井抽采卸压瓦斯技术取得重大突破
- 请你咬著喇叭线好吗
- 汽车传感器的种类和作用
- xx高速路碎石桩挖孔安全技术交底
- 考博英语写作素材