1、刪除grub stage1階段
[root@centos6 ~]# dd if=/dev/zero of=/dev/sda bs=446 count=1 1+0 records in 1+0 records out 446 bytes (446 B) copied, 0.000518378 s, 860 kB/s [root@centos6 ~]# hexdump -C -n 446 /dev/sda 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 000001b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |..............| 000001be [root@centos6 ~]# hexdump -C -n 446 -v /dev/sda
重啟機器
此時可以看到系統會直接進入到光盤啟動界面
這里我們選擇修復系統
然后進入到shell提示符
執行如下命令
sh-4.1# chroot /mnt/sysimage sh-4.1# grub-install /dev/sda sh-4.1# exit sh-4.1# exit
重啟系統,至此已經修復完成
注意:會在如下界面停留很長時間,屬于正常情況
2、刪除grub start1.5階段
[root@centos6 ~]# dd if=/dev/zero of=/dev/sda bs=512 count=2 seek=1 //破壞1.5階段 [root@centos6 ~]# hexdump -C -n 1024 -v /dev/sda
重啟修復:
此時開機界面會一直黑屏,我們需要選擇光盤啟動,進入緊急救援模式
進入救援模式后,修復方式和破壞grub stage1階段一樣
3、直接刪除grub目錄
[root@centos6 ~]# rm -rf /boot/grub/
重啟;修復
出現如下錯誤提示
重新啟動,選擇光盤引導,進入緊急救援模式
前幾個步驟和前面一樣
sh-4.1# chroot /mnt/sysimage sh-4.1# grub-install /dev/sda sh-4.1# ls /boot/grub ... ....
此時grub目錄已經出現
為grub提供配置文件
sh-4.1# vim /boot/grub/grub.conf
sh-4.1# exit sh-4.1# exit
此時系統便能正常啟動
一個簡單說明:
[root@centos6 ~]# cd /boot/grub/ [root@centos6 grub]# mv *1_5 /root //將1_5的備份文件剪切到其他路徑下 [root@centos6 grub]# grub grub> root (hd0,0) grub> setup (hd0) grub> quit [root@centos6 grub]# ls device.map grub.conf stage1 stage2 //此時grub路徑下仍沒有1_5階段的文件,說明grub命令的修復要依靠state1_5的備份文件 而grub-install則不是 [root@centos6 grub]# grub-install /dev/sda [root@centos6 grub]# ls //此時會出現stage1_5的備份文件 說明grub命令的恢復要依靠grub的備份文件,備份文件沒有則會恢復失敗
原創文章,作者:sixijie,如若轉載,請注明出處:http://www.www58058.com/47848
文章操作新強,有時候,我們就需要自己模擬破壞實驗環境來形成自己的工作經驗哦。建議多做一些實驗。