Align Datastore Names With VM Names Using Storage vMotion

September 30th, 2009 by jason Leave a reply »

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.

Update 11/7/12: Over a year later, vSphere 5.1 is shipping and this feature is still disabled.  VMware KB Article 2008877 has not been updated since the launch of vSphere 5.1 If I were a customer, I’d be upset.  As an avid user of the product, I’m upset as much about the carelessness and complacency of VMware as I am about the disabling of the feature.

Update 12/21/12: Duncan Epping reports Storage vMotion file renaming is back in vSphere 5.0 Update 2.  Read more about that here.  This is a wonderful birthday present for me.

Update 1/25/13: Duncan Epping further clarifies that Storage vMotion file renaming in vSphere 5.0 Update 2 requires an addition to the advanced setting in vCenter (Add the key “provisioning.relocate.enableRename” with value “true” and click “add”).  Read more about that here.  Duncan further hints that Storage vMotion file renaming may be coming to vSphere 5.1 Update 1.  No promises of course and this is all just speculation.

Update 4/30/13: Duncan’s prophecy came to realization late last week when VMware released vSphere 5.1 Update 1 which restores Storage vMotion file renaming.  As pointed out by Cormac here and similar to the update above, an advanced setting in vCenter is required (Add the key “provisioning.relocate.enableRename” with value “true” and click “add”).

Advertisement

10 comments

  1. rbrambley says:

    Wow. So simple and obvious it is easily missed. Thanks for pointing it out.

    Haven’t tried it, but I wonder if SVMotion lets you select the same datastore the VM already lives on and accomplish renames without actually leaving the LUN? Wishful thinking?

  2. I would like to request for the 12th time the integration of VM re-alignment with storage vMotion (otherwise we need to take the VM down for O(vm.size)

    Please open the APIs and or put the storage to do it!

  3. Matt says:

    Nice one. I didn’t know about this one, good trick!

    Thanks Jason..

  4. Josh A says:

    Thanks for the post Jason. I have been doing a large number of storage migrations between SANs and absolutely wearing out Storage vMotion. I posted a still unanswered question on the community forums about how some of the VMs have remnant files left in the old directories and some do not. I wonder if this is a result of the renaming quality you’ve mentioned in this post since moving forward we are more properly naming our datastores. Any thoughts from you or others on this?

    Community Question
    http://communities.vmware.com/thread/235579?tstart=0

  5. Gary boy says:

    VSphere 5 renames the destination directory to match the display name but the files within the directory do not change. Any other options you are aware of short of the manual method/scripting?

  6. Gary says:

    This trick doesn’t work with vSphere 5. The destination folder is renamed but the vm files are not. Is there an option available to turn this feature on and off?

  7. jason says:

    Indeed, this trick no longer works for the file names in vSphere 5.0. Major bummer as I’ve used this technique often.

  8. Xander says:

    A customer of mine has the same problem with esxi 4.1 update 1. Directory name and .vmx files are renamed but vmdk not.

  9. jason says:

    Those interested in this feature and subscribed to these comments, there have been some developments. Be sure to read the updates in the post.

  10. Craig says:

    5.1 doesn’t allow renaming even with the workaround that was published for 5.0 update 2. Bummer…

Leave a Reply