VMware Cloud Community
soleblazer
Hot Shot
Hot Shot

Change a directory name on ESX

Hi all. I have a vm that I scp'd while it was down to another VMware server. Problem is, how do I change the directory name to reflect the new name I want? When I change the name of the directory manually, the vmx file still has all the references to the original directory. Is there a way to do this automatically?

Example:

/volumename/server_name

I want to change it to /volumename/newserver_name

Thanks!

Reply
0 Kudos
8 Replies
Texiwill
Leadership
Leadership

Hello,

There is a VM copy command floating around the forums that will do this for you. The only way to really do it, is to edit the files by hand or via a script to change the names appropriately within the configuration and metadata files.


Best regards,

Edward L. Haletky

VMware Communities User Moderator

====

Author of the book 'VMWare ESX Server in the Enterprise: Planning and Securing Virtualization Servers', Copyright 2008 Pearson Education.

CIO Virtualization Blog: http://www.cio.com/blog/index/topic/168354

As well as the Virtualization Wiki at http://www.astroarch.com/wiki/index.php/Virtualization

--
Edward L. Haletky
vExpert XIV: 2009-2023,
VMTN Community Moderator
vSphere Upgrade Saga: https://www.astroarch.com/blogs
GitHub Repo: https://github.com/Texiwill
Reply
0 Kudos
Mr_Flibble1
Enthusiast
Enthusiast

Try this thread:

http://communities.vmware.com/message/822788;jsessionid=F44C51342768E9B02B25A12A26A4571D

I found that creating a new vm with the name, and pulling in the disk from the old VM works.

Mr_Flibble1
Enthusiast
Enthusiast

Note, to crawl through things on the command line to perform a rename you can use the following:

find ./ -type f -exec sed -i 's/vmname/newvmname/' {} \;

I have used this command often in Linux, (great for fixing oracle hostnames etc.) I honestly have never tried it on a VM, but the concept should work.

Reply
0 Kudos
IRIX201110141
Champion
Champion

Renaming the directory on the shell with the standard unix commands isnt the preferred way and also messing around in the vmx is also not bullet proof.

  1. Remove the VM from your inventory

  2. Use the Datastore browser to rename the directory

  3. If you would like to change the name of the vmdks too you have to use vmkfstools-i old-name.vmdk new-name.vmdk on the shell

  4. Import the VM by right- clicking on the vmx file and choose your new name

  5. Remove the old disk and add a new one which points to the existing vmdk

Most of the tasks can be scripted i think.

Note: Renaming a VM with VI Client in VC does only change the display name and not the directory in the Filesystem.

regards

Joerg

Reply
0 Kudos
VTorque
Contributor
Contributor

Another option is to Clone the VM to the new name.

This will make a copy, and change the directory and filenames for you.

Once completed, delete the source VM and you're done.

Reply
0 Kudos
scott28tt
VMware Employee
VMware Employee

I think you can do this another way, rename the VM in the VI Client, then cold migrate it to a new datastore. This may also work with Storage VMotion rather than the cold migration.

Scott.


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
Jasemccarty
Immortal
Immortal

Here's an easy way to do it.

  1. Rename the VM something totally different.

  2. Migrate it to another Host.

  3. Change the name to what you want it

  4. Migrate it back to the original Host.

As long as you've never had a VM with that name/directory name on that Host, it will name it to the name of the VM.

Jase McCarty

http://www.jasemccarty.com

Jase McCarty - @jasemccarty
Reply
0 Kudos
soleblazer
Hot Shot
Hot Shot

Thanks all.

I ended up just copying the .vmdk and -flate vmdk files to a directory on the server and then created a new vm with no hard disk, copied the files into the shell directory and then added the hard disk. This seems to work pretty good. The only reason I'm not using templates is bc the VC server is not setup yet and I'm under the gun to get 5 or 6 vm's done.

Thanks all.

-JC

Reply
0 Kudos