1、备份数据

[root@rhel6 ~]# dd if=/dev/sda of=/root/backup/mbr.bak bs=512 count=1
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.000181577 s, 2.8 MB/s
[root@rhel6 ~]# cp /etc/fstab /root/backup/
[root@rhel6 ~]# cp /etc/inittab /root/backup/
[root@rhel6 ~]# cp /etc/rc.d/rc.sysinit /root/backup/
[root@rhel6 ~]# cp /etc/rc.d/rc.local /root/backup/

2、破坏性操作

[root@rhel6 ~]# rm -rf /boot/*
[root@rhel6 ~]# rm -f /etc/fstab 
[root@rhel6 ~]# rm -f /etc/inittab 
[root@rhel6 ~]# rm -f /etc/rc.d/rc.sysinit 
[root@rhel6 ~]# rm -f /etc/rc.d/rc.local 
[root@rhel6 ~]# 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.00297539 s, 150 kB/s
[root@rhel6 ~]# 

3、选择修复模式

从光盘启动,选择Rescure installed system

不需要网络引导--->continue--->shell start shell

Linux 破坏性修复

4、修复fstab

Linux 破坏性修复

如果是逻辑卷系统,则需要执行lvm vgscan和lvm vgchange -ay 激活vg才能挂载。

Linux 破坏性修复

重启后,再次进入修复模式,如果看到chroot /mnt/sysimage,则说明/etc/fstab恢复成功。其实就是把原来的根分区挂载起来,然后利用原来的备份文件进行恢复,

如果之前未进行备份,也可以手动编辑fstab文件来恢复。

5、修复内核

Linux 破坏性修复

挂载光驱后,安装内核。

Linux 破坏性修复

6、恢复引导程序

Linux 破坏性修复

 

还需要手动添加grub.conf配置文件

 

Linux 破坏性修复

Linux 破坏性修复

恢复init:

Linux 破坏性修复

两次exit退出图形界面,选择reboot 

重启后系统自动执行selinux relabel,几分钟后自动重启,至此,系统修复完成。

相关文章: