Linux系统启动流程:
1.加载bios的硬件信息进行自我检测并根据设置取得第一个启动的设备
2.硬盘方式引导读取并执行引导扇区 MBR
3.加载grub(引导程序)启动菜单(/\)
4.加载内核(只读方式)
5.挂载根目录系统启动init进程
6.读取/etc/inittab配置文件
7.执行/etc/rc.d/rc.sysint脚本
8.根据/etc/initab文件下的启动级别执行/etc/rc.d/rc下的脚本
9.执行/etc/rc.d/rc.local (开机脚本开机自动执行的指令放在这个脚本里)
1# inittabThis file describes how the INIT process should set up
2 #the system in a certain run-level.
3 #
4 # Author:Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
5 #Modified for RHS Linux by Marc Ewing and Donnie Barnes
6# Default runlevel. The runlevels used by RHS are:
7 #0 - halt (Do NOT set initdefault to this)
8#1 - Single user mode 单用户模式用于系统维护
9 #2 - Multiuser, without NFS (The same as 3, if you do not have networking)
多用户模式但不能联网
10 #3 - Full multiuser mode多用户模式(字符界面)
11 #4 - unused用户定义
12 #5 - X11图形界面
13 #6 - reboot系统重启
14 id:3:initdefault:
15 # System initialization.
16 si::sysinit:/etc/rc.d/rc.sysinit
17 l0:0:wait:/etc/rc.d/rc 0最后一个数字表示将此数字传递给 /etc/rc.d/rc脚本
18 # Trap CTRL-ALT-DELETE
19 ca::ctrlaltdel:/sbin/shutdown -t3 -r now在任何级别下都可以使用ctrl+alt+del 执行/sbin/shutdown -r 表示关机并重新启动系统, 默认三秒后立即执行
20 # When our UPS tells us power has failed, assume we have a few minutes
21 # of power left.Schedule a shutdown for 2 minutes from now.
22 # This does, of course, assume you have powerd installed and your
23 # UPS connected and working correctly.
24 pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"
系统断电后执行/sbin/shutdown -h表示关机之后不重新启动-f表示重新启动不执行
25 # If power was restored before the shutdown kicked in, cancel it.
26 pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"
电力恢复之后取消已经运行的shutdown指令
27 # Run gettys in standard runlevels
28 1:2345:respawn:/sbin/mingetty tty1/sbin/mingetty表示产生字符终端共六个字符终端respawn表示再生的意思
29 # Run xdm in runlevel 5
30 x:5:respawn:/etc/X11/prefdm -nodaemon
启动故障可分为两大阶段:
1.系统引导扇区MBR出现问题
2.Grub菜单出现问题
一、MBR扇区出现故障
[root@localhost ~]# ddif=/dev/zeroof=/dev/sdabs=446count=1
解决方式:重建MBR用可安装光盘引导
在此界面下进入急救模式:按F5或者输入linuxresuce
将./mnt/sysp_w_picpath当做系统根目录:#chroot /mnt/sysp_w_picpath指定硬盘的根目录
1.指明引导系统执行root
#root (hd0,0)再执行setup重建MBR
#setuohd0
输入quit、exit进行重新启动
2.GRUB引导菜单出现故障
查看/boot/grub
[root@localhost ~]# ll /boot/grub
1 # grub.conf generated by anaconda
2 #
3 # Note that you do not have to rerun grub after making changes to this file
4 # NOTICE:You have a /boot partition.This means that
5 #all kernel and initrd paths are relative to /boot/, eg.
6 #root (hd0,0)
7 #kernel /vmlinuz-version ro root=/dev/sda2
8 #initrd /initrd-version.img
9 #boot=/dev/sda
10 default=0默认操作系统
11 timeout=5超时
12 splashp_w_picpath=(hd0,0)/grub/splash.xpm.gz#grub菜单背景图片
13 hiddenmenu
故障1.删除grub.conf文件
[root@localhost ~]# rm/boot/grub/grub.conf
rm: remove regular file `/boot/grub/grub.conf'? y
[root@localhost ~]# cd/boot/grub
重启
Grub提示第二阶段有问题
查看可执行的指令
执行kernel/vmlinuz-2.6-164.e15roroot=/dev/sda2 quit
Initrd /initrd-2.6.18-164.e15.img
执行完成后重新启动
启动完成
[root@localhost ~]# grub-install
install_device not specified.
Usage: grub-install [OPTION] install_device
Install GRUB on your drive.
-h, --helpprint this message and exit
-v, --versionprint the version information and exit
--root-directory=DIRinstall GRUB p_w_picpaths under the directory DIR
--grub-shell=FILEuse FILE as the grub shell
--no-floppydo not probe any floppy drive
--force-lbaforce GRUB to use LBA mode even for a buggy
BIOS
--recheckprobe a device map even if it already exists
This flag is unreliable and its use is
strongly discouraged.
INSTALL_DEVICE can be a GRUB device name or a system device filename.
grub-install copies GRUB p_w_picpaths into the DIR/boot directory specfied by
--root-directory, and uses the grub shell to install grub into the boot
sector.
重启:
故障二:/boot 目录被删的解决办法
rm-rf/boot/*(删除/boot下的所有内容)删除后重新启动重启:
解决办法:将光驱挂载上进入救援模式:
Chroot/mnt/sysp_w_picpath(使用chroot指令切换到硬盘的目录)
cd/boot && ls(切换到boot目录并查看内容)
Boot下面主要是内核和grub引导菜单所以若想重新启动就要安装内核和grub
挂载光驱
Mount /dev/hdc/mnt
安装内核,内核安装完成后会自动安装initrd
Rpm-ivh--force/mnt/Server/kernel-2.6.18-164.e15.i686.rpm内核安装完成之后安装grub
再次查看/boot目录下的内容
查看grub的内容
#cd/boot/grub/
#touchgrub.conf
#vim grub.conf
重新编写grub.conf
输入exit重新启动
故障三;文件系统表改变
Vim/etc/fstab若文件没有备份
重新启动后出现
进入管理员模式:
Mount -oremount