We moved this page to our Documentation Portal. You can find the latest updates here. |
Question
How can I manually reset the root password on my Linux VM in recovery?
Environment
OnApp All Versions
Linux VMs
Answer
- Reboot in recovery.
- Login via recovery with user/password being root/recovery or root/defaultrootpassword <-- could be either one, depends on if it was able to set it to the default one or not. If recovery does not work, try the default root password listed in the properties of the virtual machine.
-
fdisk -l
To check for the disk that has the same size as the one this VM has. ex: 50GB, you'll probably see 49.something GB here, but that's the one. Normally it's /dev/vda or /dev/xvda (depends on the distribution). It will also show the partitions, and it will more than likely be the /dev/vda1 partition. - Mount that disk. For example, you can create a directory under /mnt for this:
mkdir /mnt/vda1
and then mount it like this:mount /dev/vda1 /mnt/vda1
- To make that environment usable, bind /proc, /sys, and /dev to that environment:
mount --bind /proc /mnt/vda1/proc
mount --bind /sys /mnt/vda1/sys
mount --bind /dev /mnt/vda1/dev - Now 'change root' to that environment:
chroot /mnt/vda1
- If you check your
pwd
(present working directory), you'll have / because you're in the root of this environment now. Double check you're still root withwhoami
and then you can runpasswd
and update the password for the root user. It will not ask for the current password. - Use
exit
to leave the environment and go back to the recovery image. Unmount binds and diskcd /
The command cd is there as a reminder to make sure you're not in the directory you're unmounting or it won't unmount.
umount /mnt/vda1/proc
umount /mnt/vda1/dev
umount /mnt/vda1/sys
umount /mnt/vda1 - Restart the machine and it should allow you in with the password you've set it to.