Convert Virtual Machine of VirtualBox to ESXi

My coworker want to build a virtual machine on ESXi, but vendor only support virtual appliance of Oracle VirtualBox format. VMware has a KB article to show how to “Importing Virtual Machine from Oracle VirtualBox to VMware Fusion, Workstation, or Player (2053864)“. It’s working fine. But it’s not applicable for VMware ESXi.

If you follow the guide to export .ova file and import to ESXi. It will show error below on ESXi 6.0 or later:

Issues detected with selected template. Details….No supported hardware versions among….

After couple of hours’ deep dive. I figured out a way to convert VirtualBox to ESXi. You need Oracle VirtualBox, VMware Workstation or VMware Player and VMware ESXi host.

  1. Select the virtual machine -> Go to main menu -> File -> Export appliance.
  2. Choose the virtual machine.
  3. Make sure Format is “Open virtualization format 1.0“.
  4. Export to a .ova file.
  5. Open the .ova file in VMware Workstation or VMware Player.
  6. The import of the VM maybe failed with following error. Just click Retry button it will work.
    The import failed because xxxxx did not pass OVF specification conformance or virtual hardware compliance checks.
  7. Select the virtual machine and go to main menu -> File -> Export to OVF.
  8. VMware Workstation or VMware Player generates .ovf, .mf and .vmdk files.
  9. Edit .ovf file and find the line with keyword “VirtualSystemType“.
  10. Change the value “vmx-XX” to the version lower or equal to your ESXi version.
  11. Edit .mf file and remove SHA256 value of .ovf file in first line.
    SHA256(XXXXX.ovf)= xxxxxxxxxxxxxxxxx
  12. Now it’s ready to import to VMware ESXi host.

Conclusion

This procedure is not involve any code or command. There are also couple of other ways to convert VirtualBox to ESXi by ovftool command line. I tried several ways but didn’t work. Maybe I did something wrong.

In step 10, I changed VM version in .ovf file directly. I think you can also leverage VMware Workstation or VMware Player to downgrade the virtual machine’s version in GUI. It should work as long as the version is lower than your ESXi supported VM version.

Enable Windows Update on SCCM Managed Computer

Computer cannot contact Microsoft update service to upgrade latest patches if it’s managed by SCCM policy. Sometimes we may need to keep latest patch for testing, security or other purpose, such as when you create a golden image, you always want to keep the system up to date.

I found an article “How To: Remove WSUS Settings and Restore Windows Update Defaults” talks about how to delete registry keys to workaround the restriction.

I also found actually just need to change two keys in registry if you want to enable Windows Update service temporarily.

  1. Backup registry path below.
    HKEY_LOCAL_MACHINESOFTWAREPoliciesMicrosoftWindowsWindowsUpdate
  2. Go to the same path above.
  3. Change value of “DisableWindowsUpdateAccess” from “1” to “0”
  4. Go to following registry path.
    HKEY_LOCAL_MACHINESOFTWAREPoliciesMicrosoftWindowsWindowsUpdateAU
  5. Change value of “UseWUServer” from “1” to “0”

I also wrote another post about solution of install standalone patch on Windows Server 2016 for your reference: “The update is not applicable to your computer” When Install Standalone Patch on Windows Server 2016

How To Migrate Parent Disk on Hyper-V 2012

If you are using Microsoft Hyper-V 2012 and “Differencing Disk” you may get trouble when you want to move whole VMs to another location due to “Parent Disk” migration is not so easy. Following is the steps to move parent disk on Hyper-V server.

Preparation

I assume you want to move bunch of virtual machines. First of all you need to get disk list of virtual machines. Following is a script to grab all parent and differencing disks on a Hyper-V server.

$VMs = Get-VM 
Foreach ($VM in $VMs)
{
  $VHDs = Get-VHD -Path $VM.harddrives.path
  foreach ($VHD in $VHDs)
  {
     [pscustomobject]@{
         Name = $VM.name
         VHDType = $VHD.VhdType
         VHD = $VHD.Path
         ParentVHD = $VHD.ParentPath
     }
  }
}

Save it to “Get-vhdParent.ps1”. Launch PowerShell by administrator right. Run following command to get parent disk table.

.Get-vhdParent.ps1 | format-table -autosize

Now you have disk list in hand.

Move parent disks to new location

Parent disk moving is simple. Just copy the parent disk to new location. I suggest make multiple copies if you have large number of virtual machines linked to a parent disk. The reason is if the parent disk failed, at lease it’s not impact to all linked virtual machines. You can also distribute the duplicated parent disks to multiple location to avoid single location failure.

Re-configure parent disks for virtual machine

To be safe, I suggest grab parent disk information again by following command:

Get-VHD -Path VHDPath

Replace “VHDPath” with real differencing disk path of the virtual machine.

The output shows what’s the linked parent disk. Then run the command below to reconfigure parent disk to new location.

Set-VHD -Path VHDPath -ParentPath ParentVHDPath

You should get nothing return if it’s successfully.

If you manage Hyper-V virtual machines by System Center Virtual Machine Manager. The new parent disk is reflected after you right click the virtual machine and do a “Refresh” in System Center Virtual Machine Manager console.

 

 

 

虚拟主机无法获得DHCP IP地址

刚解决了一个问题,快速更新一下。当虚拟主机无法获得DHCP IP地址时,应该做的第一件事情是检查防火墙,无论是Windows防火墙或者物理防火墙。UDP端口67和68不能被阻挡掉。否则会出现虚拟主机只能获得169.x.x.x的IP地址,这个地址是不可用的,表示虚拟主机无法从DHCP服务器获得地址。

这两个端口是DHCP客户端用来从DHCP服务器获取IP地址的。具体的技术细节可以参考RFC文档

DHCP uses UDP as its transport protocol. DHCP messages from a client

to a server are sent to the ‘DHCP server’ port (67), and DHCP

messages from a server to a client are sent to the ‘DHCP client’ port

(68). A server with multiple network address (e.g., a multi-homed

host) MAY use any of its network addresses in outgoing DHCP messages.

我在排错过程中也用到了这篇文章。

搜索虚拟主机时提示:Login To The Query Service Failed

使用vSphere Client登录vCenter Server 6.0时可能会出现如下报错信息:

Login to the query service failed.

The server could not interpret the communication from the client. (The remote server returned an error: (500) Internal Server Error.)

这是因为在登录vSphere Client时勾选了”Use Windows session credentials“。试试取消它。

相关知识库链接:Searching the Inventory with the vSphere Client fails (2143566)

Login To The Query Service Failed When Search Virtual Machine

You may see following problem if you login vCenter  Server 6.0 by vSphere Client:

Login to the query service failed.

The server could not interpret the communication from the client. (The remote server returned an error: (500) Internal Server Error.)

That’s because “Use Windows session credentials” checkbox is selected. Deselect it and give it a try.

Refer KB Searching the Inventory with the vSphere Client fails (2143566)

Virtual Machine Cannot Get DHCP IP Address

Just a quick post. When virtual machine cannot get DHCP IP address the first thing you want to check is firewall. Whatever Windows firewall or physical firewall. You should make sure UDP port 67 and 68 are not blocked. Otherwise you  will see the virtual machine gets 169.x.x.x IP address only.

The two  ports is required for DHCP client to query IP addresses. The methodology is introduced in RFC document.

DHCP uses UDP as its transport protocol. DHCP messages from a client
to a server are sent to the ‘DHCP server’ port (67), and DHCP
messages from a server to a client are sent to the ‘DHCP client’ port
(68). A server with multiple network address (e.g., a multi-homed
host) MAY use any of its network addresses in outgoing DHCP messages.

I also got some ideas in this post.

Virtual Machine Console in vCenter is Opened by VMware Workstation

If you have VMware Workstation and VMware Remote Console both installed on Windows 10 you may see vCenter virtual machine console in vSphere Web Client is opened by VMware Workstation instead of VMware Remote  Console. If you see same case your VMware Remote Console may be hijacked. I call it “hijack” since there is no easy way to revert it back.

Continue reading “Virtual Machine Console in vCenter is Opened by VMware Workstation”

VMware Workstation自动打开vCenter虚拟机的控制台

如果你的Windows 10电脑上装了VMware Workstation和VMware Remote Console,当你在vSphere Web Client里打开运行在vCenter上的虚拟机控制台时,VMware Workstation可能会代替VMware Remote Console自动连接到控制台。恭喜!你的VMware Remote Console被劫持了。这个问题解决起来比较复杂所以我叫它“劫持”。

Continue reading “VMware Workstation自动打开vCenter虚拟机的控制台”