RHEL7 修改内核参数错误,导致系统启动失败

RHEL7 修改内核参数错误,导致系统启动失败

问题现象

当错误的配置hugepages大小时,设置的大于系统内存大小,重启就会发现系统起不来。今天又发现了一个参数,设置错误,也会造成系统启动失败,特此模拟记录下。
先模拟错误发生:
操作系统为RHEL7.6

[root@postgre ~]# cat /proc/sys/fs/file-max
94042
[root@postgre ~]# cat /etc/sysctl.conf 
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
设置错误参数
[root@postgre ~]# vi /etc/sysctl.conf 
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
fs.file-max=700
                                                                                            
"/etc/sysctl.conf" 11L, 465C written

[root@postgre ~]# reboot

好像出现假死的状态:
在这里插入图片描述
提示密码都不正确了,密码没变过。
在图形化接面,一直卡住,转圈,好像系统hang了。

在这里插入图片描述

问题原因

错误的配置了内核参数

解决方案

因某些修改操作,导致系统重启后无法正常启动,此时可进入救援模式,修复错误配置即可。
我发现7进入救援模式有两种

rw init=/sysroot/bin/sh

  1. 重启操作系统
    在这里插入图片描述
  2. 在启动过程中,当GRUB2菜单出现时,按e键进行编辑
    在这里插入图片描述
  3. 按e之后,就会出现如下接面在这里插入图片描述4. 进入后,找到linux16 开头的一行!按向右的方向键,定位到ro 在这里插入图片描述
  4. 将ro替换为rw init=/sysroot/bin/sh在这里插入图片描述
  5. 按ctrl+x重启,就会进入到如下界面。
    进入系统后,其实只是进入了一个安全模式下的内存系统,并不是真正的咱们正常使用的linux系统在这里插入图片描述
  6. 使用命令 #chroot /sysroot/ 切换到正常系统中去!在这里插入图片描述
  7. 修改错误配置
    在这里插入图片描述
    注意;修改完成后,此时直接在命令行重启系统,会报错,因为这不是一个正常的操作系统。
    在这里插入图片描述
  8. 硬重启,相当于摁电源重启

在这里插入图片描述
启动恢复正常。
在这里插入图片描述

systemd.unit=rescue.target

  1. 在启动过程中,当GRUB2菜单出现时,按e键进行编辑
    在这里插入图片描述
  2. 在x86-64系统上的linux16行的末尾或UEFI系统上的linuxefi行的末尾添加以下参数
    systemd.unit=rescue.target
  3. 光标向下翻,找到linux16开头的行,Ctrl+e (or End)跳至行的结尾,添加参数
    在这里插入图片描述
  4. 按Ctrl+x 使用参数启动系统,需要输入root密码,在这里插入图片描述
  5. 输入root密码,就会进入操作系统在这里插入图片描述
  6. vi修改错误配置在这里插入图片描述
  7. reboot重启操作系统,操作系统就会正常启动。在这里插入图片描述

参考:
https://blog.51cto.com/asd9577/1931442
https://www.freesion.com/article/5686202778/

记录下:
在这里插入图片描述

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值