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
- At the console of the ESXi host, press <ALT> + <F1> to enter the console window
The screen should change to one without command prompt - Enter “unsupported” in the console (without the quotes) and hit <Enter>
You should see a Tech Support Mode warning and command prompt - Enter “vi /etc/inetd.conf” to edit the configuration file
- 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 - Save the file (/etc/inetd.conf)
- 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
- Use SCP or WinSCP to upload the vmdk files to “/vmfs/volumes/datastore1”
- 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. 🙂