[Home] [Forum] [3i RCLI Guide]

The command svmotion.pl is used to move the virtual machine's (VM) configuration file and optionally its virtual disks to another datastore while the VM remains running and available. The command is always directed at a vCenter server and you can use the command with ESX and ESXi hosts. The command always includes the --vm option which specifies the VM and its configuration file. You can also use the --disks option to specify where to move the virtual disks for the VM or to specify that the files not move.

The svmotion.pl command can be run in either interactive or noninteractive mode. To use interactive mode, use the command svmotion --interactive. Other parameters will be ignored and you will be prompted for all the information to complete the migration.

In noninteractive mode, you would use the following syntax with the command.

svmotion <connection options> --datacenter=<datacenter_name> --vm <VM config file path>:<destination_datastore> --disks <virtual disk file path>:<destination_datastore>[,<virtual disk 2 file path>:<destination_datastore_2>]

On Linux systems enclose the virtual machine and disk parameters in singles quotes. If using a Windows system to run the command use double quotes. The --disks variable is optional and if omitted the virtual disks for the VM will be migrated to the same datastore specified with the --vm parameter.

Samples Commands

1) Error message - see the recent tasks pane in the VI client for more information on the problem as shown in the below image

svmotion.pl --server virtualcenter --username administrator --password ***** --datacenter=Surrey --vm "[NFS1] SERVER02/SERVER02.vmx:ESX01"

Can't call method "fault_string" without a package or object reference at C:\Program Files\VMware\VMware VI Remote CLI\bin\svmotion.pl line 171.

The VMotion interface is not configured (or is misconfigured) on the source host

2) Move a VM and it's virtual HDs from one datastore to another. There is no output if the command completes successfully. You can use the --verbose option and you will get the message "Storage Vmotion completed successfully.", but the amount of logging detail with that option is substantial.

svmotion.pl --server virtualcenter --username administrator --password ***** --datacenter=Surrey --vm "[datastore1] SERVER02/SERVER02.vmx:datastore2"

3) Move the VMX file to datastore2, but leave one of the VM's virtual drives on datastore1. The VM has two virtual drives: SERVER02.vmdk and SERVER02_1.vmdk.

svmotion.pl --server virtualcenter --username administrator --password ***** --datacenter=Surrey --vm "[datastore1] SERVER02/SERVER02.vmx:datastore2" --disks="[datastore1] SERVER02/SERVER
02_1.vmdk:datastore1]

4) Error attempting to move the virtual drives but not the VMX file.

svmotion.pl --server virtualcenter --username administrator --password ***** --datacenter=Surrey --vm "[datastore1] SERVER02/SERVER02.vmx:datastore1" --disks="[datastore1] SERVER02/SERVER 02_1.vmdk:datastore2,[datastore1] SERVER02/SERVER02.vmdk:datastore2"
Can't call method "fault_string" without a package or object reference at C:\Pro
gram Files\VMware\VMware VI Remote CLI\bin\svmotion.pl line 171.

The requested Storage Vmotion would move a virtual machine's disks without assigning the virtual machine a new home, but such a move is not supported on the source host

5) This command moves the VMX and two virtual disks to 3 different datastores.

svmotion.pl --server virtualcenter --username administrator --password Onyx12345 --datacenter=Surrey --vm "[datastore1] SERVER02/SERVER02.vmx:datastore2" --disks="[datastore1] SERVER02/SERVER02_1.vmdk:datastore2,[datastore1] SERVER02/SERVER02.vmdk:datastore4"

6) In the below example interactive mode is used. Note that 2 syntax errors are entered but the script is validating the data entered before the storage motion command is actually run.


svmotion.pl --interactive

Entering interactive mode. All other options and environment variables will be ignored.

Enter the VirtualCenter service url you wish to connect to (e.g. https://myvc.mycorp.com/sdk, or just myvc.mycorp.com): virtualcenter
Enter your username: administrator
Enter your password:

Attempting to connect to https://virtualcenter/sdk.
Connected to server.

Enter the name of the datacenter: Surrey
Enter the datastore path of the virtual machine (e.g. [datastore1] myvm/myvm.vmx): [datastore1] SERVER02/SERVER02.vmx
Enter the name of the destination datastore: datastore2

You can also move disks independently of the virtual machine. If you want the disks to stay with the virtual machine, then skip this step..
Would you like to individually place the disks (yes/no)? yes
Enter the datastore path of the disk you wish you place (e.g. [datastore1] myvm/myvm.vmdk): [datastore1] SERVER02/SERVER02.vmdk
Enter the name of the destination datastore: datastore3
Would you like to place another disk (yes/no)? yes
Enter the datastore path of the disk you wish you place (e.g. [datastore1] myvm/myvm.vmdk): [datastore1] SERVER02/SERVER02_01.vmdk
Could not find a disk with the path [datastore1] SERVER02/SERVER02_01.vmdk in virtual machine.

Please try again.
Enter the datastore path of the disk you wish you place (e.g. [datastore1] myvm/myvm.vmdk): [datastore1] SERVER02/SERVER02_1.vmdk
Enter the name of the destination datastore: datastore10
Could not find datastore datastore10 in the inventory.

Please try again.
Enter the name of the destination datastore: datastore4
Would you like to place another disk (yes/no)? no

Performing Storage VMotion.
0% |----------------------------------------------------------------------------------------------------| 100%
##########################################################################################
Storage VMotion completed successfully.

Disconnecting.

 

With VirtualCenter 2.5 there is no native option to perform this operation with the VI Client, but you are able to add a plug-in that will allow you to do this. The plug-in can be found here. Once you have installed the plug-in and restarted the VI Client you'll an option called "Migrate storage". That will start the "Migrate Storage..." window. You can then select the vmx for the VM and drag that to the datastore to which you want to migrate the VM. You can also select individual virtual disks and move those to specific datastores just as you can with the svmotion.pl command.

 

INSERT YOUR COMMENT - IF YOU HAVE A QUESTION PLEASE USE THE FORUM


Name (required)

Web Site (optional)

Email address (required - will not be displayed)

Comment (required)

Please enter code

 

Copyright © 2011 - Dave Mishchenko