星期四, 8月 09, 2012

How to install VMware ESXi 5 tools for FreeBSD 9

There are some problems while install FreeBSD 9 vmware tools on VMware ESXi 5 update 1, after searching a few hours, I got the solution.  You will make the new binary from source, thus no more COMPACT 6 in kernel configuration.

在VMware ESXi 5 update 1安裝vmware tools有不少問題,經過幾個小時的奮戰,終於找到答案。
首先要強調,不需要在Kernel設COMPACT 6,但是需要裝compact6x的package。以下用藍色標明需要key的指令:
  1. Install compact6x package
    #cd /usr/ports/misc/compat6x
    #make install clean
  2. Mount the cdrom image from vCenter/vSphere Client to guest vm.
    #mount -t cd9660 -o ro /dev/cd0 /mnt
    若你已經試著裝過,cd0 可能會變成acd0,就改成
    #mount  -t cd9660 -o ro /dev/acd0 /mnt
  3. Extract the source code.
    #cd /root && tar xzf /mnt/vmware-freebsd-tools.tar.gz 
    #cd vmware-tools-distriblib/modules/source
    #tar xf vmblock.tar && tar xf vmmemctl.tar && tar xf vmxnet.tar && tar xf vmxnet3.tar
  4. Compile the vmblock module.
    #cd vmblock-only
    #make && make install & cd ..
  5. Compile the vmmemctl module
    #cd vmmemctl-only
    #make && make install && cd ..
  6. Compile the vmxnet module
    #cd vmxnet-only
    Get the patch.  Update: ESXi 5.1 doesn't need this patch. 已經不需要patch.
    #fetch http://ogris.de/vmware/vmxnet.diff  # Not needed for ESXi 5.1
    #patch -p1 < vmxnet.diff  # Not needed for ESXi 5.1
    #make && make install && cd ..
  7. Compile the vmxnet3 module
    #cd vmxnet3-only
    Get the patch. Update: ESXi 5.1 doesn't need this patch. 已經不需要patch.
    #fetch http://ogris.de/vmware/vmxnet3.diff # Not needed for ESXi 5.1
    #patch -p1 < vmxnet3.diff  # Not needed for ESXi 5.1
    #make && make install && cd ..
  8. Install the vmware tools, it you don't have perl then you have to install one from ports.
    接下來要安裝vmware tools,若沒有安裝Perl則必須從ports選個版本安裝。
    #cd /root/vmware-tools-distrib
    #./vmware-install.pl
  9. Finally, halt the vm. Change network adapter to "VMXNET 3", then boot the vm.
    最後,VM關機。將網路卡換成VMXNET 3,重開機。
    You will see vmx3f0 instead of em0, replace it in /etc/rc.conf.
    會看到vmx3f0而不是em0,所以在/etc/rc.conf也要對應修改。

網路從1000Mbase-T變成10Gbase-T,再來看載入了哪些modules,輸入kldstat

最後看看狀態

會需要patch的原因是FreeBSD 9將ifnet中的watchdog/timer架構分離出來,所以已經沒有if_watchdog和if_timer。最好還是VMware自己更新FreeBSD tools,以上的patch只是將watchdog和timer的呼叫從module中移除(我本來也有考慮這麼幹),不知道會不會因此穩定度降低?若有疑問的朋友還是繼續用E1000網卡。(這需要瞭解FreeBSD kernel的朋友踹共)

另一個方法是直接從ports安裝 open-vm-tools ,但是沒看到vmxnet3的ko,應該是只有支援vmxnet,而且還會安裝fuse和glib。若想用 open-vm-tools ,記得不能用LLVM clang編譯,只能用gcc。

參考資料:
VMware 虛擬化技術實務問答 (上)
VMware_Tools_安裝
Choosing a network adapter for your virtual machine
Installing VMware Tools on FreeBSD 9
VMware Tools on FreeBSD 9.0 patch

沒有留言: