24.4.使用 VirtualBox™ 安装 FreeBSD

FreeBSD 在 VirtualBox™ 中作为虚拟机运行效果良好。该虚拟化软件可在大多数常见操作系统上运行,包括 FreeBSD 本身。

VirtualBox™ 的虚拟机增强功能提供以下支持:

  • 剪贴板共享。

  • 鼠标指针集成。

  • 宿主时间同步。

  • 窗口缩放。

  • 无缝模式。

注意

以下命令在 FreeBSD 虚拟机中执行。

首先,在 FreeBSD 虚拟机中安装 emulators/virtualbox-ose-additions 软件包或 Ports。这将安装该 Ports:

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

/etc/rc.conf 中添加以下内容:

vboxguest_enable="YES"
vboxservice_enable="YES"

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

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

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

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

注意,共享文件夹名称不得包含空格。在虚拟机系统中挂载共享文件夹的命令如下:

# mount_vboxvfs -w myshare /mnt

最后更新于