Sunday, January 25, 2015

Reset The Root Password For A Linux VM Hosted On XenServer

If you have ever tried to reset the root password for a linux VM hosted on XenServer, this section will guide you how to make that.

Follow the procedure to reset the root password of a Linux VM:

You need to to boot your virtual machine in single user mode.

1- Shut down your server using the Xencenter controls

2- Right click on machine and select Properties

3- Go under Boot options 
You already have something in the OS Boot Parameters you will need to take note of this as You will need to save it and put it back once the password reset is complete.

Change the OS Boot Parameters to rw init=/bin/bash 

Some times for some OS especial CentOS  you will need to write in the field the word single instead of rw init=/bin/bash  so try both if first trick didn’t work.

4- Save and Start your virtual machine
Your system will  boot up in single user mode. So to change your password, you need to type this command:
 bash# passwd root

5- Type in your new password you will then be asked to confirm it
Your password has now been reset.

 6- Shutdown your virtual machine.
bash# shutdown -h now


Shutdown from Xencenter controls.


Now go back to the xencenter and startup options and remove rw init=/bin/bash and change it back to whatever was there before. Start up your server and you should be able to logon with your new root password.


  1. is there a way to achieve this without rebooting the vm?


  2. sure. skip the reboot part and the kernel parameter one and continue from the passwd command instead but this way you should have the old password handy. The article implicitly assumed that you need to reset the root password in case you forgot it.