系统初始化

系统初始化
查看 uname –r
操作系统版本号 cat /etc/redhat-release
查看主机名uname -n
查看平台 uname -p
进入 boot执行ll命令得到
 
第四行为所需加载的驱动 最后一行为虚拟内核
服务***************************************
chkconfig –list 查看服务
chkconfig --list |grep sendmail 查看邮件服务
rpm -e服务名, 卸载服务
rpm –q --scriptes httpd ,显示动作
chkconfig --level 3(级别) sendmail(服务) off(状态)
setup只能设置当前的级别
ntsysv
service httpd (服务) start(动作,stoprestart)
/etc/init.d/服务 动作
服务分两类 独立(存放于/etc/init.d/) 依赖于超级守护进程 (存放于 /etc/xinetd.d)
防火墙 以及selinux影响服务的执行
Init /etc/inittab 充电自检
开机自检(BIOS)》》MBR引导 (512字节)》》GRUB菜单》》加载内核(kernel)》》运行INIT进程》》读取/etc/inittab配置文件,》》执行/etc/rc.d/rc.sysinit脚本
| i 》》执行/etc/rc.d/rc脚本
 
执行/etc/c.d/rc.local |
|
启动mingetty进程
 
 
进入grub ,cd /boot/grub 查看 ll
grub-install /dev/sda 导入
grub-install –root-directory=/ /dev/sda 导入
vim /etc/grub.conf 查看配置脚本
[root@localhost ~]# vim /etc/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/sda2
# initrd /initrd-version.img
#boot=/dev/sda 所在硬盘
default=0 对应操作系统
timeout=5 等待时间过后5秒后自动选择
splashp_w_picpath=(hd0,0)/grub/splash.xpm.gz grub的背景图片
hiddenmenu 隐藏grub菜单
title Red Hat Enterprise Linux Server (2.6.18-164.el5) title为标签
ro ot (hd0,0) 引导分区根
kernel /vmlinuz-2.6.18-164.el5 ro root=LABEL=/ rhgb quiet 内核为kernel
initrd /initrd-2.6.18-164.el5.img驱动程序
[root@localhost ~]# findfs LABEL=/ 查找标签为 / 的所在
/dev/sda2
 
 
-rw------- 1 root root 2602240 02-21 15:10 initrd-2.6.18-164.el5.img
[root@localhost abc]# zcat initrd-2.6.18-164.el5.img |cpio –id 解压驱动包
11611 blocks
[root@localhost abc]# ll
?昏. 2580
drwx------ 2 root root 4096 02-21 15:15 bin
drwx------ 3 root root 4096 02-21 15:15 dev
drwx------ 2 root root 4096 02-21 15:15 etc
-rwx------ 1 root root 2536 02-21 15:15 init
-rw------- 1 root root 2602240 02-21 15:10 initrd-2.6.18-164.el5.img
drwx------ 3 root root 4096 02-21 15:15 lib
drwx------ 2 root root 4096 02-21 15:15 proc
lrwxrwxrwx 1 root root 3 02-21 15:15 sbin -> bin
drwx------ 2 root root 4096 02-21 15:15 sys
drwx------ 2 root root 4096 02-21 15:15 sysroot
 
 
[root@localhost abc]# vim /etc/inittab 进入初始化表
 
1 #
2 # inittab This file describes how the INIT process should set up
3 # the system in a certain run-level.
4 #
5 # Author: Miquel van Smoorenburg, <[email protected]>
6 # Modified for RHS Linux by Marc Ewing and Donnie Barnes
7 #
8
9 # Default runlevel. The runlevels used by RHS are:
10 # 0 - halt (Do NOT set initdefault to this)
11 # 1 - Single user mode
13 # 3 - Full multiuser mode
14 # 4 - unused
15 # 5 - X11
16 # 6 - reboot (Do NOT set initdefault to this)
17 #
18 id:3:initdefault:
19
20 # System initialization.
21 si::sysinit:/etc/rc.d/rc.sysinit 进入级别前所需执行的脚本(初始化脚本)
22
23 l0:0:wait:/etc/rc.d/rc 0
24 l1:1:wait:/etc/rc.d/rc 1
25 l2:2:wait:/etc/rc.d/rc 2
26 l3:3:wait:/etc/rc.d/rc 3
27 l4:4:wait:/etc/rc.d/rc 4
28 l5:5:wait:/etc/rc.d/rc 5
29 l6:6:wait:/etc/rc.d/rc 6
30
31 # Trap CTRL-ALT-DELETE
32 ca::ctrlaltdel:/sbin/shutdown -t3 -r now 条件满足可重启
33
34 # When our UPS tells us power has failed, assume we have a few minutes
35 # of power left. Schedule a shutdown for 2 minutes from now.
36 # This does, of course, assume you have powerd installed and your
37 # UPS connected and working correctly. UPS备用电源
38 pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"
39 电源失效执行动作 –f快速启动
40 # If power was restored before the shutdown kicked in, cancel it.
41 pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"
42 来电了 取消shutdown
43
44 # Run gettys in standard runlevels
45 1:2345:respawn:/sbin/mingetty tty1 (2345代表级别 启动sbin/mingetty tty终端)
46 2:2345:respawn:/sbin/mingetty tty2 (respawn动作 注销亦执行)
47 3:2345:respawn:/sbin/mingetty tty3
48 4:2345:respawn:/sbin/mingetty tty4
49 5:2345:respawn:/sbin/mingetty tty5
50 6:2345:respawn:/sbin/mingetty tty6
51
52 # Run xdm in runlevel 5
53 x:5:respawn:/etc/X11/prefdm –nodaemon进5级别所需执行的脚本
[root@localhost abc]# file /etc/rc.d/rc.sysinit 查询其脚本类型
/etc/rc.d/rc.sysinit: Bourne-Again shell script text executable 可执行bash脚本
Im
 
[root@localhost abc]# vim /etc/rc.d/rc.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
"/etc/rc.d/rc.sysinit" 980L, 27239C

故障排除
事例1 模拟grub损坏
[root@localhost rc3.d]# dd if=/dev/zero of=/dev/sda bs=446 count=1
1+0 records in
1+0 records out
446 bytes (446 B) copied, 0.000131491 seconds, 3.4 MB/s
执行后 发现正常启动不了



执行Linux rescue 紧急救援模式
进入sysp_w_picpath下 cd /mnt/sysp_w_picpath
Chroot /mnt/sysp_w_picpath
Grub-install /dev/sda
Exit
Exit
系统将会重启 完毕
事例2
删除boot/grub/下面的grub.conf
[root@localhost ~]# mv /boot/grub/grub.conf /boot/grub/grub.conf.old 改动grub.conf名=删除
重新启动后如下所示
进入grub下,执行如下命令,分别实现 找硬盘,加载内核,加载驱动,然后 boot重启,

重启后记得要将/boot/grub下的grub.conf恢复或者手工编辑




 





事例三 ,模拟启动中加载的fstab文件出错 先插入我姓名的拼音hanfang


 

重新启动 发现failed 原因是未能识别“hanfangLABEL=/”输入管理员口令进入命令行模式



修改权限,


编译修改/etc/fstab文件,退出并保存然后重启 ,OK了,

希望对您有所帮助(……)
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章