Reese Knowledgebase

Copying or moving the virtual machine and virtual disks

View Kristian Reese's profile on LinkedIn


If you like this article, please +1 or Recommend via FB with the provided buttons above:

Article ID: 97
by: Reese K.
Posted: 21 Mar, 2013
Last updated: 21 Mar, 2013
Views: 1715

Copying or moving the virtual machine and virtual disks

The information below has been replicated from kb.vmware.com:
kb.vmware.com/kb/1000936

Follow these high-level steps to move a virtual machine to an alternate location:

  1. Select the virtual machine.
  2. Commit all snapshots on the virtual machine. For more information, see Committing snapshots from within the Service Console (1006847).
  3. Identify the working directory of the virtual machine.
  4. Identify the location of all virtual disks.
  5. Power off the virtual machine.
  6. Create a folder for the copy of the virtual machine.
  7. Copy the virtual machine configuration file ( .vmx) to the new folder.
  8. Copy the virtual disks to the new folder. For more information, see Moving or Copying Virtual Disks in a VMware Environment (900).
  9. Register the new virtual machine.
  10. Add the virtual disk copies to the virtual machine copy.
  11. Upgrade the virtual hardware if necessary.
  12. Power on the virtual machine.
  13. Test the new virtual machine.
  14. Optionally, delete the original virtual machine files.

Step 8 above:

Copying virtual disk files using the ESX service console

  1. Log into the ESX host as root using either a remote console or SSH. For details on how to enable SSH, see Enabling root SSH  login on an ESX host (8375637).
  2. In the event that the virtual machine which is using the virtual disk is using snapshots, you must consolidate those snapshot prior to performing any storage operations.
  3. Run the command vmware-cmd -l command to list all full paths to the configuration (vmx) files of the virtual machines registered to this host.
  4. Example:
    /vmfs/volumes/478e0d5b-3535f6a8-0ee2-0017a446ae31/VMtest/VMtest.vmx
    Note: The full path of the configuration file is identified by <cfg> for the rest of this article.

  5. Run the vmware-cmd <cfg> stop command to shut down the desired virtual machine.
  6. Run the grep -i vmdk <cfg> command to list all virtual disk files associated with the virtual machine.
  7. scsi0:0.fileName = "VMtest.vmdk"
    scsi0:0.fileName = "/vmfs/volumes/478e0d5b-3535f6a8-0ee2-0017a446ae31/VMtest_1.vmdk"

    Note: These entries may not include the full path to the directory. If a full path is not listed, refer to the full path of the <cfg> value. The full path of the source virtual disk will be identified by <src> for the rest of the article.

    Warning: If the file name ends with -#######.vmdk, then your virtual machine is still running off of a snapshot. If you find that these files are present, but you do not have any snapshots in the snapshot manager, see Committing snapshots when there are no snapshot entries in the snapshot manager (1002310).

  8. Run vmkfstools -i <src> <dst> where <dst> is the destination of where you would like to file to be copied.

Note: Syntax from older versions of ESX may vary. For ESX 2.5.X. see Examples of Using vmkfstools from the ESX 2.5.X documentation.

Command Example:

[root@esxhost ~]# mkdir /vmfs/volumes/EMM/emmruby.int.copy
[root@esxhost ~]# cd /vmfs/volumes/EMM/emmruby.int.com
[root@esxhost ~]# vmkfstools -i emmruby.int.com.vmdk -d thin ../emmruby.int.copy/emmruby.int.com.vmdk
[root@esxhost ~]# ls -lh /vmfs/volumes/EMM/emmruby.int.copy/
total 20G
-rw------- 1 root root 146G Mar 15 15:29 emmruby.int.com-flat.vmdk
-rw------- 1 root root  560 Mar 15 15:29 emmruby.int.com.vmdk
-rwxr-xr-x 1 root root 2.9K Mar 15 15:36 emmruby.int.com.vmx

In the above example, I specified the disk format as thin:

SUPPORTED DISK FORMATS
These are the arguments that can be passed to the ´-d´ option for the ´-c´ (create virtual disk) and ´-i´ (clone virtual disk) operations.

     `zeroedthick`
         Space required for the virtual disk is allocated at creation time.
         Any data remaining on the physical device is not erased during
         creation, but will be zeroed out on demand at a later time on
         first write from the virtual machine. The virtual machine does not
         read stale data from disk.

     `eagerzeroedthick`
         Space required for the virtual disk is allocated at creation
         time. In contrast to zeroedthick format, the data remaining on
         the physical device is zeroed out during creation. It might take
         much longer to create disks in this format than to create other
         types of disks.

     `thin`
         Thin-provisioned virtual disk. Unlike the ´zeroedthick´ or
         ´eagerzeroedthick´ format, space required for the virtual disk is
         not allocated during creation, but, it is allocated on demand during
         first write issued to the block. Virtual disk size is zero at
         creation time.  This format provides more efficient user of storage
         space and enables thin provisioning of virtual disks. This format is
         recommended when space utilization is the main concern, and for all
         types of applications except clustering.

This article was:   Helpful | Not Helpful
External links
kb.vmware.com/kb/1000936

Prev   Next
perl     Exporting OVF Template via vSphere Client Times Out

RSS