Wednesday, January 02, 2008

Old VM's to New ESX server

So for all of us small/medium size guys who are facing problems with old VMs on older servers or moving VM from test into production who don't have Vmotion or any of the cool stuff how do they do it?

I know of two ways. One way is command line and the other is gui. The command line way it more fun LOL but it's long and prone to error. The gui way like everything gui related to short and to the point. I'll go over the command line way first b/c it's good to know these things.

Moving VM's from ESX host to ESX host (method 1)

First you'll have to unregister you VM from the target host. To do this you have to use an ssh tool to console in like putty. SSH into the host where the VM that you want to move is located. Run the command to list your VM's

vmware-cmd -l = lists your VM's

You will notice that VM's show up with long character names followed by the shortcut name which is what you named your datastore within the Infrastructure client.

Now you'll need to unregister your VM that you want to move. To do so you'll use the command

vmware-cmd -s unregister /path/to/datastore (this path should look something like this /vmfs/volumes/datastore name

Now using FastSCP b/c this allows you to SCP into the server with root access (great tool), connect to the target ESX host and destination ESX host. You should see both host on the left side pane.

On the destination host create a folder where your volumes are and call it the datastore name. On the target browse to into the VM folder that you want to move to the new host. You will see about a dozen or so files. Copy all the files ACCEPT the .vmdk files over to the folder you just created in the new host.

Once that copy is done on the destination host create a temp folder where ever you have available space (must be enough to hold the size of the .vmdk files). Now copy the .vmdk files from the target server to this location. This copy takes a while depending on the size of the .vmdk files, 40GB is about 2 hours.

Once the files are copied run the vmkfstools command.

vmkfstools -i /path/of copied vmdk/name.vmdk /path/of where all the other files are/name.vmdk

So you will run this tool against the .vmdk files you just copied to allow the tool to reincorporate the .vmdk files over to the first set of files you copied earlier. So you must have both paths correct of it will fail.

This process takes a little while b/c it has to put everything back together and I think it defrags at the same time.


Moving VM's from ESX host to ESX host (method 2)

Use VMware Converter. LOL thats it. I found out the hard way that this was the easiest way to move VM from host to host. My last post explains how to do it.

3 comments:

MAZ said...

Hi!
Nice work you have done.
Did you tried the same with ESX 4.0 servers. I need to migrate my Guest VMs from one ESX 4.0 to other ESX 4.0 server.

BR,
Aamir

MAZ said...

Hi!
Nice work you have done.
Did you tried the same with ESX 4.0 servers. I need to migrate my Guest VMs from one ESX 4.0 to other ESX 4.0 server.

BR,
Aamir

Nocturnalis said...

Hey Aamir

I have not tried this with ESX 4.0. But I don't see why you would not be able to use the VMware Converter to achieve your goal!

I'm running my ESX hosts in HA mode and taking advantage of Vmotion. I'm still currently on ESX 3.5 but our other office in London has installed 4.0 and I've helped when configure Vmotion. 3.5 and 4.0 don't seem on that different from the Infrastructure console side. Underneath is a different story but converter should still be a solid solution for you.

Let me know how it goes.