尧图网站建设 尧图网络
  • 首页
  • 关于我们
  • 服务项目
  • 案例展示
  • 建站流程
  • 资讯中心
  • 联系我们
首页/资讯中心/详情

VirtualBox上安装FreeBSD

VirtualBox上安装FreeBSD
📅 发布时间:2026/7/15 6:43:10

环境

Windows操作系统,VirtualBox Version 7.1.8 r168469 (Qt6.5.3)。想安装FreeBSD操作系统。

下载介质

FreeBSD官网提供虚机下载。

虚机提供多种格式,一定要先读README:

FreeBSD virtual machine disk images are available in various formats for several hypervisors. Disk image formats and the supported hypervisors are: vhd: VirtualPC, Hyper-V, Xen, VirtualBox vmdk: VMWare qcow2: Qemu, KVM raw: bhyve, other hypervisors that support unformatted raw disk image

因为我的VMM是VirtualBox,所以要下载vhd格式。

我选择的是FreeBSD 14.4版本,即使是vhd格式,也有3个文件可供下载:

  • FreeBSD-14.4-RELEASE-amd64-ufs.vhd.xz(经典安装)
  • FreeBSD-14.4-RELEASE-amd64-zfs.vhd.xz (企业级安装,ZFS包括快照等功能)
  • FreeBSD-14.4-RELEASE-amd64.vhd.xz (默认安装)

最终我选择的是默认安装。文件大小为600M:

$ls-1sh*.xz 605M FreeBSD-14.4-RELEASE-amd64.vhd.xz

创建虚机

解压下载的文件,Windows下可以用7zip,解压后2.5G。

$ls-1sh*.vhd2.5G FreeBSD-14.4-RELEASE-amd64.vhd

启动VirtualBox,选择’New’创建虚机:

设定VM Name,OS选择BSD:

内存配置为默认的1G:

然后展开Specify Virtual hardware,在Specify virtual hard disk下,选择Use an Existing Virtual Hard Disk File:

这个新的磁盘还不存在,需要通过Add添加:

磁盘大小为6.03G:

💡 使用已有磁盘时,也可以先把磁盘移动到比较规范的位置,如C:\Users\XiaoYu\VirtualBox VMs\FreeBSD。

扩容虚拟磁盘

其实这是事后才知道的。因为后续安装VirtualBox Guest Addition需要2G多的空间。

此时先不要启动虚机,因为虚拟磁盘的大小只有在关机时才能修改。

进入菜单File>Tools>Media,将磁盘的Virtual Size修改为10G。

启动虚机

启动FreeBSD,用户名输入root,口令回车即可:

当前空间状态:

root@freebsd:~# df -hFilesystem Size Used Avail Capacity Mounted on /dev/gpt/rootfs8.7G2.4G5.6G30% / devfs1.0K 0B1.0K0% /dev /dev/gpt/efiesp 32M 649K 31M2% /boot/efi

rootfs不到9G,因为还有1G的swap。

root@freebsd:~# gpart show -l ada0=>3420971446ada0 GPT(10G)341221bootfs(61K)156665842efiesp(33M)6674020971523swapfs(1G)2163892188075884rootfs(9G)

配置SSH登录

我们把配置SSH放在第一步,是因为终端字符界面太丑了,而且也没法拷贝粘贴。

配置sshd,允许root登录:

vi/etc/ssh/sshd_config PermitRootLoginyes

配置和启动sshd服务:

sysrcsshd_enable="YES"servicesshd start

为root用户设置口令:

passwdroot

为虚机配置port forwarding,例如将宿主机的8822端口映射为客户机的22端口。

然后PuTTY ssh登录成功,也可以拷贝粘贴了:

安装VirtualBox Guest Additions

先更新系统:

pkg update-f

输出如下:

root@freebsd:~# pkg update -fThe package management tool is not yet installed on your system. Do you want to fetch andinstallit now?[y/N]: y Bootstrapping pkg from pkg+https://pkg.FreeBSD.org/FreeBSD:14:amd64/quarterly, please wait... Verifying signature with trusted certificate pkg.freebsd.org.2013102301...doneInstalling pkg-2.7.5... Extracting pkg-2.7.5:100% Updating FreeBSD repository catalogue... Fetching meta.conf:100%179B0.2kB/s 00:01 Fetching data:100%11MiB1.2MB/s 00:09 Processing entries:100% FreeBSD repository update completed.37777packages processed. Updating FreeBSD-kmods repository catalogue... Fetching meta.conf:100%179B0.2kB/s 00:01 Fetching data:100%36KiB37.0kB/s 00:01 Processing entries:100% FreeBSD-kmods repository update completed.245packages processed. All repositories are up to date.

更新后空间状态,只用了0.1G:

root@freebsd:~# df -h /Filesystem Size Used Avail Capacity Mounted on /dev/gpt/rootfs8.7G2.5G5.5G31% /

然后安装VirtualBox Guest Additions:

pkginstall-yvirtualbox-ose-additions

日志如下:

root@freebsd:~# pkg install -y virtualbox-ose-additionsUpdating FreeBSD repository catalogue... FreeBSD repository is up to date. Updating FreeBSD-kmods repository catalogue... FreeBSD-kmods repository is up to date. All repositories are up to date. Updating database digests format:100% The following60package(s)will be affected(of0checked):... Number of packages to be installed:60The process will require2GiBmorespace.364MiB to be downloaded.... Checking integrity...done(0conflicting)...===>CreatinggroupsCreating group'messagebus'with gid'556'===>CreatingusersCreating user'messagebus'with uid'556'... VirtualBox Guest Additions are installed. Toenableand start the required services:# sysrc vboxguest_enable="YES"# sysrc vboxservice_enable="YES"To start the services, restart the system. In some situations, a panic will occur when the kernel module loads. Having nomorethan one virtual CPU might mitigate the issue. For features such as window scaling and clipboard sharing, membership of the wheel group is required. With username"jerry"as an example:# pw groupmod wheel -m jerryThe settings dialogueforFreeBSD guests encourages use of the VMSVGA graphics controller. Whilst this might suit installations of FreeBSD without a desktop environment(a common usecase), it is not appropriate where Guest Additions are installed. Where Guest Additions are installed:1. prefer VBoxSVGA2.donotenable3D acceleration(doing so will invisibly lose the preferenceforVBoxSVGA)You may ignore the yellow alert that encourages use of VMSVGA. --===>NOTICE: This port is deprecated;you may wish to reconsider installing it: Upstream EOL reaches on2024-01-31, use emulators/virtualbox-ose-additions-72 instead. It is scheduled to be removed on or after2026-12-31.

从输出可知,此安装需要至少2 GiB 空间,这也是之前我们需要扩容的原因。

当前空间,没想到安装Guest Addition使用了2.7G:

root@freebsd:~# df -h .Filesystem Size Used Avail Capacity Mounted on /dev/gpt/rootfs8.7G5.2G2.8G65% /

根据上面命令输出的提示,需要将virtualbox-ose-additions更新为virtualbox-ose-additions-72。
很快就完成了,空间几乎没变:

# pkg install -y virtualbox-ose-additions-72# pkg info | grep virtualbox-ose-additionsvirtualbox-ose-additions-72-7.2.12.1404000 VirtualBox additionsforFreeBSD guests

设置服务并重启系统:

sysrcvboxguest_enable="YES"sysrcvboxservice_enable="YES"

确认服务正常,以及模块已加载:

# service vboxservice statusvboxservice is running as pid766.# kldstat | grep vboxguest420xffffffff8281f000 36b40 vboxguest.ko

配置主机客户机共享目录

在virtualbox中创建共享目录,例如名称为Downloads:

配置共享目录后,需重启才能生效。

确认共享文件系统的模块已加载,注意最新的模块名为vboxvfs,而非vboxsf了:

# find /boot -name "*.ko" | grep -i vbox/boot/modules/vboxvfs.ko /boot/modules/vboxguest.ko# kldload vboxvfs# kldstat | grep vbox420xffffffff8281f000 38d00 vboxguest.ko510xffffffff82858000 26bd1 vboxvfs.ko

然后挂载共享文件系统:

# mount_vboxvfs Downloads /mnt/share# df -h /mnt/shareFilesystem Size Used Avail Capacity Mounted on Downloads 237G 190G 48G80% /mnt/share

相关新闻

  • Claude Code CLI 无缝桥接 Kimi K2.5 实践指南
  • 影刀RPA 应用市场的子流程复用:别人的轮子怎么安全地用
  • Qt绘图系统:从QPainter基础到高级渲染机制

最新新闻

  • 66AK2G12时钟与接口时序设计:从PLL配置到GPMC同步模式实战
  • 2026 年更新:罗湖口碑好的市政管道维修团队施工公司有哪些,别信免费通沟!这帮穿黄马甲的暗中藏着一套让下水道不堵的黑科技 - 领域鉴赏官
  • 2026汽车托运服务有哪些实力之选,十大品牌深度测评不花冤枉钱 - mypinpai
  • 如何快速上手xnbcli:星露谷物语资源处理的终极指南
  • Windows 11终极优化指南:用Win11Debloat让你的系统焕然一新
  • ArkUI-X 1.0.0 Release:跨平台开发新纪元,从入门到部署全解析

日新闻

  • 告别启动盘残留:用Diskpart彻底清除U盘EFI分区与恢复完整空间
  • 2026 年宜春诚信的塑料缠绕膜厂家哪个好,缠绕膜背后的秘密:你不知道的成本陷阱 - 领域鉴赏官
  • Arch ECS 入门指南:10分钟掌握C#高性能数据驱动架构

周新闻

  • IX9104 PCIe5.0 高速交换芯片@ACP#完整规格 + 应用场景总结
  • Unity游戏集成Coze智能体:实现NPC智能对话与知识库联动
  • SAP EPIC 建行回单查询:从标准类CL_EPIC_EXAMPLE_CN_CCB_GHTD到Z类的5处关键修改

月新闻

  • 2026年6月公司网站搭建最新热门渠道测评:四大低成本/零代码平台对比+避坑
  • 【Linux】Linux arm 编译QT程序,出现expected “}“报错
  • 【MATLAB例程】四基站二维AOA定位与距离辅助增强对比仿真。基于角度观测和测距修正的固定目标平面定位精度分析

关于尧图

  • 公司简介
  • 团队介绍
  • 企业文化
  • 荣誉资质

服务项目

  • 定制开发
  • 电商建站
  • UI 设计
  • 运维服务

快速链接

  • 案例展示
  • 建站流程
  • 常见问题
  • 资讯中心

联系方式

  • 📍北京市朝阳区互联网产业园 A 座 10 层
  • 📞400-888-8888
  • ✉️contact@rkmt.cn
  • 🕐周一至周日 9:00-21:00

© 2024 北京尧图网络科技有限公司 版权所有 | 京 ICP 备 XXXXXXXX 号