注意,如果你运行的是比 Windows 10 更早的 Windows 版本,你将需要使用 disk0_opts="sectorsize=512" 选项将磁盘扇区大小设置为 512。 当你想在 Windows 系统上安装 Microsoft SQL Server 时,你也必须将磁盘扇区大小设置为 512。
根据模板创建 windows 虚拟机,磁盘占用 50GB:
# vm create -t windows -s 50G winguest
销毁虚拟机的命令:
root@ykla:/usr/home/ykla # vm destroy winguest
Are you sure you want to completely remove this virtual machine (y/n)? Are you sure you want to completely remove this virtual machine (y/n)? #这里输入 y 回车即可删除
loader="uefi" #不支持 UEFI 的 windows 不能够启动,例如 XP 操作系统,但是请注意 win7 是支持 UEFI 的
graphics="yes" #指定暂停虚拟机直至 VNC 链接。
xhci_mouse="yes"
cpu=2 #CPU,这个最好多给一些
memory=4G #内存
# put up to 8 disks on a single ahci controller.
# without this, adding a disk pushes the following network devices onto higher slot numbers,
# which causes windows to see them as a new interface
ahci_device_limit="8"
# ideally this should be changed to virtio-net and drivers installed in the guest
# e1000 works out-of-the-box
network0_type="e1000" #开箱即用的虚拟网卡
network0_switch="public" #虚拟交换机
disk0_type="ahci-hd"
disk0_name="disk0.img"
# windows expects the host to expose localtime by default, not UTC
utctime="no" #指定 windows 使用 UTC 时间,避免时间差 8 个小时
graphics_res="1024x768" #指定 VNC 链接的屏幕分辨率,可用数值在下文列出
uuid="af86e094-56da-11ed-958f-208984999cc9"
network0_mac="58:9c:fc:0c:5e:bb"
root@ykla:/usr/home/ykla #
终止虚拟机:
如果虚拟机卡死该命令无效,请自行 kill -9 以免影响关机,如果真的阻碍了物理机关机,可以在 tty 按 Ctrl+ C 跳过等待虚拟机,强制关机
root@ykla:/usr/home/ykla # vm stop winguest
Sending ACPI shutdown to winguest
安装系统
通过指定 Windows iso 文件开始正常的安装。当在安装模式下运行时,vm-bhyve 将等待,直到 VNC 客户端连接后再启动客户机。这允许你抓住 Windows 可能显示的“从 CD/DVD 启动“选项。你可以在 vm list 中看到,在这一点上,客户机将显示为锁定:
tap0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
description: vmnet/winguest/0/public
options=80000<LINKSTATE>
ether 58:9c:fc:10:ff:d6
groups: tap vm-port
media: Ethernet autoselect
status: active
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
Opened by PID 2519