Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
Please don't tag a question with every single tag you can find. [vmware-server] is an entirely different product. –  MDMarra Aug 21 '12 at 18:18
Thanks. Didn't know. –  Ivan Aug 21 '12 at 18:19
add comment

2 Answers

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...

share|improve this answer
+1. I was going to post this exact answer but didn't have the energy. –  joeqwerty Aug 21 '12 at 18:33
Done 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). –  Ivan Aug 22 '12 at 8:37
Then 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. –  Ivan Aug 22 '12 at 10:59
add comment

you need to migrate the vm to a different datastore, after you renamed the vm.

share|improve this answer
How? The only way to migrate I actually know and use is to copy the files. Do you mean to export-import an OVF file? –  Ivan Aug 21 '12 at 18:18
If you migrate the VM from one host to another, ESX will rename the corresponding files, folders and configuration information. –  joeqwerty Aug 21 '12 at 18:35
That's awesome to know. –  Aaron Copley Aug 21 '12 at 18:41
to 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. –  johnshen64 Aug 21 '12 at 19:09
Vote++. Storage vMotion the VM to another datastore and back again. Directory names and VMDKs renamed. Simples. –  Simon Catlin Aug 21 '12 at 21:43
show 1 more comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.