Linux启动提示Kernel panic - not syncing: Attempted to kill init解决办法

配置FTP服务的时候,修改了selinux参数。修改/etc/selinux/config中的SELINUXTYPE=targeted修改为Disable。导致 linux系统不能启动。

出现错误 Kernel panic -not syncing:Attempted to kill init!

网上查找,有人遇到相同问题,解决方案如下:

在linux启动界面出现时,按f2进入如下界面:

按e进入如下界面
移动到第2个选项,再按e进入编辑

在后面输入 selinux=0

按回车。
返回到原来界面

再按b,就可以启动了。

 

SELINUX从理解到动手配置。

SELinux 可以为你的系统提供较棒的安全防护。 使用者能被分配预先定义好的角色,以便他们不能存取文件或者访问他们不拥有的程序。

Selinux的启用与关闭

编辑/etc/selinux/conf文件

SELINUX=enforcing(强制:违反了策略,你就无法继续操作下去)

Permissive(有效,但不强制:违反了策略的话它让你继续操作,但是把你的违反的内容记录下来)

Disabled(禁用)

禁用的另一种方式:在启动的时候,也可以通过传递参数selinux给内核来控制它

编辑/etc/grup.conf

title Red Hat Enterprise Linux Server (2.6.18-8.el5)

root (hd0,0)

kernel /vmlinuz-2.6.18-8.el5 ro root=LABEL=/ rhgb quiet selinux=0

initrd /initrd-2.6.18-8.el5.img

SELINUXTYPE=targeted

此参数可选项:targeted和strice。分别是targeted只控制关键网络服务,strice控制所有的服务

查询selinux的状态

[root@linuxas ~]# /usr/sbin/getenforce

Enforcing

[root@linuxas ~]# sestatus -bv

SELinux status: enabled

SELinuxfs mount: /selinux

Current mode: enforcing

Mode from config file: enforcing

Policy version: 21

Policy from config file: targeted

查看selinux加载的内核模块

[root@linuxas selinux]# semodule -l

amavis 1.1.0

ccs 1.0.0

clamav 1.1.0

dcc 1.1.0

evolution 1.1.0

iscsid 1.0.0

mozilla 1.1.0

mplayer 1.1.0

nagios 1.1.0

oddjob 1.0.1

pcscd 1.0.0

pyzor 1.1.0

razor 1.1.0

ricci 1.0.0

smartmon 1.1.0

查看selinux错误日志

[root@linuxas selinux]# sealert -a /var/log/audit/audit.log

SElinux的图形化管理工具

[root@linuxas selinux]# system-config-selinux

Selinux的基本操作

查看文件:ls –Z(--context)

[root@linuxas ~]# ls -Z

drwx------ root root root:object_r:user_home_t Desktop

-rw------- root root system_u:object_r:user_home_t anaconda-ks.cfg

-rw-r--r-- root root root:object_r:user_home_t install.log

-rw-r--r-- root root root:object_r:user_home_t install.log.syslog

[root@linuxas ~]# ls --context

drwx------ root root root:object_r:user_home_t Desktop

-rw------- root root system_u:object_r:user_home_t anaconda-ks.cfg

-rw-r--r-- root root root:object_r:user_home_t install.log

-rw-r--r-- root root root:object_r:user_home_t install.log.syslog

查看文件系统的扩展属性:getfattr

[root@linuxas ~]# getfattr -m. -d /etc/passwd

getfattr: Removing leading '/' from absolute path names

# file: etc/passwd

security.selinux="system_u:object_r:etc_t:s0\000"

查看的文件的 security.selinux 属性中储存了此文件的安全上下文, 所以上面例子中的上下文就是 system_ubject_r:etc_t 。

所有运行了SE Linux的ext2/3文件系统上都有 security.selinux 这个属性。

更改文件的扩展属性标签:chcon (不能在 /proc 文件系统上使用,就是说 /proc 文件系统不支持这种标记的改变。)

[root@linuxas test]# ls --context aa.txt

-rw-r--r-- root root root:object_r:user_home_t aa.txt

[root@linuxas test]# chcon -t etc_t aa.txt

[root@linuxas test]# ls --context aa.txt

-rw-r--r-- root root root:object_r:etc_t aa.txt

恢复原来的文件标签: restorecon

[root@linuxas test]# restorecon aa.txt

[root@linuxas test]# ls -Z aa.txt

-rw-r--r-- root root user_u:object_r:user_home_t aa.txt

显示当前用户的Selinux context

[root@linuxas ~]# id -Z

root:system_r:unconfined_t:SystemLow-SystemHigh

runcon 使用特定的context来执行指令

[root@linuxas ~]# runcon -t user_home_t cat /etc/passwd

root:system_r:user_home_t:SystemLow-SystemHigh is not a valid context

查看某种服务是否受到SELinux的保护

[root@linuxas ~]# getsebool -a (RHEL4:inactive受保护,active不受保护;RHEL5:off受保护,on不受保护)

 

以上原文地址:http://hehaibo.iteye.com/blog/749860

  • 3
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
Kernel panic - not syncing: Attempted to kill init!是一种严重的内核错误,表示内核无法继续正常运行并试图终止init进程。修复这个问题的步骤如下: 1. 首先,尝试重启系统。如果问题仍然存在,进入控制台查看错误信息。\[1\] 2. 如果重启后仍然出现相同的错误,可以尝试进入单用户模式进行排查。在控制台重启后,按下任意键,然后按下"e"键。使用上下箭头选择第二个选项,再次按下"e"键。在末尾添加"1",然后按下Enter键,最后按下"b"键进入单用户模式。然而,如果单用户模式也无法进入并且错误仍然存在,需要尝试其他方法。\[2\] 3. 下一步是进入救援模式。挂载镜像并从光盘启动系统。按下上下箭头选择救援模式启动。进入救援模式后,使用chroot命令切换到根目录环境下,执行以下命令:chroot /mnt/sysimage。\[3\] 以上是修复Kernel panic - not syncing: Attempted to kill init!故障的一般步骤。然而,具体的修复方法可能因系统环境和具体情况而异。建议在进行修复之前,先备份重要数据,并参考相关文档或咨询专业人士以获取更准确的指导。 #### 引用[.reference_title] - *1* *2* *3* [Kernel panic – not syncing: Attempted to kill init!故障修复](https://blog.csdn.net/weixin_43770382/article/details/107686813)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值