Recover root password or failed mount on a Centos 7 instance

If you need to set the root password or fix a faulty /etc/fstab for example then this is the procedure to access the boot disk without a root password.

Reboot the instance and press "e" when the grub 2 boot menu is shown.

Add the following parameters at the end of the linux16 line

    rd.break enforcing=0

and remove all parameters starting with "console="

Press Ctrl+x to boot

Remount the root filesystem read write

mount -o remount,rw /sysroot

 

Now you can edit the root disk files under /sysroot.
If you want to set a new password do a change root and set password.

chroot /sysroot
passwd

 

When you are done reboot the instance

reboot 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.