Knowledge Base

The VMware Knowledge Base provides support solutions, error messages and troubleshooting guides
 
Search the VMware Knowledge Base (KB)   View by Article ID
 

Moving a single virtual disk using Storage vMotion via the command line (1004040)

Purpose

By default, Storage vMotion moves the entire home directory of a virtual machine. This article provides the syntax to move a single virtual disk instead.

Resolution

VMware VirtualCenter 2.5 U2 and later


Ensure that you have the VMware vSphere CLI, VMware vSphere Management Assistant, or the VMware Infrastructure Management Assistant deployed in your environment. These tools are available for download under the Drivers and Tools section of the applicable version of ESX and can be deployed on Linux based or Microsoft Windows operating systems.
Run this command to move a virtual machine and its first disk to a new datastore, while leaving its second disk on the old datastore:

svMotion --datacenter=’My DC’ --vm=’[old_datastore] myvm/myvm.vmx:new_datastore’ --disks=’[old_datastore] myvm/myvm.vmdk:new_datastore,[old_datastore] myvm/myvm_1.vmdk:old_datastore’

Note: The type of quotation may vary depending on the platform on which the command is executed. Double quotations may be required in Windows implementations of the vSphere CLI.

This command uses three separate switches. They are:

  • The --datacenter switch that identifies the datacenter in which the virtual machine resides. For example:

    --datacenter= ’My DC’

    In this example, the datacenter identified is My DC.

  • The --vm switch that identifies three parameters:
    • The source datastore
    • The virtual machine
    • The destination datastore

    For example:

    --vm=’[old_datastore] myvm/myvm.vmx:new_datastore’

    In this example, old_datastore represents the source datastore, myvm/myvm.vmx represents the virtual machine on the source datastore, and new_datastore represents the destination datastore.

    This switch specifies where the virtual machine configuration files are stored in the destination datastore.

  • The --disks switch that identifies six values:
    • The source datastore of first disk (myvm.vmdk).
    • The virtual machine disk of first disk (myvm.vmdk).
    • The destination datastore for first disk (myvm.vmdk).
    • The source datastore of second disk (myvm_1.vmdk).
    • The virtual machine disk of second disk (myvm_1.vmdk).
    • The destination datastore for second disk (myvm_1.vmdk).

    For example:

    --disks=’ [old_datastore] myvm/myvm.vmdk:new_datastore ,[old_datastore] myvm/myvm_1.vmdk:old_datastore’

    In this example, you can see the source, destination, and location of 2 virtual disks separated by a comma.

    For the first disk, old_datastore is the source datastore, myvm/myvm.vmdk represents the virtual disk file on the source datastore, and new_datastore represents the destination datastore for the first virtual disk file.

    For the second disk, old_datastore is the source datastore, myvm/myvm_1.vmdk represents the virtual disk file on the source datastore, and old_datastore represents the destination datastore for the first virtual disk file.

    Note: For the second disk, old_datastore is both the source and the destination datastore. This means that the second virtual disk remains in the original datastore and is not migrated along with the first disk and the virtual machine configuration files.

    Caution: Any disks which are not explicitly defined in the syntax are migrated to the same location as the vmx file by default. You must specify all of the locations of all of the disks when migrating a subset of all virtual disks, this includes disks that will not be migrated.

VMware vCenter 4.x


For more information, see the Migrate a Virtual Machine with Storage vMotion section in the vSphere Basic System Administration Guide.

Note: On step 5 in the procedure provided in the guide, click Advanced. In the Datastore column, select a destination for the configuration file and each virtual disk, and click Next.

For information on verifying the supportability for CLI 4.0 and later, see the vCLI Users Guide for 4.0 and 4.0 Update 1.




Additional Information

Request a Product Feature

To request a new product feature or to provide feedback on a VMware product, please visit the Request a Product Feature page.

Feedback

  • 17 Ratings

Did this article help you?
This article resolved my issue.
This article did not resolve my issue.
This article helped but additional information was required to resolve my issue.
What can we do to improve this information? (4000 or fewer characters)
  • 17 Ratings
Actions
KB: