Moving VM’s between hosts

About a year ago I purchased a 1U IBM X3550 server to run VMware vSphere 5 on. While it was cool to have a server that had dual quad procs and 8 gig of ram in it, the noise it put off was too much for my family room. (Just think of half a dozen 1 inch fans running at 15,000RPM almost constantly.) Recently I have been spending more time in the family room and the noise has gotten to a level that it is almost impossible to do anything in the room with out hearing it. (Like watch tv, a movie, play a game, etc.) So I started looking at my favorite used hardware site, geeks.com, for a new “server”. Well it finally arrived today, an HP XW8600 workstation. It is another dual quad proc, however it has 16GB of ram, and 12 SATA ports and a larger case, and the best of all, almost absolutely quiet.

So with it installed, I needed to start moving the VM’s from the IBM Server to the HP Server. In an enterprise environment, this usually isn’t a problem as you usually have a shared storage (SAN) that each of the hosts connect to. Well in my little home lab I don’t have shared storage. I did try to use COMSTAR in Solaris 10 to export a “Disk” as an iSCSI target. While this would work, it was going to take forever to transfer 1TB of VM’s from one server to a VM running on my Mac and back to the new server.

So a googling I went, and what I found was a way easier way to copy the VM’s over. ovftool, which runs on Windows, Linux and Mac. What it does is allow you to export and import OVF files to a VMware host. The side benefit of that is that you can export from one and import to another all on one line.

So I downloaded the Mac version and started coping. The basic syntax is like this:


./ovftool -ds=TargetDataStoreName vi://root@sourcevSphereHost/SourceVM vi://root@destvSphereHost

So if one of my VM’s is called mtdew, and I had it thin provisioned on the source host and wanted it the same on the destination host, and my datastore is called “vmwareraid” I would run this:

./ovftool -ds=vmwareraid -dm=thin vi://root@ibmx3550/mtdew vi://root@hpxw8600

where ibmx3550 is the source server and hpxw8600 is the destination server. If you don’t specify the “-dm=thin” then when it is copied over, it will become a “thick” disk, aka us the entire space allocated when created. (I.E. a 50GB disk that only has 10GB in use would still use 50GB if the -dm=thin is not used.)

There are some gotchas that you will have to look out for:

  1. Network configs, I had one VM that had multiple internal network’s defined. Those were not defined on the new server, so there is a “mapping” that you have to do. I decided I didn’t need them on the new server so I just deleted them before I copied it over.
  2. VM’s must be in a powered off state. I tried them in a “paused” state and it did not want to run right.
  3. It takes time, depending on the speed of the network, disk, etc, it will take a lot of time to do this, and the VM’s have to be down while it happens. So definitely not a way to move “production” vm’s unless you have a maintenance window.
  4. It will show % complete as it goes, which is cool, but the way it does it is weird. It will show the % at like 11 or 12 and then I turn my head and all of the sudden it says it is completed.
  5. I did have some issues with a vm that I am not sure what happened to it, but when I try to copy it, I get an error: “Error: vim.fault.FileNotFound”… It may be due to me renaming something on the vm at some point in the past.

Hope this helps some other “home lab user”…

 

 

vSphere4i cloning

Have been playing around with VMWare’s vSphere 4i today. One of the major differences between it and the full version is being able to clone and make templates out of VM images. What I did today was setup a machine with a bunch of Solaris VM’s. But I did not want to installed them all from scratch. On the full version of ESX, cloning is supported for Windows and I believe Linux, but don’t think it is for Solaris. So to do the poor mans clone of Solaris was what I needed to do. So how do you do it? Sort of simple:

1. Install one of the VM’s from scratch from either a CD or ISO Image. (You can upload an ISO image to the server by going in to to the Configuration section of the vSphere Client, and clicking on storage and then browse the datastore. What I did was make a directory for the ISO Images, and then you can click the upload button and find the file on the local machine and it will upload it to the server. It makes it a lot faster to install from an ISO image vs the CDRom).

2. Once the OS is installed, I put the latest Security/Recommended patches on it. I also installed the VMWare Tools.

3. Do any “configuration” that you want to be done for all the VM’s. For example, modify the /etc/issue,/etc/ssh/sshd_config, create non root accounts, enable auditing, disable services, etc.

4. The next thing I did was ran a “sys-unconfig”. This will remove the root user’s password, clear the hostname, clear all IP information and the naming service info. It will leave other local created accounts though.

5. The final step of the sys-unconfig, halts the VM. This will be the “last” time you will boot this image. We will now use it as a poor man’s template for our other VM’s. (The reason I say last is unless you are going to update it to be used to “clone” new vm’s, you should never boot it again.) You should also probably rename this virtual machine to be something like “Solaris – Template – DNB” (DNB=Do Not Boot… )

6. Back in the Datastore browser, create a new folder for the to be “cloned” vm.

7. Now go in to the folder of the original vm you made that is in the “unconfiged” state. Once in there, select ALL the files in there and right click and select copy.

8. Now go to the newly created folder, and go in to it and right click and select paste. For a VM with a 20gb disk this takes about a minute or so to copy and paste.

9. Now go in to the cloned directory and right click on the VMX file and select “Add to Inventory”. It will pop up a dialog box and will let you “name” the new vm. Type in the new name of the new vm. (It won’t change the name of the files in that directory though.)

10. Next you can power on the new “cloned” vm. It will give you a pop up box asking if you have “moved” it or “copied” it or something else. Just select copied, and it will load the VM.

11. Now when Solaris boots, it will look like a clean machine, it will ask you for the hostname, ip, name service, etc, and then reboot after you enter in the information.

All said I did about 12 of these and had them all running at the same time and didn’t have a problem with them. If you need some different “hardware” for a vm, before you power it on, you can change the settings just as if you had installed it from scratch. One thing with the new vSphere it will support adding more than just a disk if the OS supports it. So you should be able to add processors, disk and possibly memory on the fly to a solaris VM.

Hope that helps people with the i version of ESX…