I ran into an interesting situation a few days ago at work. Basically, we had a very old VMWare Server that was running on Gentoo. All of the VM’s were hosted on that server (about 5 VMs were hosted on this server.) There was only one VM that we actually needed to move from that old VMWare Server to our new ESXi/vCenter server. In the old VMWare Server, there is no export tools build in, because of this..there really isn’t a great way to retrieve your VM through the console.

The solution I chose to use was to actually log in to the Gentoo server directly. All of the Virtual Machines are stored within a folder on the server. This includes the VMDK and VMX files. If you aren’t any good with Linux, there are plenty of resources out there that will walk you through some things to help you navigate through the filesystem. If you don’t know where your VMDK files are stored, go back to your VMWare Server console and right click on the VM you want to move. Click on settings, and it will tell you the path to your virtual machine files. Once you have this path simply log in directly to the server that is hosting your VM. Change directories into where your Virtual Machines are located. For example:

cd var/www/vmware/”Virtual Machines”

Once inside the folder with your VMs, do an “ls” command, which will list all of the files and folders, which is basically all of the VMs you have on that VMWare server. Now is a good time to plug in some sort of external storage. Depending on the size of your VM you could use a Flash Drive or if it’s big, an external hard drive. Be sure that your external storage is formatted in a way that Linux will be able to mount it. Some older versions of Linux won’t recognize the NTFS filesystem, if formatting the drive on a Windows box, this is the standard choice, but I would go with FAT32, in Linux it’s known as “vfat.”

Now that you have your external storage plugged in you’re going to want to mount it so that you can copy all of the files for your VM over to the external storage. This is fairly simple to do. I usually create a “usb” folder in the “mnt” directory, and mount my external drives there. To do this, run the following command:

mkdir mnt/usb

That creates the folder we’re going to mount to.

Then, run the following command to figure out what the name of your external device is

fdisk -l

You should get some output like this:

Disk /dev/sdb: 429.4 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 52216 419425019+ 83 vfat

In this case, we’re interested in /dev/sdb1 as this is my external hard drive.
Make note that this will vary from computer to computer depending on how many devices are plugged in, how many hard drives the server has, etc.

To mount this device so that we can copy files to it, we want to run the following command.

mnt /dev/sdb1 /mnt/usb

That will mount our external device (sdb1) to the folder that we created earlier (/mnt/usb.)
Now it’s just a matter of copying the files over from whatever folder our VM is in, to our mounted device. In my case the VM I want to copy is called “WWW” which is obviously our website. As I am still in the /var/www/vmware/”Virtual Machines” folder, I just need to “cd” into the WWW folder. Now that I am in the folder that has all of the virtual machine files, I am going to run the following command:

cp * /mnt/usb

That is going to copy everything from in the directory which you are in, to the mount folder of your external device. Once that is done we can move on to Part 2. In the next part, we will convert the VMX files to VMware’s OVF format and then upload that to our ESXi server. Be sure to check back later this week for Part 2! Don’t hesitate to ask any questions if you need help with something!