7

VMware vSphere 4 SAN storage with multiple data-stores No vCenter

I shut-down a virtual machine and using the data-store browser did a copy/paste to copy the VM to a new datastore with additional space. The file copy performance was very poor, and due to time constraints I decided to cancel the copy task. However the copy task showing in the vsphere client can not be cancelled; the cancel option is disabled.

Currently I am not able to start the machine in it's original location as the disk files are locked for the copy. How can I abort the copy? I tried deleting the target directory but this did not abort the copy task.

1
  • Did you try to connect on the ESX(i) directly and kill the process with 15 signal or worst case scenario 9 ?
    – golja
    Jul 1, 2012 at 12:57

2 Answers 2

10

The answer depends on the version of vSphere you've got.

Step 1:First make sure you disable the automatic restart of VM's.

enter image description here

Step 2: enable the SSH console

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

To create a user in ESX host for using a SSH client:

Log in to the vSphere Client as a root user.
Click Users & Groups.
Right-click on a blank area and click Add.
Enter a username and password. Confirm your password.

Note: Starting in ESX 4.0, the password needs to be at least 
8 characters in length.

Select Grant shell access to this user and click OK.

Step 3: log into ssh
Download putty from: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Step 3a (ESX only) Restart the VM client daemon

service mgmt-vmware restart

Step 3b (Esxi only) Restart the VM client daemon

/etc/init.d/hostd restart

Step 4 Wait for the vSphere client to reconnect
All of your VM's will still be running as before, only the vSphere app will restart.
With it the copy process will stop.

Bonus: a better way to copy

If you have thinly provisioned client, you can use the command-line tool vmkfstools like so:

vmkfstools -i /vmfs/volumes/path_to_datastore/path_to_source_vm/vmname.vmdk /vmfs/volumes/path_to_dest_datastore/path_to_dest_vm/vmname.vmdk -d thin &

This will clone (-i) the vmdk file and make sure the destination file is thinly (-d thin) provisioned. The & at the end of the command will make sure you get your command prompt back.

It will copy much faster than the GUI copy does, and you can cancel it easier.

canceling a vmkfstools copy

ps |grep vmkfstools Note down the PID. kill 12345
Where 12345 is the first number listed on the vmkfstools line.

2
  • thanks, I just needed the last part to make sure I could safely kill the vmkstools copy correctly. for me, this command line was slow and failed.
    – FireDragon
    Sep 18, 2014 at 5:44
  • This one solved my issue!
    – BenCes
    Sep 22, 2015 at 13:13
0

I managed to cancel the copy by creating a dummy virtual machine with a disk almost big enough to fill the datastore; shortly after the copy process caused the space to run out and cancelled itself.

If someone has a better solution I'll accept that as the answer, because that seems like a horrible way to stop a file copy and I'd like to know how to do it nicely.

2
  • 1
    I equate this to "I had to slow down my bike so I used a stick in the spokes". Beware the potential problems.
    – Tim
    Aug 14, 2013 at 0:02
  • 1
    Please do not mark this answer as correct. This is a very bad way to make your ESX(i) cancel the task. It does have impact on all your servers.
    – BenCes
    Sep 22, 2015 at 13:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .