How to rename a VMWare ESXi 5 VM physically?
Solution 1
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.
/vmfs/volumes/0170cf28-62cf5d0c/zimbra # ls -al
drwxrwxrwx 1 -2 -2 15 Sep 25 2011 .
drwxr-xr-x 1 root root 11 Aug 8 15:23 ..
-rw-rw-rw- 1 -2 -2 72171 Sep 25 2011 vmware.log
-rw------- 1 -2 -2 77309411328 Sep 25 2011 zimbra-flat.vmdk
-rw------- 1 -2 -2 8684 Sep 25 2011 zimbra.nvram
-rw------- 1 -2 -2 543 Sep 25 2011 zimbra.vmdk
-rw-r--r-- 1 -2 -2 0 Sep 25 2011 zimbra.vmsd
-rwxr-xr-x 1 -2 -2 2955 May 2 09:35 zimbra.vmx
-rw-r--r-- 1 -2 -2 261 Jul 19 22:51 zimbra.vmxf
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.
# Extent description
RW 150994944 VMFS "zimbra-flat.vmdk"
Change the name to reference the new name. Save the file.
That's it...
Solution 2
you need to migrate the vm to a different datastore, after you renamed the vm.
Gargaroz
Updated on September 18, 2022Comments
-
Gargaroz over 1 year
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?
-
MDMarra over 11 yearsPlease don't tag a question with every single tag you can find. [vmware-server] is an entirely different product.
-
-
Gargaroz over 11 yearsHow? The only way to migrate I actually know and use is to copy the files. Do you mean to export-import an OVF file?
-
joeqwerty over 11 years+1. I was going to post this exact answer but didn't have the energy.
-
joeqwerty over 11 yearsIf you migrate the VM from one host to another, ESX will rename the corresponding files, folders and configuration information.
-
Aaron Copley over 11 yearsThat's awesome to know.
-
johnshen64 over 11 yearsto move to a different datastore, yes, you can do export or import, or install a temporary vcenter server (eval, if you don't have one already) which will then have an option to migrate storage. there are other ways as well, but whenever the datastore of the vm is changed, the files will all be named correctly, however you do it.
-
Simon Catlin over 11 yearsVote++. Storage vMotion the VM to another datastore and back again. Directory names and VMDKs renamed. Simples.
-
ewwhite over 11 yearsThis looks and sounds like a single-instance VMWare setup with no SAN. In practice, the name of the VM's folder shouldn't matter, leaving the naming focus on the vSphere Client interface. Assuming that the OP doesn't have a SAN or vCenter, manually renaming the files is the right approach.
-
Gargaroz over 11 yearsDone it. Now, when I try to turn the VM on, it says it can't find MyVM-000002.vmdk file (which is in place actually).
-
Gargaroz over 11 yearsThen I've changed everything back and it began to work ok. I've then done the renaming by copyint the VM with VMware vCenter Converter Standalone Client.