Lost your root password? Well, this is very unfortunate! This tutorial will show you how to reset ESXi root password.
You need a Linux Live or Rescue CD to perform this action. You can use RHEL/CentOS using the rescue mode, SysRescue CD, Knoppix or your favorite portable Linux distro.
1. Boot on your Live CD
2. Create two temp folders under /mnt :
1
2
|
mkdir/mnt/sda5
mkdir/mnt/sda6
|
3. Mount the dual root ESXi system partitions into the folders you just created :
1
2
|
mount/dev/sda5/mnt/sda5
mount/dev/sda6/mnt/sda6
|
Now, move in the first volume (sda5) :
1
|
cd/mnt/sda5
|
4. Create a safety copy first of the file you are about to edit :
1
|
cp-pstate.tgzstate.tgz.bak
|
5. Untar state.tgz archive :
1
|
tar xzf state.tgz
|
(This will extract local.tgz)
6. Untar local.tgz archive :
1
|
tar xzf local.tgz
|
(This will extract ‘etc’ folder. You might get some outputs during the extraction about permissions, it’s safe to ignore.)
7. Edit ‘shadow’ file (this is the file where the user passwords are stored, encrypted of course) :
1
|
vietc/shadow
|
8. At the top line, you should see “root:” followed with alpha numeric characters, which is the encrypted password. Simply erase everything after ” : ” and enter the following :
1
|
$1$1wX62qTk$dgXJsh1PRKZnWyx6aDx3..:15831:0:99999:7:::
|
This line will set the password to “recoverypassword”. You can also create your own by creating a new user on your rescue CD and paste the generated password.
9. Save and exit. Then repack the ‘etc’ folder :
1
|
tar czf local.tgzetc
|
And repack to ‘state.tgz’ :
1
|
tar czf state.tgzlocal.tgz
|
10. Go back to ‘/mnt’ location and unmount the ‘sda5′ filesystem :
1
2
|
cd../
umount/mnt/sda5
|
11. Repeat the exact same steps for ‘sda6′, then reboot.