So, you renamed a virtual machine in vSphere, and now the containing folder and associated VM files don’t match the new name of the virtual machine. Can that be changed?
Yes – vSphere makes that task very easy utilizing Storage vMotion.
First off, be sure to reference this KB for all the information needed: Renaming a virtual machine and its files in VMware ESXi (1029513)
I’ll call it out…this feature/function has been out for some time. I believe it was available in the 5.0u2 version of vSphere back in 2012, according to Duncan in his post (Dec 21st, 2012) here: Renaming virtual machine files using SvMotion back in 5.0 U2 | Yellow Bricks (yellow-bricks.com)
I feel that there’s some need to remind Admins and Engineers out there that this function is still out there – plus it’s an easy win for a task that used to be tedious.
Let’s try it in the lab, shall we?
For testing purposes, I deployed a PhotonOS (OVA) and I called it…ahem….”PhotonOS”
Very creative…I know 🙂
From here take a look at the datastore the VM is on, and notice the VM folder, including all associated VM files are also called “PhotonOS” + the appropriate VMW file extension
Now let’s rename the VM.
For all intents and purposes, let’s say we are going to turn this VM into a template and put it into our Content Library and publish out to other vCenters.
Right-click the VM and rename it to “Photon-TEMPLATE”
Note the VM name has changed in the inventory view
However, in the datastore view the VM folder and files have not changed and still reflect the original name of the VM:
From the KB and info above, we know that the folder and files will change after a Storage vMotion (a.k.a. SvMotion).
Let’s illustrate it!
From here all I need to do is migrate the VM – this can be done live or with the VM off.
I’m going to select a storage vMotion only – although note, there is an option to change both compute (vMotion) and storage (SvMotion) resources if preferred
I’m choosing a simple SvMotion to another local 4TB disk, although I could choose any of the available VMFS volumes
Click Finish to Start the SvMotion 🙂
When complete we’ll look at the datastore
All complete! Looking at the datastore we now see the VM folder and associated files are now named “Photon-TEMPLATE”, which matches the current name of the Virtual Machine
And that’s it, example complete! Hope that helped some others out there – if so please leave a comment below and subscribe to the blog for more!