[Linux學習筆記] Linux系統引導流程(二)

GRUB的配置文件shell

軟連接: /etc/grub.conf;文件位置: /boot/grub/grub.confui

下面給出grub.conf配置文件並就相關配置項進行說明:this

[root@collect3 grub]# cat 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/VolGroup00/LogVol00
#          initrd /initrd-version.img
#boot=/dev/sda
default=0    # default定義缺省啓動系統
timeout=5    # timeout定義缺省等待時間
splashimage=(hd0,0)/grub/splash.xpm.gz    # splashimage定義GRUB界面圖片(hd0,0)表示/boot分區<hd表示硬盤,參數1:hd0表示第一塊硬盤,參數2:0表示第一個分區>
hiddenmenu    # hiddenmenu隱藏菜單
title GreatTurbo Enterprise Server (2.6.9-78.ELhugemem)    # title定義菜單項名稱
	root (hd0,0)
	kernel /vmlinuz-2.6.9-78.ELhugemem ro root=/dev/VolGroup00/LogVol00 acpi=on    # 定義內核文件所在位置(/boot目錄下)
	initrd /initrd-2.6.9-78.ELhugemem.img    # 命令加載鏡像文件
title GreatTurbo Enterprise Server-smp (2.6.9-78.ELsmp)

單用戶模式:加密

(1) 系統啓動過程當中按Esc鍵進入GRUB界面;
spa

(2) GRUB界面按e進行編輯行模式,選中kernel行,再次按e鍵,在新的界面的最後一行輸入1或s,便可進行單用戶模式. Enter回車保存後,再次跳到GRUB界面;
命令行

(3) 按b鍵從新引導boot.code

(4) 從新啓動後將進入單用戶模式,該模式下無圖形界面,無需密碼便可進入root用戶命令行。此時能夠修改root密碼orm

設置GRUB密碼:圖片

[root@localhost ~]# grub-md5-crypt
Password: 
Retype password: 
$1$HDiFX$CfZRdJWPYkb5qq2w8lhKw/
[root@localhost ~]# grub
Probing devices to guess BIOS drives. This may take a long time.


    GNU GRUB  version 0.97  (640K lower / 3072K upper memory)

 [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename.]
grub> md5crypt
md5crypt
Password: 123456
123456
Encrypted: $1$GViFX$JlugRZWB7bfs3RQfe./th.
grub> quit

如此咱們得到了md5加密後的串,接下來修改grub.conf文件,加入行:md5

password --md5 $1$GViFX$JlugRZWB7bfs3RQfe./th.

系統從新啓動後,進入GRUB界面以下截圖:

系統修復及手動引導啓動:

(1) GRUB命令行手工方式引導;

(2) 光盤引導

1.把安裝盤放到光驅,而後從新啓動機器,在BIOS中指定系統爲光驅引導l
2.等待安裝界面顯示後,按[F5]鍵進入Linux Rescue模式
3.sh#命令行修復

下面來簡單介紹一下CentOS-7如何進入到單用戶模式修改root密碼:

(1) 系統開始啓動時,按下ESC鍵,進入GRUB界面

(2) GRUB界面截圖以下:

(3) 修改框住的"ro",鍵入rw init=/sysroot/bin/sh

(4) 進入單用戶模式,輸入命令:

:/# chroot /sysroot    #訪問系統
:/# passwd root    #重置root密碼
:/# touch /.autorelabel    #更新系統信息
:/# exit    #退出chroot
exit
:/# reboot
相關文章
相關標籤/搜索