前言
目前 FreeBSD 最新版本為 10,剛好最近有 VM 虛擬主機要安裝 FreeBSD 的需求。當然,VM 虛擬主機裝好的第一件事是安裝 VMware Tools,但是卻遇到困難。本文便是記錄目前過渡期的解決方式。因為從 VMware KB 2059649 - vmware-toolbox-cmd fails on FreeBSD 8.4 and 9.2 (32-bit) operating system 文章中,已經很明確的說明了,在 VMware vSphere ESXi 5.5 當中「僅能」運作「FreeBSD 8.4 (64-bit) or 9.0 (32-bit or 64-bit) or 9.1 (32-bit)」。
實作環境
- VMware vSphere ESXi 5.5 (1331820)
- FreeBSD 10
安裝及設定
以下將說明若在 VMware vSphere ESXi 5.5 平台上,VM 虛擬主機安裝 FreeBSD 10 時二種解決方式:- 解決方式一、安裝由熱血人士 Ogris 所撰寫的 Patch 檔案,再進行安裝即可順利安裝。
- 解決方式二、安裝 Open Virtual Machine Tools。
採用 Ogris 撰寫的 Patch 檔案
當你安裝 FreeBSD 10 時指派「vmxnet3」網路卡,安裝後你將發現可以順利識別並且也是可以運作的。# dmesg |grep vmx
vmx0: <VMware VMXNET3 Ethernet Adapter> port 0x4000-0x400f mem 0xfd5fb000-0xfd5fbfff,0xfd5fc000-0xfd5fcfff,0xfd5fe000-0xfd5fffff irq 18 at device 0.0 on pci3
vmx0: Ethernet address: 00:0c:29:bb:f4:7f
確認網路功能正常後,請先安裝需求套件以便後續能順利安裝 VMware Tools。
# cd /usr/ports/lang/perl5.18
# make install clean
# cd /usr/ports/misc/compat6x/
# make install clean
掛載 VMware Tools,開啟 vSphere Client >> 開啟 Console >> 選擇【VM \ Guest \ Install/Upgrade VMware Tools】掛載相對應的 ISO 檔給 VM 平台。
# mount -t cd9660 /dev/cd0 /media
# df -h
Filesystem Size Used Avail Capacity Mounted on
/dev/da0p2 18G 2.4G 14G 14% /
devfs 1.0K 1.0K 0B 100% /dev
/dev/cd0 15M 15M 0B 100% /media
# cp /media/vmware-freebsd-tools.tar.gz /tmp/
# umount /media
你必須下載 Ogris 所撰寫的 Patch 檔案,否則稍後安裝 VMware Tools 時將會發生如下錯誤訊息:
Starting VMware Tools services in the virtual machine:
Switching to guest configuration: done
Guest memory manager: failed
Guest operating system daemon: done
Unable to start services for VMware Tools
Execution aborted.
切換到 /tmp 路徑後,下載 Ogris 所撰寫的 Patch 檔案。
# cd /tmp/
# fetch http://ogris.de/vmware/vmware-tools-distrib.diff
vmware-tools-distrib.diff 100% of 1681 B 22 MBps 00m00s
# fetch http://ogris.de/vmware/vmblock-only.diff
vmblock-only.diff 100% of 1004 B 13 MBps 00m00s
# fetch http://ogris.de/vmware/vmmemctl-only.diff
vmmemctl-only.diff 100% of 675 B 9277 kBps 00m00s
# fetch http://ogris.de/vmware/vmmemctl-only55.diff
vmmemctl-only55.diff 100% of 1189 B 16 MBps 00m00s
相關修正檔案下載完畢後,便先執行相關修正程序後才進行安裝。
# cd /tmp/vmware-tools-distrib
# patch -p1 < /tmp/vmware-tools-distrib.diff
# cd lib/modules/source/
# tar xf vmblock.tar
# tar xf vmmemctl.tar
# cd vmblock-only
# patch -p1 < /tmp/vmblock-only.diff
# make
# make install
# cd ../vmmemctl-only
# patch -p1 < /tmp/vmmemctl-only55.diff
# make
# make install
# cd /tmp/vmware-tools-distrib
# ./vmware-install.pl
...略...
Starting VMware Tools services in the virtual machine:
Switching to guest configuration: done
Guest memory manager: done
Guest operating system daemon: done
...略...
to use the vmxnet interface using DHCP.
Enjoy,
--the VMware team
# reboot
順利將 FreeBSD 10 重新啟動後,進行相關確認動作。
# /usr/local/sbin/vmware-checkvm -h
VM's hw version is 4
VMware software version 6 (good)
# kldstat
Id Refs Address Size Name
1 3 0xffffffff80200000 15f0310 kernel
2 1 0xffffffff81a12000 2108 vmmemctl.ko
但是,此時在 vSphere Client 端看到此台 VM 虛擬主機的 VMware Tools 欄位狀態,其值為「Running (Not installed)」而非「Running (Current)」。
安裝 Open Virtual Machine Tools
如果你擔心所下載的修正檔被人偷加料,或者其它安全因素考量,那麼你可以下載 Open Virtual Machine Tools 進行安裝即可,只要確認 FreeBSD 10 虛擬主機的網路功能正常,執行如下指令即可完成安裝動作。# pkg install open-vm-tools-nox11
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y
Bootstrapping pkg from pkg+http://pkg.FreeBSD.org/freebsd:10:x86:64/latest, please wait...
...略...
The installation will require 214 MB more space
42 MB to be downloaded
Proceed with installing packages [y/N]: y
...略...
Checking integrity... done
[1/10] Installing libdnet-1.11_3... done
[2/10] Installing pcre-8.34... done
[3/10] Installing icu-52.1... done
[4/10] Installing gettext-0.18.3.1... done
[5/10] Installing perl5-5.16.3_9... done
...略...
*******************************************************************
To run the Open Virtual Machine tools at startup, add the following
settings to your /etc/rc.conf
vmware_guest_vmblock_enable="YES"
vmware_guest_vmhgfs_enable="YES"
vmware_guest_vmmemctl_enable="YES"
vmware_guest_vmxnet_enable="YES"
vmware_guestd_enable="YES"
*******************************************************************
在安裝完成後,很貼心的提醒你必須記得在「/etc/rc.conf」加上相關參數,以便啟用功能與 VMware vSphere ESXi 虛擬化平台整合。
# vi /etc/rc.conf
vmware_guest_vmblock_enable="YES"
vmware_guest_vmhgfs_enable="YES"
vmware_guest_vmmemctl_enable="YES"
vmware_guest_vmxnet_enable="YES"
vmware_guestd_enable="YES"
# reboot
順利將 FreeBSD 10 重新啟動後,進行相關確認動作。
# kldstat
Id Refs Address Size Name
1 10 0xffffffff80200000 15f0310 kernel
2 1 0xffffffff81a12000 2198 vmmemctl.ko
3 1 0xffffffff81a15000 23d8 vmxnet.ko
4 1 0xffffffff81a18000 2bf0 vmblock.ko
5 1 0xffffffff81a1b000 81b4 vmhgfs.ko
但是,此時在 vSphere Client 端看到此台 VM 虛擬主機的 VMware Tools 欄位狀態,其值為「Running(3rd-party/Independent)」而非「Running (Current)」。