FreeBSD Bhyve
準備工作 vm-bhyve $ pkg install vm-bhyve-devel uefi-edk2-bhyve-csm bhyve-firmware vm pool $ zfs create -o mountpoint=/vm zroot/vm /etc/rc.conf vm_enable="YES" vm_dir="zfs:zroot/vm" vm_list="" #開機自動啟動的VM vm_delay=3 /boot/loader.conf #PCI Passtrough vmm_load="YES" #pptdevs="3/0/0 3/0/1" #GPU Passthrough init $ vm init 網路 $ vm switch create public $ vm switch add public 網卡代號 安裝VM ISO位置 $ vm iso ISO位置 $ vm iso DATASTORE FILENAME default Win11_23H2_English_x64v2.iso default windows.iso 設定檔 範例在 /usr/local/share/examples/vm-bhyve 裡,選擇要安裝的系統, 複製一份到 /vm/.templates/ 下 修改設定檔 以Windows為例 # If you want to pull a graphical console, you'll need the UEFI loader, # no matter what OS you're installing on the guest. loader="uefi" graphics="yes" xhci_mouse="yes" # If not specified, cpu=n will give the guest n discrete CPU sockets. # This is generally OK for Linux or BSD guests, but Windows throws a fit # due to licensing issues, so we specify CPU topology manually here. cpu=8 cpu_sockets=2 cpu_cores=4 cpu_threads=1 # Remember, a guest doesn’t need extra RAM for filesystem caching-- # the host handles that for it. 4G is ludicrously low for Windows on hardware, # but it’s generally more than sufficient for a guest. memory=8G # put up to 8 disks on a single ahci controller. This avoids the creation of # a new “controller” on a new “PCIe slot” for each drive added to the guest. ahci_device_limit="8" # e1000 works out-of-the-box, but virtio-net performs better. Virtio support # is built in on FreeBSD and Linux guests, but Windows guests will need # to have virtio drivers manually installed. #network0_type="e1000" network0_type="virtio-net" network0_switch="public" # bhyve/nvme storage is considerably faster than bhyve/virtio-blk # storage in my testing, on Windows, Linux, and FreeBSD guests alike. disk0_type="nvme" disk0_name="disk0.img" # This gives the guest a virtual "optical" drive. Specifying disk1_dev=”custom” # allows us to provide a full path to the ISO. disk1_type="ahci-cd" disk1_dev="custom" disk1_name="/vm/virtio-win.iso" # windows expects the host to expose localtime by default, not UTC utctime="no" graphics_port="5900" graphics_listen="本機地址 x.x.x.x" graphics_res="1024x768" graphics_wait="yes" vnc_password="123456" 其中網路卡設定為virtio-net,這樣安裝Windows過程中就不會要求登入M$帳戶, ...