Reloading a vmx File Without Remove That From vCenter Inevntory
I’m working on a solution that it needs to edit something on virtual machine vmx file. But as you know, vmx file should be removed and re-add from vCenter inventory for apply new configurations.
This process is very simple but you have to find your virtual machine datastore and remove the virtual machine from inventory and re-add that again.
There is a way for reloading your vmx file without do the above process from ESX/ESXi command line (Tech Support Mode).
To reload the virtual machine configuration .vmx
file on an ESXi/ESX host from the command line:
- Log in to the Local Tech Support Mode console of the ESXi/ESX host.
- Obtain the Inventory ID (
Vmid
) for the virtual machine by running the command:# vim-cmd vmsvc/getallvms
The output shows virtual machines which are registered on the ESXi/ESX host.Example output:
Vmid Name File Guest OS Version Annotation
2848 Win2003_storage_performance [local] Win .vmx winNetEnterpriseGuest vmx-07 To be used as a templateIn this example, the
Vmid
is2848
. - Reload the virtual machine configuration
.vmx
file by running the command:# vim-cmd vmsvc/reload Vmid
To reload configuration files of all the virtual machines on the ESXi/ESX host using a script, run this command:Update:
Below command will not work.
for a in $(vim-cmd vmsvc/getallvms 2>&1 |grep invalid |awk ‘{print $4}’|cut -d \’ -f2);do vim-cmd vmsvc/reload $a;
Use this:
for $a in $(vim-cmd vmsvc/getallvms 2>&1 | grep invalid |awk ‘{print $4}’|cut -d \’ -f2); do vim-cmd vmsvc/reload $a;
Thanks Sohrab Kasraeian for correction.
Reference: VMware KB1026043