网上普通的方法在我们本的openstack 虚拟机上无效,可能和底层的组件有关,由于是用的Cefh 存储,使用下面的方法修改root密码:

原文链接:https://www.tecmint.com/reset-forgotten-root-password-in-centos-7-rhel-7/ 

提示:如果在内核参数界面rhgb quiet后还有参数 console=ttyS0的参数也直接去掉,否则无法正常加载环境变量。wKiom1kVe_-zZtsMAAF5e7piTt8704.jpg

 To do this reboot the Server as soon as you get the below screen press 'e' (stands for edit) from keyboard.

Press 'e' to Edit Boot Menu

Press ‘e’ to Edit Boot Menu

After you press 'e' from keyboard you would see a lot of text which may be clipped as per the size of your screen.

Grub Configuration

Grub Configuration

Search for the text “rhgb quiet” and replace it with “init=/bin/bash” without quotes.

Enable Shell

Enable Shell

Once done editing press 'ctrl+x' and it will start booting with specified parameter. And you will get bash prompt.

Booting System

Booting System

Now check the status of root partition by running following command on the single user mode.

# mount | grep root

Check Root Mount Status

Check Root Mount Status

You may notice that root partition is reported to be 'ro' (Read Only). We need to have read-write permission on root partition to change the root password.

# mount -o remount,rw /

Also cross check, if the root partition is mounted with read-write permission mode.

# mount | grep root

Set Permissions on Root Partition

Set Permissions on Root Partition

Now you can change the root password by typing the passwd command. But that is not done. We need to relabel SELinux context. If we skip relabeling the whole SELinux context we would be able to login using using password.

# passwd root
[Enter New Password]
[Re-enter New Password]
# touch /.autorelabel

Reset root Password

Reset root Password

Reboot and login again to root account and see if everything works ok or not?

# exec /sbin/init

Login root User