Existing VMware Products and Features
Prior to manually moving or copying virtual machine disk files, consider using existing VMware features which can accomplish similar desired results. These VMware features include:
- Converting virtual machines with VMware Converter. For more information, see the https://docs.vmware.com/en/vCenter-Converter-Standalone/index.html .
- Converting virtual machines with VMware vCenter Converter. For more information, see the https://docs.vmware.com/en/vCenter-Converter-Standalone/index.html for your VMware product version.
- Live Migrate, Cold Migrate, Clone, or Storage vMotion with VMware vCenter or VMware VirtualCenter. For more information, see the Migrating Virtual Machines in the https://knowledge.broadcom.com/external/article/311446/migrating-virtual-machines.html for your VMware product version.
- Backing up virtual machines with VMware Consolidated Backup.
Considerations and Caveats
The following are several caveats specific to moving or relocating virtual machine disk files:
-
Different versions of VMware products may have different implementations of a virtual disk file.
-
When using snapshots, a virtual machine's virtual disks can be comprised of multiple VMDK files which are part of an interdependent chain.
-
To prevent performance and data management related issues on ESX, avoid the use of using scp, cp, or mv for storage operations; instead use vmkfstools, VMware's virtual machine Importer tool.
-
To avoid any potential issues involving snapshots and inconsistent disk chains, ensure that the virtual machine does not have any snapshots. Moving virtual machines with snapshots is outside of the scope of this article, and VMware strongly recommends using one of the alternate methods described above.
-
You must know exactly where the virtual disk file you want to move is located, and you must ensure that the virtual machine is powered off.
Copying or moving the virtual machine and virtual disks
Follow these high-level steps to move a virtual machine to an alternate location:
-
Select the virtual machine.
-
-
Identify the working directory of the virtual machine.
-
Identify the location of all virtual disks.
-
Power off the virtual machine.
-
Create a folder for the copy of the virtual machine.
-
Copy the virtual machine configuration file ( .vmx) to the new folder.
-
-
Register the new virtual machine.
-
Add the virtual disk copies to the virtual machine copy.
-
Upgrade the virtual hardware if necessary.
-
Power on the virtual machine.
-
Test the new virtual machine.
-
Optionally, delete the original virtual machine files.
Note: For more information about performing these general steps, see Commands for ESX and ESXi and Commands for VMware Server and VMware desktop products in this article.
Creating a new virtual machine and copying or moving the virtual disks
Creating a new virtual machine instead of copying the original virtual machine configuration file has advantages. By creating a new virtual machine, you do not have to create folders, upgrade the virtual machine hardware, or register a virtual machine.
Follow these high-level steps to recreate a virtual machine in an alternate location:
-
Select the virtual machine.
-
Make note of the networking, memory, and CPU configuration of the virtual machine.
-
-
Identify the location of all virtual disks.
-
Power off the virtual machine.
-
Remove virtual disks.
Warning: Do not delete the virtual disk.
- Create a new virtual machine and recreate the configuration identified in step 2.
- Copy the virtual disks to the folder of the new virtual machine.For more information, see Moving or Copying Virtual Disks in a VMware Environment (900).
-
Add the virtual disk copies to the new virtual machine.
- Power on the new virtual machine.
-
Test the new virtual machine.
-
Optionally, delete the original virtual machine files.
Note: For more information about performing these general steps, see Commands for ESX and ESXi and Commands for VMware Server and VMware desktop products in this article.
Commands for ESX and ESXi
The steps to create a copy a virtual machine to a new location or recreate a virtual machine in an alternate location are different for ESX and ESXi.
For specific instructions to perform the following tasks, see the appropriate commands in the KB https://knowledge.broadcom.com/external/article/345049
- Power on the virtual machine
- Power off the virtual machine
- Remove virtual disks
- Upgrade the virtual hardware
- Adding virtual disks
Warning: In certain situations, you may want to run some of the above steps via the command line or service console. To support certain internal operations, ESX installations include a subset of standard Linux configuration commands (for example, network and storage configuration commands). Using these commands to perform configuration tasks can result in serious configuration conflicts and render some ESX functions unusable. Always work through the vSphere Client when configuring ESX, unless otherwise instructed in vSphere documentation or by VMware Technical Support.
Registering a virtual machine
To register a virtual machine from the ESX Service Console, run the command:
vmware-cmd <cfg> register, where <cfg> is the full path to the vmx file
where <cfg> is the full path to the .vmx file
In Versions ESXi 4.1, 5.0, 5.1 and 5.5 vmware-cmd is no longer a valid command .vCLI (vSphere CLI) will have to be installed.
To register a virtual machine from ESXi and thevSphere CLI, run the command:
vmware-cmd.pl -H <host> -U <username> -P <password> <cfg> register
where <cfg> is the full path to the .vmx file
In ESXi 5.x, use this command to register the virtual machine:
vmware-cmd.pl -H <vc_server> -U <login_user -P <login_password --vihost <esx_host> -s register /vmfs/volumes/Storage2/testvm/testvm.vmx
Note: The system returns 0 to indicate success, 1 to indicate failure.
Identifying the working directory
To identify the working directory of the virtual machinefrom the ESX Service Console, run the command:
vmware-cmd -l
To identify the working directory of the virtual machinefrom ESXi and the vSphere CLI, run the command:
vmware-cmd.pl -H <host> -U <username> -P <password> -l
Identifying the location of all virtual disks
To identify the location of all virtual disks from the ESX Service Console, run the command:
grep -i vmdk <cfg>
where <cfg> is the full path to the vmx file
Creating a folder for the copy of the virtual machine
To create a folder for the copy of the virtual machine from the ESX Service Console, run the command:
mkdir /vmfs/volumes/<datastore>/<dir>
where <datastore> is the desired datastore, and <dir> is the desired directory name</dir></dir>
To create a folder for the copy of the virtual machine from ESXi and the vSphere CLI, run the command:
vifs.pl -H <host> -U <username> -P <password> --mkdir '[datastore] dir'
where datastore is the name of the datastore, and dir is the name of the new directory
Copying the virtual machine configuration file to the new folder
To copy the virtual machine configuration ( .vmx) file to the new folder from the ESX Service Console, run the command:
cp <source> <destination>
where <source> is the full path of the virtual machine configuration file, and <destination> is the desired location for the .vmx file.
To copy the virtual machine configuration file to the new folder from ESXi and the vSphere CLI, run the command:
vifs.pl -H <host> -U <username> -P <password> --copy '[src datastore] <src dir>/<vmx>' '[dst datastore] <dst dir>/<vmx>'
where:
- src datastore and dst datastore are the source and destination datastores
- <src dir> and <dst dir> are the source and destination directories
- <vmx> is the name of the . vmx file
Copying virtual disk files across the network to and from different platforms
Moving virtual disk files across a network can be accomplished in many ways and on many platforms. Here are several options to transport files across to different platforms:
- FTP file transfer
- SCP file transfer
- NFS shares
- Windows File Sharing (CIFS shares)
Steps on how to enable, configure, and transfer files using these specific methods are outside of the scope of this article. When transferring virtual disk files across the network, VMware recommends validating the information before and after the file transfer. This can be done by using MD5 checksums. For more information about MD5 checksums, please see Using MD5 Checksums.
Additional Information:
For translated versions of this article, see: