Below is the process I used to migrate all of my VMs from one iSCSI datastore to another iSCSI datastore. Both datastores were connected to the same ESXi host (ESXi 5.1.0). I also used this same method to migrate VMs from the datastore located on the local drive to an iSCSI datastore on ESXi 5.1.0
1. In vSphere Client, properly power down the VM you are going to migrate to a new datastore.
2. Create a directory in the target datastore for the migrated VM (either in vSphere Client’s GUI or via SSH using the mkdir command).
3. In order to migrate a VM from a source datastore to the target datastore (with both datastores attached to the same ESXi host), use the following command:
vmkfstools -i [<path_to_VM_directory_in_source_datastore>]/<source_VM.vmdk> [<path_to_VM_directory_in_target_datastore>]/<destination_VM.vmdk> -d thin
Note 1: if the source VM has had snapshots made and was running off a snapshot (which can be seen by looking inside the <VM_name>.vmx file), use the following name for the source VM’s .vmdk file:
<VM_name>-00000X.vmdk, where X is the number designated to the snapshot used for running this VM. Even though the file size shown for this file in the source datastore is small, the vmkfstools command will consolidate all snapshots up to the snapshot specified for the source .vmdk file in this command and will properly migrate the VM to the new datastore.
Note 2: The -d thin parameter allows the VM to be migrated as thin-provisioned if it was in fact thin-provisioned when created. Therefore, if you don't want the migration process to expand the disk size of this VM to the "thick" size specified when the VM was created, use this parameter. If your VM was already thick-provisioned, I don't know what this parameter will do - probably it will do nothing.
4. Once the migration process has completed, copy the following files from the old datastore to the new datastore:
<VM_name>.vmx
<VM_name>.vmxf
<VM_name>.vmsd
<VM_name>-XY.log (if you want to keep the logs)
5. Edit the <VM_name>.vmx file in target VM directory using the vi command (or by downloading the <VM_name>.vmx file to your local Windows machine via vSphere, editing it with Notepad and uploading it to the same location in the target VM directory) and change the name of scsi0:0.filename = from the name of the snapshot it was running off (which is the name you used for the source .vmdk file in the vmkfstools -i command) to the name you assigned to this .vmdk file in the target datastore location (using the same vmkfstools -i command). Don’t forget to save the <VM_name>.vmx file in the target VM datastore folder.
6. In vSphere Client, remove the old instance of this VM from the host inventory (without deleting the files).
7. In vSphere Client, add the new instance of this VM (located in the target datastore) to the inventory on this host by navigating to the target datastore in vSphere Client, finding the VM’s directory, right clicking on the <VM_name>.vmx file you have just edited, and selecting Add to Inventory.
8. In vSphere Client, start this VM. The start process will halt at 95%. You will have to right click on the name of this VM in the inventory, navigate to Guest > Answer Question, and choose Moved to answer the question about whether you have copied this VM or moved it.
9. Start the VM again in vSphere Client. The VM should launch without any issues.