2013年5月1日 星期三

Reset root password on an ESXi 4.1 host

According to VMware KB http://kb.vmware.com/kb/1317898, root password cannot be reset without re-install.  Below is the a trick to reset the root password on an ESXi 4.1 without re-install.

  1. Boot the ESXi host with a Linux boot-able media (e.g. DVD)
  2. Mount the ESXi host partition containing the system data
    • mkdir -p /tmp/mnt
    • mount /dev/sda5 /tmp/mnt
  3. Extract the shadow file of the ESXi installation and reset password
    • mkdir -p /tmp/workdir
    • cd /tmp/mnt
    • cp state.tgz /tmp/workdir
    • zcat state.tgz | tar xvf -
    • zcat local.tgz | tar xvf -
    • cd etc
    • vi shadow "Reset the root password"
    • cd ..
    • tar zcvf local.tgz etc
    • tar zcvf state.tgz local.tgz
    • cp state.tgz /tmp/mnt
    • sync; sync; sync
    • umount /tmp/mnt 
  4. Reboot the box