How to move a VM without vCenter or Storage VMotion

Posted by on April 15, 2010 in vCenter Server, VMware, vSphere | 9 comments

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 Suhr

Brian is a VCDX5-DCV and a Sr. Tech Marketing Engineer at Nutanix and owner of this website. He is active in the VMware community and helps lead the Chicago VMUG group. Specializing in VDI and Cloud project designs. Awarded VMware vExpert status 6 years for 2016 - 2011. VCP3, VCP5, VCP5-Iaas, VCP-Cloud, VCAP-DTD, VCAP5-DCD, VCAP5-DCA, VCA-DT, VCP5-DT, Cisco UCS Design

9 Comments

  1. …I don't know; I keep hearing how you should never ever use the mv command on these. There _has_ to be a supported way of doing this. VMware is begining to tick me off.

    • I understand the need of vmkfstools command when cloning. When using mv inside same file system it should be perfectly safe, because it affects only directory data structures not data location of file.

      I do my moves inside esx using vmkfstools -i (clone) and then delete vmkfstools -U

  2. …I don't know; I keep hearing how you should never ever use the mv command on these. There _has_ to be a supported way of doing this. VMware is begining to tick me off.

  3. Hi, wouldn’t svmotion.pl do the same in a supported way? “mv” might not be the fastest way of moving ESX related data around.

    cheers.

    • You are correct that is a valid option if you have vCenter server. I have never tested it on a standalone server, but my guess it might not work.

  4. Can I move with this metod itself the (virtual) vcenter server?

  5. Thanks for the info, thankfully this helped me do what I needed to during my weekend down time. Could do everything else within vcenter, except move the vcenter host

  6. Hey Brians. Thanks for the post. Well I have a one query and it is that I have 10 node cluster and all of them are configure in HA with DRS. One of the host which i have added newly in cluster showing that it is disconnected and it is same for all vms on that host bit at the same time i am able ssh all of them and by running uptime command it is state that this machine is up from last many days that means it haven’t rebooted.So, Could you please help to how to fix this issue and if it is possible to follow the above process to move vm on another host in same cluster without changing LUN -ID. I will wait for your positive reply asap………

    • Most likely has to do with the Management connection to the host. If vCenter cannot talk to the host it and all the VMs running on it will show disconnected. The VMs will still be running if there is nothing else wrong with the host.

      You need to look into this connection which should correct your issue.

Leave a Reply

%d bloggers like this: