在远程FreeBSD服务器上运行VirtualBox

• 本文约 401 字,阅读大致需要 1 分钟 | Distributed Computing | #VirtualBox | #FreeBSD | #Virtualization | #X11 forwarding | #remote access

📜 历史文件已不具备现实意义

现时提倡的安装方式为pkg,本文并未对此进行更新。

VirtualBox可以在远程运行,并把界面通过ssh的X11转发放到管理员的桌面。

FreeBSD 上可以用port来安装VirtualBox:

portsnap fetch update
cd /usr/ports/emulators/virtualbox-ose
make install clean

接着配置VirtualBox所需要的内核模块:

echo 'vboxdrv_load="YES"' >> /boot/loader.conf
echo 'vboxnet_enable="YES"' >> /etc/rc.conf.local

将需要使用VirtualBox的用户添加到vboxusers组:

pw groupmod vboxusers -m delphij

安装xauth:

cd /usr/ports/x11/xauth
make install clean

重启系统,或手工加载模块之后,就可以从远程ssh进来运行VirtualBox了:

desktop% ssh -Y vsvc.example.com # 【注1】
vsvc% VirtualBox

VirtualBox的管理界面会出现在客户端系统上(当然,在列出文件时仍然是服务器端的文件)。

在安装、调试之后,就可以用VBoxHeadless来启动远程的虚拟机了。

【注1】这里使用的是"Trusted Forwarding",如果远程主机不可信,这样做会提高安全风险。