Loading

×Sorry to interrupt
CSS Error

Refresh

Cookie Preference Center

General Information on cookies

When you visit our website, we use cookies to ensure that we give you the best experience. This information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies by clicking on the different category headings to find out more and change your settings. However, blocking some types of cookies may impact your experience on the site and the services we are able to offer. Further information can be found in our

Cookie Policy.

Strictly Necessary

Strictly Necessary

Always Active

Strictly Necessary

Strictly necessary cookies are always enabled since they are essential for our website to function. They enable core functionality such as security, network management, and website accessibility. You can set your browser to block or alert you about these cookies, but this may affect how the website functions. For more information please visit www.aboutcookies.org or www.allaboutcookies.org.

Cookie Details‎

Performance

Performance

Performance

Performance cookies are used to analyze the user experience to improve our website by collecting and reporting information on how you use it. They allow us to know which pages are the most and least popular, see how visitors move around the site, optimize our website and make it easier to navigate.

Cookie Details‎

Please confirm your settings by refreshing the page.

Functional

Functional

Functional

Functional cookies help us keep track of your past browsing choices so we can improve usability and customize your experience. These cookies enable the website to remember your preferred settings, language preferences, location and other customizable elements such as font or text size. If you do not allow these cookies, then some or all of these services may not function properly.

Cookie Details‎

Advertising

Advertising

Advertising

Advertising cookies are used to send you relevant advertising and promotional information. They may be set through our site by third parties to build a profile of your interests and show you relevant advertisements on other sites. These cookies do not directly store personal information, but their function is based on uniquely identifying your browser and internet device.

Cookie Details‎

Advertising Cookies

Consent Leg.Interest

Select All Vendors

Select All Vendors

Select All Hosts

Select All

Clear Filters

Information storage and access

Apply

Confirm My Choices Reject All Allow All

My Subscriptions

Loading

Knowledge Base

Renaming a virtual machine and its files in VMware ESXi (1029513)

Last Updated: 5/14/2021Categories: How toTotal Views: 90915Language:
Chinese (Simplified)JapaneseEnglishGerman

103 like this article

Subscribe to get an email
newsletter with new updates

103 people found this helpful Please provide article feedback:

Learn how VMware Skyline Advisor and Skyline Health Diagnostics work together to provide proactive intelligence and self-service log analysis.

Use Skyline Advisor to avoid issues before they occur across VCF, vSphere, vSAN, NSX, vROps & Horizon. Skyline Findings are based on top KBs, VMSAs/CVEs and design best practices.

Use Skyline Health Diagnostics to root cause vSphere & vSAN logs when an issue occurs. Skyline Health Diagnostic Findings are based on top KBs and VMSA/CVEs. You can use the Skyline Health Diagnostics tool in online or offline mode.

If you require additional help from technical support, please use Skyline Advisor to initiate a Log Assist to reduce time to upload logs. TSEs can also initiate logs to reduce effort.

Purpose

This article provides steps on how to rename a virtual machine and its files through SSH, System Management Interface, or directly at its console.

Renaming a virtual machine using the vSphere Client only changes the display name, not the corresponding files on the datastore. It may be useful to also rename the files of virtual machines to maintain consistency.

Resolution

A virtual machine's files can be renamed during a disk migration operation, such as Storage Migration, Storage vMotion or by manually renaming them in-place from the ESXi Shell. Select your preferred method.

Renaming virtual machine files using Storage vMotion

A virtual machine's files can be renamed on the fly during a Storage vMotion initiated from the vSphere Client. The renaming occurs with no downtime.

Log in to the vCenter web client.

Locate the virtual machine in your host inventory.

Right-click the virtual machine and click Rename.

Change the virtual machine name as required.

Begin a Storage vMotion or an offline Storage Migration of the virtual machine. For more information, see:

ESXi 6.x: Migration with Storage vMotion

ESXi 7.0 .x: Migration with Storage vMotion

Notes:

The Storage vMotion only changes the name of the virtual machine files when the destination datastore is different from the original.

After the migration completes, the virtual machine files match the virtual machine name configured in step 4.

If a virtual machine directory already exists on the datastore with the same name, then the target virtual machine is placed in a new directory with _1 appended.

Changing the name does not change the name of any virtual machine files or the name of the directory that the files are located in.

Migration with Storage vMotion changes the virtual machine filenames on the destination datastore to match the inventory name of the virtual machine. The migration renames all virtual disk, configuration, snapshot, and .nvram files. If the new names exceed the maximum filename length, the migration does not succeed.

Renaming virtual machine files in-place using the console

Warning: Before proceeding, ensure that:

The virtual machine has a current backup and that it has been powered down.

The virtual machine does not have snapshots or virtual disks shared with other virtual machines.

To manually rename files of the virtual machine:

Log in to the vCenter web client.

Locate the virtual machine in your host inventory.

Power down the virtual machine

Right-click on the virtual machine and click Remove from inventory.

Open SSH session to the ESXi/ESX host.

Navigate to the directory containing the virtual machine.

For example:
cd /vmfs/volumes/DatastoreName/originalname

Rename the virtual disk (VMDK) files using the vmkfstools -E command:

vmkfstools -E originalname.vmdk newname.vmdk

Notes:

In some cases, it may be required to clone (copy) a virtual disk. To clone a virtual disk to a new virtual disk, run this command:

vmkfstools -i originalname.vmdk newname.vmdk

This leaves the original virtual disk untouched. You need enough space available to clone the virtual disk in the destination directory. In the preceding command, the new virtual disk is created in the current directory but a different directory can be specified.

You need not rename the originalname-flat.vmdk file after running the vmkfstools command. The vmkfstools command renames both VMDK files and updates the reference within the descriptor.

Do not use the cp or mv commands to rename virtual disk files. Instead, use VMware utilities such as vmkfstools.

Copy the virtual machine configuration file (.vmx) using the command:

cp originalname.vmx newname.vmx

Open the file new virtual machine configuration (for example, newname.vmx) in a text editor.

For more information, see Editing configuration files in VMware ESXi and ESX .

For example:

vi newname.vmx

Within the configuration file, modify all old instances of the virtual machine's file names to the new file names. At a minimum, modify these values (more may exist):

nvram = "newname.nvram"
displayName = "newname"
extendedConfigFile = "newname.vmxf"
scsi0:0.fileName = "newname.vmdk"
[...]
migrate.hostlog = "./newname-UUID.hlog"

Repeat this process for each virtual machine disk. For example:

scsi0:1.fileName = "newname_1.vmdk"
scsi0:2.fileName = "newname_2.vmdk"

Correct the VMkernel swap file reference.

For example:

sched.swap.derivedName = "/vmfs/volumes/DatastoreUUID/newname/newname-UUID.vswp

Note: Ensure that you rename both the .vswp file and the directory name for the swap file in bold.

Correct any other remaining lines referencing the original path or file names.

Save the file and exit the editor.

Rename all the remaining files, except the .vmx configuration file, to the new names.

For example:

mv originalname.nvram newname.nvram

Change directory to the parent directory:

cd ..

Rename the directory for the virtual machine:

mv originalname newname

Using the VMware vSphere Client, browse the datastore and navigate to the renamed virtual machine directory.

Right-click the virtual machine's new configuration file (for example, newname.vmx) and select Add to inventory.

Alternatively, you can use this command to add the virtual machine to the inventory:

vim-cmd solo/registervm /vmfs/volumes/DatastoreName/newname/newname.vmx

Power on the virtual machine.

A question for the virtual machine displays in the Summary tab during power-on. To review the question:

Click the Summary tab.

Right-click the virtual machine in your inventory and select Answer question.

When prompted, select I moved it, then click OK.

Warning: Selecting I copied it results in a change of the virtual machine's UUID and MAC address, which may have detrimental effects on guest applications that are sensitive to MAC address changes, and virtual machine backups that rely on UUIDs.

Optionally delete the original virtual machine configuration file.

For example:

rm /vmfs/volumes/DatastoreName/newname/originalname.vmx

Related Information

The CLI on ESX is case-sensitive and requires escaping of special characters used in some virtual machine file names. The examples above encourage the use of quotation marks around command arguments to ensure spaces and special characters are interpreted literally and do not require escape sequences.

For example, a virtual machine named "Original VM" is referenced either as "Original VM" (with quotation marks) or Original\ VM.

Special characters, such as opening and closing parentheses, also require character escaping. A virtual machine named "Original VM (1)" is referenced either as "Original VM (1)" (with quotation marks) or Original\ VM\ \(1\).

The former quotation method simplifies the process considerably and improves readability.

Additional information on escape characters can be found in the Bash Reference Manual.

Note: If you find the link is broken, provide a feedback and a VMware employee will update the link.

Renaming a virtual machine disk (VMDK) via the vSphere Management Assistant (vMA) or vSphere CLI (vCLI)

Unable to connect to an ESX host using Secure Shell (SSH)
Editing configuration files in VMware ESXi and ESX
vSphere 5.x Storage vMotion does not rename virtual machine files on completing migration
重命名 VMware ESXi/ESX 中的虚拟机及其文件
VMware ESXi/ESX で仮想マシンとそのファイルの名前を変更する
Umbenennen einer virtuellen Maschine und deren Dateien in VMware ESXi und ESX

Detectable by VMware SkylineTM

Actions

Copy

link to clipboard
copied!

Print

Language:
Chinese (Simplified)JapaneseEnglishGerman

Attachments

Additional Resources

KB
•
End Of General Availability of the Free vSphere Hypervisor (ESXi 7.x and 8.x) (2107518)

KB
•
Download and Install VMware Fusion (2014097)

Results 1-2 of 2

Ask The Community

Get answers quickly from VMware experts in the community

Post Subject

CONTINUE IN COMMUNITIES

Related Products:

VMware vSphere

Related Versions:

VMware vSphere 7.0.x

VMware vSphere 6.x

Take Our Survey

Support Assistant