一.centos的啟動流程
post–mbr grub 1stage–stage1.5–stage 2 /boot/grub—/boot/grub/grub.conf —kernel /vmlinuz.XXX root=— /boot/initramfs |/boot/initrd.XX.img —/sbin/init –/etc/inittab —/etc/rc.d/rc.sysinit(/etc/fstab) —/etc/rc5.d/K,S —/etc/rc.d/rc.local –login
首先我們來解釋一下:
1.加載BIOS的硬件信息,獲取第一個啟動設備
2.讀取第一個啟動設備MBR的引導加載程序(grub)的啟動信息
3.加載核心操作系統的核心信息,核心開始解壓縮,并嘗試驅動所有的硬件設備
4.核心執行init程序,并獲取默認的運行信息
5.init程序執行/etc/rc.d/rc.sysinit文件
6.啟動核心的外掛模塊
7.init執行運行的各個批處理文件(scripts)
8.init執行/etc/rc.d/rc.local
9.執行/bin/login程序,等待用戶登錄
10.登錄之后開始以Shell控制主機
GRUB的三個階段:
第一階段:MBR
第1.5階段:讓第一階段能夠識別boot分區
第二階段:放在/boot/grub/grub.conf
Init:
centos 6的第一個進程
它的配置文件:/etc/inittab /etc/init/*.conf
運行級別:七個級別
0、關機
1、單用戶模式
2、多用戶模式
3、多用戶模式(命令界面)
4、預留級別
5、多用戶模式(圖形界面)
6、重啟
默認級別:3和5
切換級別:init #
查看級別:runlevel :
在/etc/rc.d/rc#.d中:
以K開頭的文件:數字越小,越先運行,數字越小的服務,通常為依賴到別的服務。
以S開頭的文件:數字越小,越先運行,數字越小的服務,通常為被依賴的服務。
Chkconfig命令:
查看服務:chkconfig –list
添加服務:chkconfig –add
刪除:chkconfig –del
指定開啟服務的級別:chkconfig –level # 【name】 on
指定關閉服務的級別:chkconfig –level # 【name】 off
Ntsysv命令:管理服務啟動狀態(交互式)
Service 服務名 start 開啟服務
Service 服務名 stop 關閉服務
Service 服務名 restart 重啟服務
Service –status-all 顯示所有服務狀態
二.關于系統啟動與錯誤的幾個實驗
1,Grub三個階段破壞后如何修復?
第一個階段:例 dd if=/dev/zero of=/dev/sda bs=1 count=446 破壞MBR分區然后reboot
首先進入光盤引導
選擇rescue installed system救援模式
選擇shell進入shell界面
chroot /mnt/sysimage/ 切根
grub-install /dev/sda(可以生成grub文件恢復mbr扇區)
exit
reboot
2.grub的第1.5階段破壞修復:
dd if=/dev/zero of=/dev/sda bs=1 count=2048 skip=512 seek=512
reboot
進入光盤引導
選擇rescue installed system救援模式
選擇shell進入shell界面
chroot /mnt/sysimage/ 切根
grub
grub>root (hd0,0)(第一個硬盤的第一個分區)
grub>setup (hd0)
grub>quit
exit
reboot
grub第二階段破壞修復:Grub目錄下的文件全被破壞了如何修復?
rm -rf /boot/grub/*
reboot
進入光盤引導
選擇rescue installed system救援模式
選擇shell進入shell界面
chroot /mnt/sysimage/ 切根
grub-install /dev/sda
vim grub.conf
Default=0
Timeout=3
Title wanglingux
Kernel /vmlinuz root=/dev/sda2 \uuid
Initrd /initramfs-2.6.32-696.el6.x86_64.img
#exit
#reboot
原創文章,作者:gd1479,如若轉載,請注明出處:http://www.www58058.com/79497