Thursday, September 27, 2012

Rename Virtual Machine After Creating VMware vSphere

Renaming virtual Machine inventory name is much easier, just right click and rename. But in the datastore all the folder and files related to that VM keep the old name, means if you have VM with inventory name “VM001” then in the datastore this will create the folder “VM001” and within that folder all the files also start with same name like see the diagram below

Then suppose you rename the VM in the inventory VM001à db-srv-del-01 after this you can see that in the inventory you have new name but in the datastore folder and files still keep the old name. See the screen shot below:-

So if you want to apply the new name to all the files and folder related to that VM, you need to shutdown the VM and then remove from inventory and then manually rename all the files and folder with new name and then add back to inventory. For details on that see below:-

       Shutdown the VM and then remove from inventory.
      After that connect to the console of esxi/esx server and then change directory to datastore where that VM is located. Like in my example that VM is located in datastore Private02 and the folder name is VM001. I just enabled SSH in my esxi server and then connect using the Putty to esxi host. So that I can reach those files, perform the steps as in the screenshot :-

After renaming the folder, you need to rename all the files also, so do the steps as in screenshot:-

Once all the related files are renamed with new name, after that you need to modify the vmx file to point to the new name of vmdk, so edit vmx file with any editor, I used in this case vi and then rename the .vmdk name to new name .vmdk and save the file and exit.


After this you also need to update the .vmdk fiel to point to new –flat.vmdk.   so you need to edit the vmname.vmdk file with vi editor (or any editor you feel comfortable), and modify the name of –flate.vmdk to new name –flat.vmdk after this save and exit.


Once all this done now your VM is ready with new name, now you can go back to vSphere client and browse your datastore and then locate the VM name folder and then locate .vmx file and add back to inventory. Once added to inventory you can power on the VM and now all files and folder related to that VM have new name.

1 comment:

Unknown said...

Thank you very much Sir.