Toying with VMware ESXi – importing existing vmdk

Didn’t really get to use VMware ESXi until recently where I need to set up some virtualization environment for demonstration purposes. Was originally looking at XenServer “Project Boston” (released on 16th May 2011) but chose ESXi in the end, not because ESXi is better than XenServer but instead:

  • My previous mini-demo environment were based on VMware Workstation/Player
  • Little time to explore new hypervisor hence sticking to what I have on hand

I told myself that I will try running Citrix infrastructure on XenServer the next time.

After setting up the ESXi on a trusty old IBM x3650 box, I tried importing my existing vmdk (Active Directory, Citrix Licensing Server, Citrix XenApp Servers, Citrix Web Interface, Data Store, Microsoft Exchange Server, etc) into ESXi.

The import process is not as straight forward as I thought (to be). The vSphere vCenter only imports virtual machines based on OVF (Open Virtualization Format). To import the vmdk, you can either:

  • use VMware Converter to convert the vm disk file and upload to ESXi; or
  • enable ssh on the ESXi, upload the disk into datastore and clone the disk

I chose the latter as I happen to be at a project site where bandwidth is an issue so downloading a VMware Converter software is a no no. So how can one import existing vmdk into ESXi?

Enable SSH on the ESXi

  1. At the console of the ESXi host, press <ALT> + <F1> to enter the console window
    The screen should change to one without command prompt
  2. Enter “unsupported” in the console (without the quotes) and hit <Enter>
    You should see a Tech Support Mode warning and command prompt
  3. Enter “vi /etc/inetd.conf” to edit the configuration file
  4. Uncomment the lines that starts with “#ssh” to enable ssh
    Note: There are 2 lines that starts with #ssh, one for IPv4 and one for IPv4. So uncomment the one that is suitable for your environment
  5. Save the file (/etc/inetd.conf)
  6. Enter “/sbin/services.sh restart” to restart the management services to start SSH

Create a new Virtual Machine without disk

From the VMware vSphere vCenter, create a new virtual machine but before you create the machine, go to the advance settings and remove the HDD. Take note of the name you used for the virtual machine.

Upload the vmdk file to ESXi and clone it

  1. Use SCP or WinSCP to upload the vmdk files to “/vmfs/volumes/datastore1”
  2. Clone the vmdk file by using the command “vmkfstools -i <input.vmdk> <output.vmdk>”
    There should be 2 output files – output-flat.vmdk and output.vmdk

Moving the disk file to your virtual machine

Remember I told you to take note of the virtual machine name? A folder will be created with the same virtual machine name in /vmfs/volumes/datastore1. You will need to move the cloned disk (from the previous step) to the folder. You can do this through SSH and the mv command.

Add the disk to the virtual machine

From the vSphere vCenter, add a hdd (existing hdd) to the virtual machine through virtual machine settings. The hdd image can be found in the folder datastore1/<virtual machine name>.

It’s done!

Boot up your virtual machine! It should run fine. Do remember to install the VM tools. 🙂

 

Treat shadowandy!

If these step-by-step guides have been very helpful to you and saved you a lot of time, please consider treating shadowandy to a cup of Starbucks.  

  • M. Fricke

    If you’ve got a compatible .vmx file, there’s an easier way.
    You can import the whole machine by copying the folder to the datastore, open the datastore explorer by rightclicking the datastore in the overview, locate the uploaded folder, right click the .vmx and add the machine to the hosts inventory.

  • Joachim Otahal

    Thanks, that is what I needed.

    To Mr. Fricke: Useless comment if the morons sending you the “backup” or “export” are only sending you vmdk images without using their brain and export it the way it is supposed to. A clean done export can be imported using the vCenter converter.

    This happens a lot more often than you can imagine!

  • Ennis McCaffrey

    Thanks, this helped out a bunch.

    -Ennis

  • B. Koz

    Thanks M. Fricke, that’s the info that I was looking for. I had a copy of the entire VM folder and I was pretty sure there was a quick way to import the VM without importing, exporting, or copying the VM.

  • Asimov

    Don’t use WinSCP to upload the vmdk, instead use the vSphere Client upload facility, it is much, much faster. Browse a datastore and click the upload icon, choose your vmdk file and go!

Close