Recover root password or failed mount
Guide to recover root password or failed mount on a Centos 7 instance
Overview
If you need to set the root password on a Centos 7 instance or fix a faulty /etc/fstab for example, then this is the procedure to access the boot disk without a root password.
Modify boot parameters
-
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
-
Remove all parameters starting with “console=”
-
Press Ctrl+x to boot
Set password
- Remount the root filesystem read write.
$ mount -o remount,rw /sysroot
-
You can now edit the root disk files under /sysroot.
-
To set a new password do a change root and set password.
$ chroot /sysroot
$ passwd
- Exit both shells and the instance will reboot.
$ exit
Last modified April 18, 2024: doc(mail-relay): elastx dkim signing (#168) (eda521a)