This something that I don’t have to use very ofter but it can save sometime if you have a standalone ESX hosts. If you have vSphere with vCenter server than Storage VMotion is the way to do this same thing. It’s also much easier to accomplish. But if you are a small shop or have a standalone host some place these few steps will get the job done.
Just to make things clear you cannot do this while the Virtual Machine is running, you will have to shut it down first. Then log into the service console via SSH or at the console directly. You need to login with root privileges or us SU – to elevate your rights.
Before starting you will need to find out the LUN ID that your machine is located on. You do not want to use the datastore friendly name for these commands. There are 2 ways that you can find this out.
First method is from the command line you move into the /vmfs/volumes directory and list its contents. You can then move into the different LUN’s to find the Virtual Machine that you want to move.
The second option to find out the LUN ID would be to connect directly to your host. Then go to the Configuration tab and click on storage from the left section. You can then click on the Datastores and you will be able to see the ID in the lower section. I circle an example on the picture above.
Now that you have identified the LUN ID’s and shutdown your virtual machine. You can now unregister the VM so that it can be moved without breaking anything. Use the command listed below with your details and refer to the picture above to see what it looks like on my test machine.
vmware-cmd -s unregister /vmfs/volumes/LUN ID/vmname
Now that the virtual machine has been unregistered it can be moved. This can be done by the mv linux command and providing a source and target locations. Use a command like the one below and again refer to the image above to a real life example.
mv /vmfs/volumes/source LUN ID/vmname /vmfs/volumes/destination LUN ID/vmname
The last step now that you have moved the virtual machine is to register it with the host. This is similar to the earlier step and I have listed a command sample below. Also the image above shows my lab example.
vmware-cmd -s register /vmfs/volumes/LUN ID/vmname/vmname.vmx
About Brian
Brian is a Technical Architect for a VMware partner and owner of this website. He is active in the VMware community and is helps lead the Chicago VMUG group. This blog Virtualize Tips was started to document and remember things that I come across while working with tech.
Mail | Web | Twitter | LinkedIn | More Posts (170)





