Resetting root password on CentOS 7 Cloud Image

General root password recovery on CentOS 7 does not work with a Cloud Image. This guide is just a quick memo to myself. Tested on OpenStack.

    1. Boot to GRUB menu.
    2. Press e to edit.
    3. Go to line starting with linux16 (kernel command) and do some magic:
      – Modify ro to rw init=/sysroot/bin/sh.
      – Modify all of ttyS0 to tty0 or just console=ttyS0 to console=tty0.
      – Append rd.break enforcing=0 to the end of the line.
    4. Press Ctrl+X to start in single user mode.
    5. Execute:
      chroot /sysroot
    6. Reset password:
      passwd root
    7. Update SELinux information:
      touch /.autorelabel
    8. Exit chroot:
      exit
    9. Reboot the system:
      reboot
    10. Done.

Notes:

  • tty0 is Graphical Console.
  • ttyS0 is Serial Console.

Credits:

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s