Categories
blog

CentOS 6 kernel panic selinux config file error

CentOS kernel panic after wrongfully changing selinux config file.
Use enforcing=0 kernel boot option to boot and then correct the config file.
Detailed instructions in the article.

If you get a kernel panic on CentOS or RedHat as shown below and you recently changed the selinux config, then there might be an error in the config file.

None of the kernels in the GRUB boot menu will boot, you get a kernel panic:

Kernel panic - not syncing:  Attempted to kill init! Pid: 1, comm: init Not tainted 2.6.32-504.3.3.el6.x86_64 #1 panic+0xa7/0x16f do_exit+0x862/0x870 fput+0x25/0x30 do_group_exit+0x58/0xd0 sys_exit_group+0x17/0x20 system_call_fastpath+0x16/0x1b
Kernel panic – not syncing: Attempted to kill init!
Pid: 1, comm: init Not tainted 2.6.32-504.3.3.el6.x86_64 #1
panic+0xa7/0x16f
do_exit+0x862/0x870
fput+0x25/0x30
do_group_exit+0x58/0xd0
sys_exit_group+0x17/0x20
system_call_fastpath+0x16/0x1b

Booting in single user mode doesn’t work either.

Here’s how to fix this:
1) Reboot, and go in the GRUB menu. You have 3 seconds to strike the arrow keys before it will automatically boot the default kernel.

GRUB boot menu
GRUB boot menu

2) Select the first line, the default kernel, and press the E key on the keyboard to edit the parameters. You will then see the following.

Edit GRUB boot options
Edit GRUB boot options

3) Use the arrow keys to select the 2nd line, that starts with kernel. Press the E key to change this line, use the arrow keys to go to the end and type a space followed by enforcing=0

GRUB edit kernel line
GRUB edit kernel line

4) Press enter to conform and then press B to boot the system.
It should boot up fine now.
Now edit the selinux config file (/etc/sysconfig/selinux) and correct your mistake.
In my case I set disabled for the SELINUXTYPE variable, that’s wrong it has to be set for the SELINUX variable. In the screenshot below I show you the correct settings in the config file to disable SELINUX.

SELINUX disabled correctly
SELINUX disabled correctly

5) Now reboot and everything should be fine!

11 replies on “CentOS 6 kernel panic selinux config file error”

This website has helped me to fix the same issue on RHEL 6.5 machine. Thanks a lot.

Thanx a lot.
I am installing centos(6.5) seven times in our system. But every time i am facing kernel panic problem.
With the help of this artical i am resolve this problem.

You can also boot the machine using the LiveCD rescue mode, mount the filesystem and edit the file to correct your mistake.

Hi Stan. Same error after giving enforcing=0. Doesn’t work. Also I tried with live CD. But unable to mount at bash prompt.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.