方法一
- 重启服务器
- 按e进入编辑模式
- 将光标移到linux这一行,在末尾添加rd.break
- ctrl+x启动
- 进入命令行,mount -o remount,rw /sysroot
- chroot sysroot
- passwd root
- 修改root的密码
- touch /.autorelabel #getenforce查看selinux有没有关,没关执行touch /.autorelabel selinux
- exit
- reboot(重启过程中要等一会)
方法二
- 按e进入编辑模式,光标移到linux一行
- 将ro包括ro在内这一行后面参数替换为rw init=/sysroot/bin/sh
- ctrl+x启动
- chroot /sysroot
- passwd root
- touch /.autorelabel
- exit
- reboot