linux系统中的/boot目录存放着系统开机所需要的各种文件,其中包含内核、开机菜单及所需配置文件等等。
但是当不小心删除了/boot目录里的某些文件或者干脆整个/boot目录都不见了的情况下,该如何恢复系统并重启系统呢?
以下通过加载磁盘镜像文件以重装内核与grub2加载器的方式可解决这个问题,只是过程有点复杂。
实验环境:KVM中的rhel7系统。
1.模拟删除/boot目录,使系统无法启动

2.reboot尝试重新启动,确认系统已故障

3.强制关闭系统

4.进入虚拟机配置页面,通过以下点击顺序选择导入本地磁盘镜像文件

选择导入磁盘镜像文件

5.重启设置启动顺序,添加CDROM启动,操作如下所示

6.重新启动系统,系统启动时按F12进入boot menu界面


7.输入数字”3“,通过DVD/CD引导,然后选择以下截图中的”Troubleshooting“

8.选择以下截图中的"Rescue a Red Hat Enterprise Linux system",回车

9.进入Recue环节,以下截图中点击Continue-》OK-》OK



10.变更root目录

11.挂载cdrom到/mnt

12.配置本地软件仓库文件

13.重新安装内核,注意一定要使用reinstall命令,不能使用install

14.重新安装grub2

15.重新生成grub2配置文件grub.cfg

16.两次exit后重新启动,系统已经成功恢复!
