RHEL 7 Root Password Recovery

Latest response

Hi guys,

when I add add rd.break instead of init=/bin/sh to the line that starts with linux in Grub2, I get dropped in an emergency mode. Please see attached image. I am using a vm, hence " init=/bin/sh " doesn't give me keyboard.

Any way to fix this issue?

Thanks

Arrey

Responses

You did not mention what virtualization method, but can you boot the guest using boot.iso in resque mode (choose Troubleshooting -> Rescue a system)?

UPDATED
Arrey,

also see the comments in this Red Hat solution for some virtualization tips, namely the first comment by Red Hat's Matthew Casperson.

Thanks guys for the response. I figure out the problem. rd.break always drop to the emergency mode. It was not an issue on the OS, it was me not understanding the process. But I do now.

Thanks

Arrey

Adding rd.break to the end of the line with kernel parameters in Grub stops the start up process before the regular root filesystem is mounted (hence the necessity to chroot into sysroot). Emergency mode, on the other hand, does mount the regular root filesystem, but it only mounts it in a read-only mode. Note that you can even change to emergency mode using the systemctl command on a running system (systemctl emergency).

I updated the linked solution (Resetting the Root Password of RHEL-7 / systemd) to make the instructions easier to follow.

I've found recently that sometimes on a virtual system you have to add "console=tty0" at the end on a virtual system else the output goes to a non-available serial console.

RHEL 7 root Password Reset.

Step 1: Break the Consloe while Linux boot. Step 2: Press "e" to edit the kernel. Step 3: append the entry at the end of linux line as below rd.break console=tty1

Step 4: Press CTRL+X

Step 5: mount -o remount,rw /sysroot Step 6: change root password Step 7: touch ./autorelabel Step 8: Type exit two times

Thanks & Regards Namasivayam

1 - on grub menu, select the kernel to boot from and press "e". 2 - append the following to the end of the line that starts with "linux16" rd.break console=tty1 3 - use ctrl+x to bootup - mount -o remount,rw /sysroot 4 - chroot /sysroot 5 - passwd (enter new password). 6 - touch ./autorelabel 7 - ctrl+d twice to resume normal boot process.

If you use the syntax above (touch ./autorelabel (dot forward-slash)), the result is to create a file called autorelabel in the current directory. The result will NOT be a relabel function and a system you may not be able to log in to.

That should be "touch /.autorelabel" (forward-slash dot instead of dot forward-slash). Notice the position of the period in front of the autorelabel filename. The result is to create a file called .autorelabel in the root directory. The result will be a relabel function and a system you can log in to.

I have made that mistake!

// Bill //

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.