Knowledgebase
emscom > emscom Help Desk > Knowledgebase

Search help:


ESXi Clone operations including snapshots

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

Document Id
1027876

Symptoms



Purpose
This article provides instructions on how to clone individual virtual machine disks through ESXi/ESX 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 in this article.

Impact / Risks
Downtime during the clone procedure.

Resolution

Cloning a virtual machine disk without delta files or snapshots

To clone a virtual machine disk using the ESXi/ESX host terminal:
  1. Log in to the terminal of the ESXi/ESX host.

  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/examplevm/examplevm.vmdk /vmfs/volumes/Storage2/examplevm_clone.vmdk

    You see output similar to:

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


    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 want the destination disk to be thin provisioned, add -d thin to the end of the preceding command.

      For example:

      # vmkfstools -i /vmfs/volumes/Storage1/examplevm/examplevm.vmdk /vmfs/volumes/Storage2/examplevm_clone.vmdk -d thin

Cloning a virtual machine disk with delta files or snapshots

To clone a virtual machine disk using the ESXi/ESX host terminal:
  1. Log in to the ESXi/ESX 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/examplevm/examplevm-000003.vmdk /vmfs/volumes/Storage2/examplevm_clone.vmdk

    You see output similar to:

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

Related 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. These 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.
For snapshot delta file cleanup procedures and other related information, see the Additional Information section of Consolidating snapshots (1007849).
 
For more information on vmkfstools in this context, see Cloning and converting virtual machine disks with vmkfstools (1028042).
Consolidating snapshots in ESX/ESXi 3.x and 4.x
Cloning and converting virtual machine disks with vmkfstools
Clonagem de discos individuais da máquina virtual por meio do terminal do host VMware ESX
Clonación de discos individuales de la máquina virtual mediante la terminal del host VMware ESX
通过 ESX/ESXi 主机终端克隆单个虚拟机磁盘
ESX/ESXi ホスト端末を使用して個々の仮想マシン ディスクのクローンを作成する

 
Was this article helpful? yes / no
Related articles ESXi consolidate space on thin disk
ESXi Create clone from snapshot
ESXi Ueful but poorly documented commands
ESXi OVF Tool
Time Machine backup rsync
Article details
Article ID: 118
Category: Virtualisation
Date added: 09-04-2018 19:14:24
Views: 3750
Rating (Votes): Article rated 5.0/5.0 (1)

 
« Go back

 
Powered by Help Desk Software HESK, in partnership with SysAid Technologies