Sunday, January 25, 2015

Reset The Root Password For A Linux VM Hosted On XenServer

http://www.unixmen.com/reset-root-password-linux-vm-hosted-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
boot

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.
boot-option

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

Or,

Shutdown from Xencenter controls.

password

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.

2 comments:

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

    thnx

    ReplyDelete
  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.

    ReplyDelete