登入到 Esxi 後台, 我的是遠程SSH登入.

非常簡單,我的目的是把 examplevm 虛擬機的 硬盤 複製到 另一個虛機機 examplevm_clone

vmkfstools -i "/vmfs/volumes/Storage1/examplevm/examplevm.vmdk" /vmfs/volumes/Storage2/examplevm_clone/examplevm_clone.vmdk

 

具體參考

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1027876

 

Cloning individual virtual machine disks via the ESX/ESXi host terminal (1027876)

Purpose

This article provides instructions on how to clone individual virtual machine disks via ESX/ESXi host's terminal.

Note: The context of the instructions will change depending on whether the virtual machine has existing snapshots or not. If the virtual machine has snapshots or delta disks, refer to the appropriate instructions included below. Both scenarios are covered in this article. 

Resolution

Cloning a virtual machine disk without delta files or snapshots

To clone a virtual machine disk using the ESX/ESXi host terminal:
  1. Log into the ESX/ESXi host's terminal.

  2. Navigate to the virtual machine's directory using the cd command. It is located at:

    /vmfs/volumes/source_datastore/virtual_machine/

  3. Confirm the destination directory where the clone will be copied to. Create this directory, if required.

    For example, if this destination directory does not exist:

    /vmfs/volumes/destination_datastore/virtual_machine/

    Create the directory using this command:

    mkdir /vmfs/volumes/destination_datastore/virtual_machine/

  4. Clone the virtual hard disk using the vmkfstools -i command after shutting down the virtual machine:

    # vmkfstools -i "/vmfs/volumes/Storage1 (3)/examplevm/examplevm.vmdk" /vmfs/volumes/Storage2/examplevm_clone.vmdk

    Notes:
    • Encapsulate objects with quotes where appropriate to ensure spaces and other special characters are interpreted correctly.
    • By default, the vmkfstools -i command will create a destination thick provisioned disk. If you would like the destination disk to be thin provisioned, add -d thin to the end of the above command.

    The output appears similar to:

    Destination disk format: VMFS thick
    Cloning disk '/vmfs/volumes/Storage1 (3)/examplevm/examplevm.vmdk'...
    Clone: 100% done.

Cloning a virtual machine disk with delta files or snapshots

To clone a virtual machine disk using the ESX/ESXi host terminal:
  1. Log into the ESX/ESXi host's terminal.

  2. Navigate to the virtual machine's directory using the cd command. It is located at:

    /vmfs/volumes/source_datastore/virtual_machine/

  3. Confirm the destination directory where the clone will be copied to. Create this directory, if required.

    For example, if this destination directory does not exist:

    /vmfs/volumes/destination_datastore/virtual_machine/

    Create the directory using this command:

    mkdir /vmfs/volumes/destination_datastore/virtual_machine/

  4. Clone the virtual hard disk from its current snapshot delta point using the vmkfstools -i command.

    # vmkfstools -i /vmfs/volumes/Storage1 (3)/examplevm/examplevm-000003.vmdk /vmfs/volumes/Storage2/examplevm_clone.vmdk

    The output appears similar to:

    Destination disk format: VMFS thick
    Cloning disk '/vmfs/volumes/Storage1 (3)/examplevm/examplevm-000003.vmdk'...
    Clone: 100% done.


    Note: If the process fails, try selecting the next snapshot delta point in the snapshot tree; the selected point or one of its parents may be corrupt.

Additional Information

Additional steps for virtual machine disks with delta files or snapshots

The original virtual machine files are still intact without modifications. You may opt to either create a new virtual machine and attach the cloned disk file(s), or replace the existing disks attached to the virtual machine with the cloned copies. The following steps encompass the latter option.

To replace the original virtual machine disk(s) and delta snapshot file(s) with the cloned copy or copies:
  1. Detach the virtual hard disk from the virtual machine's configuration in the VMware vSphere or Infrastructure Client.

  2. Attach the new (cloned) virtual hard disk, /vmfs/volumes/Storage2/examplevm_clone.vmdk to the virtual machine.

  3. Rename the snapshot database (.vmsd) file for the virtual machine. At this time it is no longer valid due to manipulation of the virtual machine's disk layout during troubleshooting:

    # mv examplevm.vmsd examplevm.vmsd.old

  4. Power on the virtual machine and confirm the guest operating system can boot successfully. Verify data integrity and confirm data is not missing or corrupt.

  5. With the virtual machine still powered-on, you may remove the original disk files to free datastore space. Files in use by the powered-on virtual machine cannot be removed by the VMware ESX server. This can be used as a safeguard.

 

Felix 發表在 痞客邦 PIXNET 留言(0) 人氣()