23.4.使用 VirtualBox™ 安装 FreeBSD

FreeBSD 作为客户机操作系统在 VirtualBox™ 中表现良好。该虚拟化软件可用于大多数常见的操作系统,包括 FreeBSD。

VirtualBox™ 客户机额外提供如下支持:

  • 同步剪切板。
  • 整合鼠标指针。
  • 同步宿主机时间。
  • 窗口缩放。
  • 无缝模式。

注意

请在 FreeBSD 客户机中执行下文命令。

首先,在 FreeBSD 客户机中安装 virtualbox-ose-additionsopen in new window。可以通过软件包或者 port 安装。以 port 为例:

# cd /usr/ports/emulators/virtualbox-ose-additions && make install clean

然后在 /etc/rc.conf 中添加如下内容:

vboxguest_enable="YES"
vboxservice_enable="YES"

如果使用了 ntpd(8)open in new window 或者 ntpdate(8)open in new window,可禁用宿主机时间同步:

vboxservice_flags="--disable-timesync"

Xorg 会自动识别 vboxvideo 驱动。也可以在 /etc/X11/xorg.conf 中手动指定:

Section "Device"
	Identifier "Card0"
	Driver "vboxvideo"
	VendorName "InnoTek Systemberatung GmbH"
	BoardName "VirtualBox Graphics Adapter"
EndSection

若要使用 vboxmouse 驱动,请在 /etc/X11/xorg.conf 中修改鼠标部分配置:

Section "InputDevice"
	Identifier "Mouse0"
	Driver "vboxmouse"
EndSection

HAL 输入设备用户应该创建如下所示的 /usr/local/etc/hal/fdi/policy/90-vboxguest.fdi,或者从 /usr/local/share/hal/fdi/policy/10osvendor/90-vboxguest.fdi 复制文件至上述目录:

<?xml version="1.0" encoding="utf-8"?>
<!--
# Sun VirtualBox
# Hal driver description for the vboxmouse driver
# $Id: chapter.xml,v 1.33 2012-03-17 04:53:52 eadler Exp $

	Copyright (C) 2008-2009 Sun Microsystems, Inc.

	This file is part of VirtualBox Open Source Edition (OSE, as
	available from http://www.virtualbox.org. This file is free software;
	you can redistribute it and/or modify it under the terms of the GNU
	General Public License (GPL) as published by the Free Software
	Foundation, in version 2 as it comes in the "COPYING" file of the
	VirtualBox OSE distribution. VirtualBox OSE is distributed in the
	hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.

	Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
	Clara, CA 95054 USA or visit http://www.sun.com if you need
	additional information or have any questions.
-->
<deviceinfo version="0.2">
  <device>
    <match key="info.subsystem" string="pci">
      <match key="info.product" string="VirtualBox guest Service">
        <append key="info.capabilities" type="strlist">input</append>
	<append key="info.capabilities" type="strlist">input.mouse</append>
        <merge key="input.x11_driver" type="string">vboxmouse</merge>
	<merge key="input.device" type="string">/dev/vboxguest</merge>
      </match>
    </match>
  </device>
</deviceinfo>

使用 mount_vboxvfs 来挂在用于在宿主和虚拟机之间传输文件的共享文件夹。共享文件夹可以在宿主机上通过 VirtualBox 的图形界面或者 vboxmanage 工具创建。例如,要为虚拟机 BSDBox 创建一个名为 myshare 的共享文件夹,其位于 /mnt/bsdboxshare,请执行:

# vboxmanage sharedfolder add 'BSDBox' --name myshare --hostpath /mnt/bsdboxshare

请注意共享文件夹名称中不能包含空格。要在客户机中挂载这个共享文件夹,请执行:

# mount_vboxvfs -w myshare /mnt
Loading...