VMware Cloud Community
elijah1
Contributor
Contributor

Renaming Virtual Macine

My inderstanding is that if I rename the VM then it doesn't rename the directory allocated for that machine on the datastore (where all the files pertinent to this machine are kept). I just started working for the company and when I look at the VM I don't see machine that corrsponds to datastore directory.

Is there a way to figure out of this is the orphaned directory that can be removed from datastore or there is actually a VM using it?

Thanks.

Elijah.

0 Kudos
8 Replies
ChicaneUK
Enthusiast
Enthusiast

Assuming the VMDK files are living in the same directory, one way would be to get the properties of the VM up, then check the properties of the Virtual Disk and see if the Disk File path corresponds to the expected location...

Alternatively, from the Service Console, do a "ps ax | grep VMNAME" (e.g. ps ax | grep PROD-DB) - this will show you the instance for the Virtual Machine you're looking for and will show the full path to which VMX file it's registered from..

lamw
Community Manager
Community Manager

That's correct, if you want a full rename you would need to power the system off and rename all files including entries in the .vmx file OR if you have vCenter and sVMotion license, you can svMotion the VM and it'll rename the entire directory structure for you.

Regarding orphaned, I thought someone wrote a PowerCLI script to detect this but I don't recall, let me search around.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
elijah1
Contributor
Contributor

: "OR if you have vCenter and sVMotion license, you can svMotion the VM and it'll rename the entire directory structure for you"

--- Yes we recentlky instyalled VMotion liocense, but I'm not relll\y fluent with VMotion yet, so I cannot propely decode what you were saying Smiley Happy Cna you be ab it more specifis as to how you do that?

Thanks.

Elijah.

0 Kudos
lamw
Community Manager
Community Manager

It's not a vMotion but a Storage vMotion, this allows you to live migrate a VM's VMDK(s) from one datastore to another, where as vMotion migrates a VM from one host to another.

If you have the capability and sufficient storage space, then you can rename the VM and then migrate the VM. It's pretty much a point/click if you have vSphere, but if you're running on VI 3.5, it's manual or you can use the CLI

If you let us know the version of vCenter and if you have a Storage vMotion license, we can provide further details else it'll be a manual process

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
elijah1
Contributor
Contributor

I've attached lic info in the file.

Thanks.

0 Kudos
lamw
Community Manager
Community Manager

Yes, you're on vSphere 4.0 and you do have vCenter 4.0 along with Storage vMotion license. You're actually licensed with the highest version available, so all features are available to you.

Here is a quick overview of Storage vMotion - http://www.vmware.com/products/storage-vmotion/

Make sure you have two datastore and the 2nd one has sufficent space for your VM, as it'll be moving it's disk contents. So if you have a VM that's 20GB, make sure the destination has at least 20GB. Right click on the VM and click "Migrate", you'll have few options, one of which is to Change Datastore, select one that has free space and this may take some time depending on your disks and how big your VM is. Once that is completed, the VM has now been fully renamed both the displayName + the actual files. Now you would then move the VM back, unless you have no reason to move it back. You would do the reverse and now your VM will be fully renamed.

The other option is to power the VM off and rename it manually which can lead to errors if you miss-name the wrong files/etc. The first method is the recommendation.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
msemon1
Expert
Expert

Easy way to rename VM. Go into Virtual Center and right click VM and choose rename and type in the new name. Next, right click on VM and choose migrate. Choose change datastore. This will rename configuration files when it moves VM to new datastore. Done.

Mike

0 Kudos
elijah1
Contributor
Contributor

Thanks for your help guys.

0 Kudos