CentOS 7在grub rescue模式中修復系統


安裝完CentOS 7后 修改硬盤分區后,系統重啟后,無法正常啟動,進入grub rescue模式; 

網上大多數centos grub rescue的資料應該是Centos 7之前的,其中提到的命令很多使用的目錄是grub,而在7中,這里應該替換成grub2;

另外normal.mod 的目錄也有變化。特別要注意


1)首先找到centos 的boot是裝在那個分區中;

1. 先使用ls命令
在 grub rescue>下輸入以下命令:

ls
會羅列所有的磁盤分區信息,比方說:

引用:

(hd0,1),(hd0,5),(hd0,3),(hd0,2)
  注:我的是(hd0),(hd0,msdos3),(hd0,msdos5)等
2. 然后依次調用如下命令: X表示各個分區號碼
如果/boot沒有單獨分區,用以下命令:

ls (hd0,X)/boot/grub2
如果/boot單獨分區,則用下列命令:

ls (hd0,X)/grub2
例如:
grub rescue> ls (hd0,msdos2)/grub2 

會有如下的輸出:
 -grub2  grub  grub.cfg  i386-pc ...


2)

grub rescue> ls (hd0,msdos2)/grub2 // 找到/boot分區位置
--> grub2 grub grub.cfg i386-pc ...


grub rescue> set root=hd0,msdos2 // 臨時重置grub位置為當前分區
grub rescue> set prefix=(hd0,msdos2)/grub2
grub rescue> insmod (hd0,msdos2)/grub2/i386-pc/normal.mod
// 加載normal模塊
grub rescue> normal // 調用normal模塊


3)重新安裝grub到sda
這時就出現了 grub引導菜單,選擇進入CentOS系統

登錄
login:root
passwd:*****

# cd /sbin
# grub2-install --boot-directory=/boot   /dev/sdb  // 重新安裝grub到sdb, 根據ls /dev/sd* 的結果,替換成你自己的硬盤
--> grub2-install completed, No Error occured.


# reboot

  

轉載自:http://blog.csdn.net/junglefly/article/details/51325393

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM