Systems Engineering and RDBMS

Exporting and Importing Virtual Machines Using ‘vmkfstools’

Posted by decipherinfosys on February 25, 2007

Importing and exporting virtual machine from a VMWare ESX Server host involves converting that virtual machine’s .vmdk file(s) from one format to another. Even though other versions of VMWare (GSX Server, Workstation, etc) also use virtual machine files, the format is slightly different. Since GSX and Workstation run on top of a Windows operating system, they are not able to use the VMFS file system native to VMWare. Only ESX Server, which is basically its own operating system, has the ability to use VMFS.

VMKFSTOOLS

Often times administrators find themselves in a situation where they must either move a virtual machine created in GSX Server or Workstation to an ESX host server, or the other way around. One way to accomplish this is to use the ‘vmkfstools’ command, which is included with all versions of VMWare ESX Server. Vmkfstools is a powerful command that lets you manipulate virtual machine files.

Exporting Virtual Disks from ESX Server

In order to run a virtual machine created in ESX Server on another VMWare platform, the .vmdk files need to be converted into a format that can be read by the Windows FAT or NTFS file systems (remember that VMWare GSX Server and Workstation run on Windows).

The vmkfstools command and switches required to acheive this conversion are as follows:

In ESX Server 2.5 and earlier:

vmkfstools -e <folder>/<filename>.vmdk <vmhba number>:<filename>.dsk

<folder> is the name of the folder that you are exporting

<filename> is the name of the actual virtual machine file(s) you are exporting

<vmhba number> is the name of the VMFS partition the above files and folders are located in.

An example of a complete command would be:

vmkfstools -e /mnt/vmfolder/vmserver1.vmdk vmhba0:0:8:vmserver1.dsk

Once the conversion has been completed you can copy the files to the destination VMWare host server and add the files as a new virtual machine.

Note: ESX Server 2.5 may use a .vmdk file extension instead of the .dsk extension shown in the example. In that case the last part of the example would be ‘vmhba0:0:8:vmserver1.dsk’

In ESX Server 3.0:

vmkfstools -i /vmfolder/vmserver1.vmdk -d 2gbsparse /dest/folder/vmserver1.vmdk

Note: the destination path /dest/folder/vmserver1.vmdk shold not contain any existing files with the name ‘vmserver1.vmdk’. If it does the file will be overwritten.

Importing Virtual Disks from GSX Server and Workstation to ESX Server

Before an ESX Server can run a virtual machine created on a different version of VMWare, the virtual disks must first be converted to a format that can be read by the VMFS file system. This is done by running the following vmkfstools command:

vmkfstools -i <folder>/<filename>.vmdk <vmhba number>:<filename>.dsk

<folder> is the name of the folder from which you are importing from

<filename> is the name of the virtual machine file(s) to be imported

<vmhba number> is the name of the VMFS partition you are importing to

An example of a complete command would be:

vmkfstools -i /mnt/vmfolder/vmserver1.vmdk vmhba0:0:8:vmserver1.dsk

As you may have noticed, the only difference between the export and import commands are the ‘-e’ and ‘-i’ switches.

Additional information regarding the vmkfstools command can be found in the ESX Server documentation. However, additional entries about vmkfstools will also be written in the near future
 

About these ads

Sorry, the comment form is closed at this time.

 
Follow

Get every new post delivered to your Inbox.

Join 79 other followers

%d bloggers like this: