There are a couple of ways to rename a Virtual Machine, but there are two in my opinion that stand out:
- Shutdown the VM
- Rename the VM in VirtualCenter
- Migrate the VM and move it to another Datastore
- done!
And from the service console:
- vmware-cmd -s unregister /vmfs/volumes/datastore/vm/vmold.vmx
- mv /vmfs/volumes/datastore/vm-old /vmfs/volumes/datastore/vm-new
- cd /vmfs/volumes/datastore/vm-new
- vmkfstools -E vm-old.vmdk vm-new.vmdk
- find . -name ‘*.vmx*’ -print -exec sed -e ‘s/vm-old/vm-new/g’ {} \;
- mv vm-old.vmx vm-new.vmx
for every file that hasn’t been renamed (.vmsd etc.)- vmware-cmd -s register /vmfs/volumes/datastore/vm-new/vm-new.vmx
- done!
Thxs I thought I was going to have to do the cmd line because The app owner changed the name. I didn’t realize moving the VM to a different datastore would take care of this. Thanks
-Richard Powers
Hi Duncan,
thanks for the concise summary. Two things for those without Storage vMotion who need to go down to the SC. Step 5 should read ‘sed -i -e’ to actually replace the *.vmx* file contents inplace (-i) and might be abbreviated to
sed -i -e ’s/vm-old/vm-new/g’ *.vmx*
Further, the renaming for step 6 can be automated a bit to speed it up and make it less error-prone. At least for ESX3.5/ESX4.0 where the ‘rename’ utility is present (just checked), older platforms might not have it.
shopt -s nullglob
OLD=vm-old
NEW=vm-new
rename $OLD $NEW $OLD.{???,????,?????}
Renames all $OLD files which have extensions ranging from 3 to 5 chars (.vmx, .vmsd, .vmxe, .vmxf, .nvram,. ..).
HTH
Sebastian
I need to rename a live w2k8 vm server both in windows and vcenter.
I do not have a lot of space left in my data stores so option one seems out of reach.
In considering option 2, is it a must to rename the VM files? What happens if I do not rename the vm files but only rename the vm by right clicking on it and selecting rename. I need to do this in the next 45 minutes please!
it is not a must, but it might make troubleshooting more difficult when you don’t,
This “feature” no longer works in vSphere 5. The destination directory name is changed but the vm files do not. Is there a variable that can be set to turn it back on?
Agreed, the svMotion way does not rename the files of the VM anymore in vSphere 5. I have been rooting around in the advanced options to see if anything pops out, but I haven’t seen it.
Do you know of a way to turn this back on?
I’ve had this question floating around the communities for better than week and I only had one response there and your comment here. Considering the seemingly hundreds of blogs that talked about this feature when it came out, I’m surprised it has so little attention now that it is gone.
I’ll keep digging.
gb
i will ask the engineer today 🙂
Thank you.
gb
Any word from the engineer?
Yes I spoke with him about it this morning over breakfast. They changed the behavior due to an issue with disk numbering. I am going to creat a feature request for this to see if we can get is back in.
Thank you.
Hoping to see this in an upcoming update; I was racking my brain trying to figure out why this wasn’t working for me.
Any Information about this in ESXi 5.0?
as stated 3 comments above this is a known issue in 5.0 and I have requested that his behavior is returned to “normal”. cannot comment on when,
Does anybody know if this has been fixed in vsphere 5.0 update 1?
Nope, still the same problem with the latest release. Figured this would have been fixed, but no joy!
I have successfully renamed the VM in ESXi 5.0 using CLI. The following URL will help me a lot.
http://esx-guy.blogspot.com/2012/05/how-to-rename-virtual-machine-with-cli.html
Thanks,
Kandan.
This method worked before as well, but when they made it auto-magically work through Storage VMotion, it was a welcome addition. In my environment, it is next to impossible to bring a machine down for any reason unless absolutely necessary. Hoping they’ll “re-introduce” this much needed feature.
What if this is the scenario:
I have a server named test that has 3 drives.
drive 1 in store1 – test.vmdk
drive 2 in store1 – test_1.vmdk
drive 3 in store2 – test.vmdk
I want to storage vmotion drives 1 and 2 into the newer datastore “store2”. The storage vmotion screen says validation succeeded, I haven’t hit finish yet, but if this renaming feature doesn’t work in 5 will there be a file name conflict after the storage vmotion with the two test.vmdk’s or will it rename the vmdk on the fly?
Can we rename a vm in the ESX using python script??
If yes, Can you please suggest me , how it can be done
Thanks,
Sasikiran
Please provide me the apis for it, and one more question. Can we able to get the uuid for the vm through the esx apis using python
Hi Duncan,
Do you think using Converter (to perform a V2V) would be a viable option as well?
It would take longer than the command line approach (by manually renaming the files) but may be easier for those not inclined to use the CLI.
cheers,
gm
One to avoid CLI, I usually just clone the oldname VM with the new name and boot up the clone. Seems to work well providing you have the extra space and the time to allow the clone. Server 2008 R2 is so resilient I’ve often done the clone while the source server was running to keep keep the added uptime. Probably not the prettiest solution, but until they bring back the storage vMotion solution it works for me.
Can we rename the VM in Vcenter when the VM power on?