【MBR故障】

用命令来把MBR的前446字节覆盖

Dd if=/dev/zero of=/dev/sda bs=446 count=1

结果:无法登录系统

Centos下的rescue救援模式_linux


1. 虚拟机进去bios,将CD-ROM Drive设置为第一启动项

Centos下的rescue救援模式_虚拟机_02


Centos下的rescue救援模式_虚拟机_03


2. 加载镜像文件,进入救援模式

Centos下的rescue救援模式_count_04


3. 默认选项

Centos下的rescue救援模式_linux_05


Centos下的rescue救援模式_count_06


4.  继续选择

Centos下的rescue救援模式_count_07


Centos下的rescue救援模式_count_08


5. 选择默认

Centos下的rescue救援模式_count_09


Centos下的rescue救援模式_虚拟机_10


6. 选择shell编辑模式

Centos下的rescue救援模式_linux_11


7. 输入clear,回车清屏

Centos下的rescue救援模式_linux_12



8. chroot /mnt/sysp_w_picpath,即切换到机器系统的根目录,改写MBR

命令 grub-install /dev/sda

Centos下的rescue救援模式_linux_13



9. 输入两次exit命令,重启,成功登录

Centos下的rescue救援模式_linux_14




【误删grub.conf文件救援】


1. 删除文件 rm -rf /boot/grub/grub.conf

Centos下的rescue救援模式_linux_15


2. 重启linux,无法登录系统

Centos下的rescue救援模式_count_16


3.  启动linux,通过kernel和initramfs


a. root   (hd0,0) 系统的安装位置    注:root   (hd0,按tab键,自动打印分区,0x83的分区都需测试

b. kernel   /vmlinuz-2.6.18-8.el5  注:输入/vmlinuz按tab健补全,表示测试正确

c. initrd  /initrd-2.6.18-8.el5.img  注:输入/init 按tab健可以补全

d. boot    启动


Centos下的rescue救援模式_虚拟机_17


注:如启动不了,说明根分区选择错了(即/根分区和boot分区不在同一分区),需重新设置根分区:

root=/dev/sda3

说明:(hd0,0)=/dev/sda1   (hd0,2)=/dev/sda3


4. 成功登入系统

Centos下的rescue救援模式_count_18


5. 查看根分区uuid,用于创建grub配置文件

Centos下的rescue救援模式_linux_19


6. 创建grub.conf文件

vim /boot/grub/grub.conf

Centos下的rescue救援模式_count_20


配置文件详解:

default=0        //默认系统列表的第一个启动

timeout=5       //默认启动等待时间5秒

splashp_w_picpath=(hd0,0)/grub/splash.xpm.gz          //系统选择菜单背景所在的位置

hiddenmenu      //隐藏菜单 

title Re-system Centos 6.8               //在grub界面所显示的系统名称

root (hd0,0)     //启动时从IDE接口的第一块硬盘第一个分区启动

kernel /vmlinuz-2.6.32-642.el6.x86_64 ro root=UUID=3fcf7112-c461-4d02-90b8-416b0d587856    //启动的内核版本,可以在后面添加内核参数

initrd /initramfs-2.6.32-642.el6.x86_64.img  //加载的镜像文件


7. 重启,成功登入系统

Centos下的rescue救援模式_虚拟机_21



【误删grub目录救援】


Centos下的rescue救援模式_count_22

结果:无法登入系统

Centos下的rescue救援模式_linux_23


1. 通过镜像,进入救援模式,生成grub目录

grub-install --root-directory=/ /dev/sda

说明:grub.conf配置文件不能生成

Centos下的rescue救援模式_虚拟机_24


2. 进入grub界面,通过kernel和initramfs启动Linux系统,并创建grub.conf文件即可

Centos下的rescue救援模式_count_25