Does it bug you when the registered names of your VM do not match the folder and file names on the datastore? It can be difficult to identify VMs when browsing the datastore if the folder and file names do not match the VM name. Or maybe the VM names generally match what’s on the datastore but there are some case sensitivity discrepancies. I for one an uncomfortable with these situations. While fixing the problem by bringing the datastore folder/file names into alignment with the VM name isn’t impossible, the process is painful when done manually and requires an outage of the VM.
Here’s a simple trick I’m sure many may already be aware of. I remember hearing about it quite a while ago (I don’t remember where) but had forgotten about it until today. Let VMware Storage VMotion take care of the problem for you. During the Storage VMotion process, the destination folder/file names are synchronized with the name of the VM on the fly with no outage.
For example, let’s say we create a VM with a registered name of “old_name”. The datastore backing folder has the name of “old_name” and the files inside are also prefixed with “old_name”.vmdk, .vmx, etc.
Now we go ahead and change the name of the VM to “new_name” in vCenter. The datastore backing folder and files still have the “old_name” and now obviously don’t match the registered VM name.
To bring the datastore backing folder and file names back in synchronization with the registered VM, we can perform a Storage VMotion. In doing so, the backing folder and files will be dynamically renamed as they land on the new datastore. In this case, they will be renamed to “new_name”.
This solution is a heck of a lot easier than powering down the VM and renaming all the files, as well as modifying the corresponding metadata in some of the files.
Update 9/27/11: As reported by Gary below and validated in my lab, this trick no longer works in vSphere 5.0 with respect to file names within the folder. As an example, after renaming the VM in vCenter inventory and then subsequently Storage vMotioning the VM, the destination folder name will match the VM however the .vmx and .vmdk files inside will not. This is unfortunate as I have used this trick method many times.




