22.4.使用 VirtualBox™ 安装 FreeBSD

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

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

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

提示

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

首先,在 FreeBSD 客户机中安装 virtualbox-ose-additions。可以通过 package 或者 port 安装。以 port 为例:

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

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

  1. vboxguest_enable="YES"
  2. vboxservice_enable="YES"

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

  1. vboxservice_flags="--disable-timesync"

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

  1. Section "Device"
  2. Identifier "Card0"
  3. Driver "vboxvideo"
  4. VendorName "InnoTek Systemberatung GmbH"
  5. BoardName "VirtualBox Graphics Adapter"
  6. EndSection

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

  1. Section "InputDevice"
  2. Identifier "Mouse0"
  3. Driver "vboxmouse"
  4. EndSection

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

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!--
  3. # Sun VirtualBox
  4. # Hal driver description for the vboxmouse driver
  5. # $Id: chapter.xml,v 1.33 2012-03-17 04:53:52 eadler Exp $
  6. Copyright (C) 2008-2009 Sun Microsystems, Inc.
  7. This file is part of VirtualBox Open Source Edition (OSE, as
  8. available from http://www.virtualbox.org. This file is free software;
  9. you can redistribute it and/or modify it under the terms of the GNU
  10. General Public License (GPL) as published by the Free Software
  11. Foundation, in version 2 as it comes in the "COPYING" file of the
  12. VirtualBox OSE distribution. VirtualBox OSE is distributed in the
  13. hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
  14. Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
  15. Clara, CA 95054 USA or visit http://www.sun.com if you need
  16. additional information or have any questions.
  17. -->
  18. <deviceinfo version="0.2">
  19. <device>
  20. <match key="info.subsystem" string="pci">
  21. <match key="info.product" string="VirtualBox guest Service">
  22. <append key="info.capabilities" type="strlist">input</append>
  23. <append key="info.capabilities" type="strlist">input.mouse</append>
  24. <merge key="input.x11_driver" type="string">vboxmouse</merge>
  25. <merge key="input.device" type="string">/dev/vboxguest</merge>
  26. </match>
  27. </match>
  28. </device>
  29. </deviceinfo>

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

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

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

  1. # mount_vboxvfs -w myshare /mnt