sysrootdirectory with read & write access and change the root password on RHEL 8 / CentOS 8 by using the
passwdcommand to set the new root password.
In this tutorial you will learn:
- How to perform a break at an early stage of the boot process.
- How to remount root partition with read/write access.
- How to change root password.
- How to force filesystem relabeling.
Software Requirements and Conventions Used
|Category||Requirements, Conventions or Software Version Used|
|System||RHEL 8 / CentOS 8|
|Other||Privileged access to your Linux system as root or via the |
|Conventions|| # - requires given linux commands to be executed with root privileges either directly as a root user or by use of |
How to recover RHEL 8 / CentOS 8 root password step by step instructions
- Boot to the GRUB menu and enter the edit mode. Use your arrows to navigate to the the menu item you would normally boot your RHEL 8 Linux system from. Press
eto start editing the selected menu item.
- Perform a break at an early stage of the boot process by typing
rd.breakat the end of the line starting with
kernel=. Once ready press
CTRL+Xto start the RHEL 8 boot process.
- Check write access on the
/sysrootmount point. By default this mount point is mounted only with the read-only (ro) access. Execute:
switch_root:/# mount | grep sysroot
- Remount the
sysrootdirectory with read & write access. To do so execute:
switch_root:/# mount -o remount,rw /sysroot/ switch_root:/# mount | grep sysroot
- Enter chroot system by executing:
switch_root:/# chroot /sysroot
- Use the
passwdcommand to set a new root password. Please note that when typing a new password the characters you type will not be visible. Simply keep typing.
- Force file-system relabeling by executing the following command:
# touch /.autorelabel
- Exit the
chrootsystem by executing the
- Logout to continue the normal boot:
- Wait for the file-system relabeling to complete. Depending on your system speed and number of files this might take some time. Be patient.
- Login with your new root password.