Moving or copying virtual disks in a VMware environment


Solution

Existing VMware Products and Features

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.
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:

Considerations and Caveats

There 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. For more information, seeVirtual Machine Disk Format (VMDK).
  • When using snapshots, a virtual machine's virtual disks can be comprised of multiple VMDK files which are part of an interdependent chain. For more information, see the Disk Chaining and Redo Logs section in the VDDK API documentation.
  • To prevent performance and data management related issues on ESX, avoid the use of scp, cp, or mv for storage operations; instead use the vmkfstools, the Virtual Machine Importer tool from VMware. For more information regarding the usage of tools within the service console, see Third-Party Software in the Service Console.

Prior to copying virtual machine files

To avoid any potential issues involving snapshots and inconsistent disk chains, we must 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. Also, we must know exactly where the virtual disk file we want to move is located as well as ensure that the virtual machine is powered off.
These steps outline what to do prior to doing an operation to virtual disks from the vSphere/VI Client connected to either vCenter or ESX:
  1. Connect to the ESX host using the vSphere/VI Client with administrator credentials..
  2. Ensure that the virtual machine that uses the virtual disk file does not have any snapshots by right-clicking the virtual machine, and clicking Snapshot > Snapshot Manager.
  3. Make note of the datastore and location of the virtual disk files that you want to copy by right-clicking the virtual machine, and clicking Edit Settings. Click on the virtual disk, and refer to the Disk File portion of the Virtual Machine Properties.
  4. Power off the virtual machine.

    Note: If there is no virtual machine to receive the virtual disk files, you may want to create the virtual machine in advance to establish the destination of the move or copy operation.
These steps outline what should be done prior to doing an operation to virtual disks from VMware Workstation:
  1. Open VMware Workstation, and click on the virtual machine which has the virtual disk you wish to conduct an operation on.
  2. Click VM > Snapshot > Snapshot Manager, and remove any preexisting.
  3. Click VM > Settings > Options Tab make note of the Working Directory section on the bottom left of the Virtual Machine Settings window.
  4. Click VM > Power > Shut Down Guest to power off the virtual machine.

    Note: If there is no virtual machine to receive the virtual disk files, you may want to create the virtual machine in advance to establish the destination of the move or copy operation.
If you want to commit snapshots via the ESX service console, see Committing snapshots from within the Service Console (1006847).

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.

    Example:

    vmfs/volumes/478e0d5b-3535f6a8-0ee2-0017a446ae31/VMtest/VMtest.vmx
    Note: The full path of the configuration file is identified by  for the rest of this article.
  4. Run the vmware-cmd stop command to shutd own the desired virtual machine.
  5. Run the grep -i vmdk  command to list all virtual disk files associated with the virtual machine.

    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 value. The full path of the source virtual disk will be identified by  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).
  6. Run vmkfstools -i  where  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.

Copying virtual disk files using the vSphere Command Line Interface for ESX and ESXi

Unlike ESX, ESXi does not have a service console. To copy files, use the vifs utility that comes with the vSphere Command Line Interface. The vifs command performs common operations such as copy, remove, get (download), and put (upload) files. The command is supported against ESX/ESXi hosts but not against vCenter Server systems. Use the vifs command to perform the file operation on the virtual machine files. The syntax and examples on using the vifs command can be found in the vSphere Command-Line Interface Installation and Reference Guide.

Copying virtual disk files using the vSphere/VI Client datastore browser for ESX and ESXi

The datastore Browser allows you to manage the contents of datastores in the vSphere/VI Client inventory. You can use the Datastore Browser to do these tasks:
  • View or search the contents of a datastore.
  • Add a virtual machine or template stored on a datastore to the vSphere/VI Client inventory.
  • Copy or move files from one location to another, including to another datastore.
  • Upload a file from the client computer to a datastore.
  • Download a file from a datastore to the client computer.
  • Delete or rename files on a datastore.
The Datastore Browser operates in a manner similar to file system applications like Windows Explorer. It supports many common file system operations, including copying, cutting, and pasting files. The Datastore Browser does not support drag-and-drop operations. For detailed instructions on using the Datastore Browser, see the vSphere/VI Client online help.

Copying virtual disk files using a web browser for ESX and ESXi

ESX and ESXi servers have a built in web service which allows you to access files via a web browser. Although this method of copying files is only one way, and does not allow you to upload files, it may be a good alternative in certain situations. To access these files, use this convention:
  1. Open a web browser.
  2. Open the http:///folder URL where the the  is the IP or DNS name of the ESX host.
  3. Enter the appropriate credentials when prompted.
  4. Click the ha-datacenter link.
  5. Browse to and download the desired virtual disk file.

    Note: When using the browser to move and copy virtual disk files in ESX, you must copy both the flat file, and the descriptor file. For example, if a virtual machine disk has a name of disk.vmdk, it would have a corresponding disk-flat.vmdk file which needs to be copied or moved as well.

Copying virtual disk files to and from VMware Server or a VMware desktop product

VMware desktop products such as VMware Workstation and VMware ACE include the VMware Virtual Disk Manager utility. These are some examples of VMware Virtual Disk Manager utility:
vmware-vdiskmanager -n mydisk.vmdk "..\\myNewDisk.vmdk"
vmware-vdiskmanager -n mydisk.vmdk "..\\mydisk.vmdk"
For more information regarding the Virtual Disk Manager utility, see the Virtual Disk Manager User's Guide.

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. These options exist to transport files across to different platforms:
  • FTP file transfer
  • SCP file transfer
  • NFS shares
  • Windows File Sharing (CIFS shares)
reference
http://kb.vmware.com

ความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

ความแตกต่างระหว่าง ESX และ ESXi

ความสามารถครั้งใหญ่ของ Virtual Machine File System 5 (VMFS-5)

ติดตั้ง และใช้งาน VMware ESXi 4 (Free Version)