There are occasions that we need to create custom built Linux VMs on behalf of our clients. Forexample, we may build a Linux VM that has all the best practices for 12c Oracle database or a 12c Weblogic Server. We sometimes do this in VMware Fusion or in vSphere/ESXi config.
In this example we will showcase how we migrate VMs built in Fusion to a ESXi based environment.
In this example, it is assumed that the Linux VM is been pre-created in VMware Fusion.
My VMware Fusion runs on MAC OsX 10.9.5
The key tool in this migration/conversion is called vmware-vdiskmanager, and is located in the following directory:
/Applications/VMware\ Fusion.app/Contents/Library
vmware-vdiskmanager has the following capabilities (as per Help)
NitinV$ ./vmware-vdiskmanager -h VMware Virtual Disk Manager - build 1945692. Usage: vmware-vdiskmanager OPTIONS | Offline disk manipulation utility Operations, only one may be specified at a time: -c : create disk. Additional creation options must be specified. Only local virtual disks can be created. -d : defragment the specified virtual disk. Only local virtual disks may be defragmented. -k : shrink the specified virtual disk. Only local virtual disks may be shrunk. -n : rename the specified virtual disk; need to specify destination disk-name. Only local virtual disks may be renamed. -p : prepare the mounted virtual disk specified by the volume path for shrinking. -r : convert the specified disk; need to specify destination disk-type. For local destination disks the disk type must be specified. -x : expand the disk to the specified capacity. Only local virtual disks may be expanded. -R : check a sparse virtual disk for consistency and attempt to repair any errors. -e : check for disk chain consistency. -D : make disk deletable. This should only be used on disks that have been copied from another product. Other Options: -q : do not log messages Additional options for create and convert: -a : (for use with -c only) adapter type (ide, buslogic, lsilogic). Pass lsilogic for other adapter types. -s : capacity of the virtual disk -t : disk type id Disk types: 0 : single growable virtual disk 1 : growable virtual disk split in 2GB files 2 : preallocated virtual disk 3 : preallocated virtual disk split in 2GB files 4 : preallocated ESX-type virtual disk 5 : compressed disk optimized for streaming 6 : thin provisioned virtual disk - ESX 3.x and above Below is the command I ran to convert my Linux VM (Openfiler) to ESXi vmdk: /Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager -r OpenFiler1.vmwarevm/Virtual\ Disk.vmdk -t 4 /Volumes/Oracle-images\ 1/LinuxStones/linuxStones.vmdk Creating disk '/Volumes/Oracle-images 1/LinuxStones/linuxStones.vmdk' Convert: 100% done. Virtual disk conversion successful. ls -l ~/LinuxStones linuxStones-flat.vmdk linuxStones.vmdk Linux66_StonesVT.ova
This conversion produces two files.
Once the vmdk and flat.vmdk files are generated, the next step is to import these into ESXi. I used vSphere client to execute this workflow:
1. Create a new VM, using the usual method; e.g., File->New->Virtual Machine->Custom-> Choose Datastore location
2. Choose Virtual Machine Version -> Guest CPU/Memory/Network/SCSI controller settings -> Select “Do Not Create Disk” -> Finish
3. Go back to VM Configuration-> Datastore -> Browse DataStore -> Upload
4. Upload .vmdk and -flat.vmdk
5. Go back to VM configuration (Virtual Machine Properties) -> Add -> Device Type (Hard Disk) -> “Use an existing virtual disk”
6. Locate the datastore and select the existing disk -> Finish -> OK
7. Startup VM