When I create a VM on a VMWare ESXi 5 server naming it "MyVM" then "MyVM" directory is created on a data store and files like "MyVM.vmx", "MyVM.vmdk" etc. in it.
I've renamed the VM and would like all the files to be renamed to follow the change. How to achieve this?
Best Answer
This is possible, but not really necessary. You should only care about the virtual machine's name as displayed in the vSphere console.
Suppose your datastore's name is "datastore1" and the VM is named "zimbra". You wish to change its name to "mail". From the ssh console, you can descend into
/vmfs/volumes/datastore1
directory, then the virtual machine's directory.You can rename each of the files with the
mv
command. For instance,mv zimbra.vmx mail.vmx
will rename that specific file. Repeat for all of the files.Once the files are renamed, you'll need to edit the virtual machine's configuration file (.vmx) and the disk descriptor file (.vmdk).
vi zimbra.vmx
- From there, you can manually replace the instances of the old name with the new, or run a search-replace (%s/zimbra/mail/g
).Save the .vmx file. For each .vmdk file, look for the "Extent description" line, e.g.
Change the name to reference the new name. Save the file.
That's it...