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 π
![](https://i0.wp.com/mikewire.com/wp-content/uploads/2023/07/image.png?resize=302%2C176&ssl=1)
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
![](https://i0.wp.com/mikewire.com/wp-content/uploads/2023/07/image-1.png?resize=1038%2C302&ssl=1)
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”
![](https://i0.wp.com/mikewire.com/wp-content/uploads/2023/07/image-2.png?resize=543%2C213&ssl=1)
Note the VM name has changed in the inventory view
![](https://i0.wp.com/mikewire.com/wp-content/uploads/2023/07/image-3.png?resize=252%2C117&ssl=1)
However, in the datastore view the VM folder and files have not changed and still reflect the original name of the VM:
![](https://i0.wp.com/mikewire.com/wp-content/uploads/2023/07/image-4.png?resize=820%2C426&ssl=1)
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.
![](https://i0.wp.com/mikewire.com/wp-content/uploads/2023/07/image-5.png?resize=488%2C260&ssl=1)
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
![](https://i0.wp.com/mikewire.com/wp-content/uploads/2023/07/image-6.png?resize=755%2C339&ssl=1)
I’m choosing a simple SvMotion to another local 4TB disk, although I could choose any of the available VMFS volumes
![](https://i0.wp.com/mikewire.com/wp-content/uploads/2023/07/image-7.png?resize=1024%2C382&ssl=1)
Click Finish to Start the SvMotion π
![](https://i0.wp.com/mikewire.com/wp-content/uploads/2023/07/image-8.png?resize=936%2C236&ssl=1)
![](https://i0.wp.com/mikewire.com/wp-content/uploads/2023/07/image-9.png?resize=805%2C125&ssl=1)
When complete we’ll look at the datastore
![](https://i0.wp.com/mikewire.com/wp-content/uploads/2023/07/image-10.png?resize=811%2C114&ssl=1)
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
![](https://i0.wp.com/mikewire.com/wp-content/uploads/2023/07/image-12.png?resize=266%2C100&ssl=1)
![](https://i0.wp.com/mikewire.com/wp-content/uploads/2023/07/image-13.png?resize=1046%2C335&ssl=1)
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!
Leave a Reply