今天在测试审计工具Linux Audit的时候,无意中将SELinux设置为enforing状态,然后重启系统后进不了,报错kernel panic。使用光盘进入linux rescue模式,但是不能修改/etc/selinux/conf和/mnt/sysimage/etc/selinux/conf中的参数,因为是只读模式。在网上查了一些资料,发现在系统的启动选项里可以给SELinux传递参数,这样可以在系统启动时改变SELinux状态。
具体过程是这样的,重新启动,在启动过程中选择“e”,在系统启动的时候在内核启动项中增加“enforcing=0”或者是“enforcing=1”来改变selinux的值,另外按radhat官方网站说明,执行setenforce 0可以设置为permissive模式,而执行setenforce 1可以设置为enforcing模式。
这样在启动时有这么两种解决办法:
1. 修改启动选项:
在kernel一行后添加enforcing=0将SELinuix设置为permissive模式,如下所示,该方法实验成功。
title Asianux(2.6.18)
root (hd0,0)
kernel /vmlinuz-2.6.18 enforcing=0
initrd /initrd-2.6.9-5.EL.img
修改完了,按b重启系统。
2. 在Linux rescue模式下执行命令,如下(该方法没有实验)
# getenforce
Enforcing
# setenforce 0
# getenforce
Permissive
除了以上两种方法,根据网上资料,还可能有第三种方法,具体如下:
3. 通过光盘启动,进入linux rescue修复模式,根据英文提示your system ha been mounted under /mnt/sysimage.press return to get a shell,if your would like to make your system the root environment , run the command : chroot /mnt/sysimage.
就是说如果需要编辑,可以先输入命令:
# chroot /mnt/sysimage
然后就是可读写模式了,这样再去修改selinux的配置,然后重启系统,应该就可以了。(此方法没有实验)