我有一个包含 /boot/loader* 和 /boot/kernel 的 FreeBSD 镜像。在 EC2 实例下它可以正常启动,但是我希望能在 Qemu 中启动它。我尝试了各种方法,但都没有成功。请看下面的内容。
qemu-system-x86_64 -kernel kernel -nographic -append 'console=ttyS0' disk.img
qemu-system-x86_64 -kernel loader -nographic -append disk.img
我有一个包含 /boot/loader* 和 /boot/kernel 的 FreeBSD 镜像。在 EC2 实例下它可以正常启动,但是我希望能在 Qemu 中启动它。我尝试了各种方法,但都没有成功。请看下面的内容。
qemu-system-x86_64 -kernel kernel -nographic -append 'console=ttyS0' disk.img
qemu-system-x86_64 -kernel loader -nographic -append disk.img
这可以在Ubuntu 20.04 amd64主机上启动,使用的是QEMU 4.2.1:
wget https://download.freebsd.org/ftp/releases/VM-IMAGES/12.1-RELEASE/amd64/Latest/FreeBSD-12.1-RELEASE-amd64.qcow2.xz
unxz FreeBSD-12.1-RELEASE-amd64.qcow2.xz
sudo apt install qemu-system-x86
qemu-system-x86_64 -drive file=FreeBSD-12.1-RELEASE-amd64.qcow2,format=qcow2 -enable-kvm
用户名为root
,密码为空:
该镜像的下载页面为:https://www.freebsd.org/where.html
不幸的是,试图添加:
-serial mon:stdio -nographic
仅显示引导映像,而不是整个启动过程。 https://lists.freebsd.org/pipermail/freebsd-hackers/2005-March/011051.html 提到了通过修改映像来解决这个问题,虽然有点麻烦,但确实有效。在GUI启动时,我执行了以下操作:echo 'console="comconsole"' > /boot/loader.conf
然后下一次无图形启动在我的终端上完全运行。
您可以像这里所示,使用Ctrl-A X
退出QEMU的-nographic
模式。
接下来的问题是磁盘已满,我必须学会如何增加其大小。通过交互式的df -Th
检查,镜像似乎包含一个单独的原始UFS分区。我尝试了:
qemu-img resize FreeBSD-12.1-RELEASE-amd64.qcow2 +1G
但是这并不足够,可能是因为分区本身没有被调整大小以适应磁盘。 可以使用gpart
来实现这一点,如在https://www.freebsd.org/doc/handbook/disks-growing.html中所示,但我现在没有耐心。