八、 启动引导  
 
 1 、 Linux 的启动流程  
 
 1) BIOS  自检  
 
 2)  启动  GRUB/LILO  
 
 3)  运行  Linux kernel  并检测硬件  
 
 4)  挂载根文件系统  
 
 5)  运行  Linux  系统的第一个进程  init( 其  PID  永远为  1 ,是所有其它进程的父进程 )  
 
 6) init  读取系统引导配置文件  /etc/inittab  中的信息进行初始化 7)  执行系统初始化脚本-  /etc/rc.d/rc.sysinit ,执行系统初始化 ( 包括很多内容 )  
 
 8)  根据指定的运行级别 (runlevel) 来运行服务器脚本程序,再执行脚本  /etc/rc.d/rc.local  
 
 9)  运行一些其他的特别服务,一般为  /sbin/mingetty  和  /etc/X11/prefdm  
 
 10) Linux  控制台 (console) 提示用户输入用户名、密码进行登陆。  
 
 总结: BIOS  初始化  检查外围设备  检查启动设备  读区  MBR  
 
 
 
 2 、在 Linux 中常用的启动引导工具: grub 和 lilo  
 
 在  Linux  和  WINDOWS  两系统并存时就需要安装  GRUB ( Grand Unified Bootloader ), GRUB  被广泛地  
 
 用于替代  lilo,GRUB  支持在启动时使用命令行模式 , 支持  md5  加密保护 还可以从  ext2/ext3 、 ReiseFS 、 JFS 、  
 
 FAT 、 minix  及  FFS  文件系统上启动其配置文件为 /boot/grub/grub.conf, 更改  grub.conf  即可立时生效如果  
 
 硬盘上的  MBR  被更动过,可以用 /sbin/grub-install /dev/hda  来重安装  grub  现在我们打开  
 
 /boot/grub/grub.conf  查看一下  
 
 # vim /boot/grub/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  
 
 #default=0  表示默认启动第一个系统 , 如果系统有两个系统是用什么做为分隔符的呢? title  就是系统的分  
 
 隔符 , 第一个  title  后面就是第一个系统 , 用  0  表示。  
 
 timeout=5  
 
 #timout=5 ,就是默认在启动选择界面停留的时间,单位是秒。等待  5  秒自动进入默认操作系统  
 
 splashimage=(hd0,0)/grub/splash.xpm.gz  
 
 #splashimage  是  grub  启动背景画面,如果是自己写  grub.conf  文件,这个可以不用写。  
 
 hiddenmenu  
 
 title Red Hat Enterprise Linux Server (2.6.18-53.el5)  
 
 #title  后面就是系统在启动时候显示的名字  
 
 root (hd0,0)  
 
 #root  启动文件所在位置  
 
 kernel /vmlinuz-2.6.18-53.el5 ro root=LABEL=/ rhgb quiet  
 
 #kernel  内核所在位置和名字  
 
 initrd /initrd-2.6.18-53.el5.img  
 
 #initrd  内核镜象的名字  
 
 grub.conf  的范例:  
 
 timeout=10 # 等待  10  秒自动进入默认操作系统  
 
 splashimage=(hd0,0)/grub/splash.xpm.gz #grub  启动背景画面  
 
 default=0 # 默认进入第一个标题  
 
 title Red Hat Linux (2.4.20-18) #Red Hat Linux  标题  
 
 root (hd0,0) # 根文件系统位置  
 
 kernel /vmlinuz-2.4.20-18 ro root=LABEL=/ # 核心位置与核心加载参数  
 
 initrd /initrd-2.4.20-18.img # 启动  initrd ram  盘  
 
 title windows # 另一个操作系统的标题  
 
 rootnoverify (hd0,1) # 操作系统存放在  hd0,1  上,不要在  grub  里  mount  
 
 chainloader +1 # 从  hd0,1  的第一个扇面启动