centos 6/centos 7開機mbr/grub出現故障的修復方法

CentOS 6:
當grub出現故障,但未重啓,可以如下恢復
方法一:
[root@localhost ~]# dd if=/dev/sda of=/root/mbr.bak count=1 bs=512 #備份
[root@localhost ~]#dd if=/dev/zero of=/dev/sda count=1 bs=200 #破壞mbr扇區
[root@localhost ~]#sync
[root@localhost ~]# grub-install --root-directory=/ /dev/sda #恢復mbr
[root@localhost ~]# reboot
方法二:
[root@localhost ~]# grub
grub> root (hd0,0)
grub> setup (hd0)
grub> reboot

如果已經重啓了系統,此時插入光盤(救援盤)在開機界面選擇Rescue install或按(ESC->linux rescue #== Rescue install重啓後的救援模式,然後依次選擇
contunue
shell bash shell
chroot /mnt/sysimage
grub-install --root-direcoryt=/ /dev/sda
exit #退出shell
reboot #停掉光驅,重啓正常進入系統

CentOS 7 mbr修復
[root@localhost ~]# dd if=/dev/sda of=/root/mbr.bak count=1 bs=512 #備份
[root@localhost ~]# dd if=/dev/zero of=/dev/sda count=1 bs=200 #破壞mbr扇區
[root@localhost ~]# sync
[root@localhost ~]# reboot
#插入光盤,依次選擇如下
Troubleshooting
Rescue a CentOS system
<Enter>
1 <Continue>
2 <shell>
sh-4.2# grub2-install --root-directory=/mnt/sysimage /dev/sda

CentOS 7 grub修復(在修復mbr的基礎上增加一個步驟)
sh-4.2# grub2-mkconfig -o /boot/grub2/grub.cfg
sh-4.2# exit
sh-4.2# reboot #成功啓動系統,更多關於此項可參閱鳥哥的linux私房菜,說的很詳細

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章