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$帳戶, ...

March 18, 2024

Freebsd Graphics

支援顯卡 參考FreeBSD官網支援列表 https://wiki.freebsd.org/Graphics/AMD-GPU-Matrix 如果FreeBSD 13+ 安裝 drm-510-kmod,FreeBSD 14+ 安裝 drm-515-kmod 在rc.conf 加上 kld_list="radeonkms" ##amd舊顯卡,參考官網列表 Firmware 手動載入後,發現錯誤 [drm] radeon kernel modesetting enabled. drmn0: <drmn> on vgapci0 vgapci0: child drmn0 requested pci_enable_io vgapci0: child drmn0 requested pci_enable_io sysctl_warn_reuse: can't re-use a leaf (hw.dri.debug)! [drm] initializing kernel modesetting (CAICOS 0x1002:0x6779 0x1642:0x3A75 0x00). [drm ERROR :radeon_atombios_init] Unable to find PCI I/O BAR; using MMIO for ATOM IIO ATOM BIOS: C26402 drmn0: VRAM: 1024M 0x0000000000000000 - 0x000000003FFFFFFF (1024M used) drmn0: GTT: 1024M 0x0000000040000000 - 0x000000007FFFFFFF [drm] Detected VRAM RAM=1024M, BAR=256M [drm] RAM width 64bits DDR [drm] radeon: 1024M of VRAM memory ready [drm] radeon: 1024M of GTT memory ready. [drm] Loading CAICOS Microcode drmn0: could not load firmware image 'radeon/CAICOS_pfp.bin' ni_cp: Failed to load firmware "radeon/CAICOS_pfp.bin" [drm ERROR :evergreen_init] Failed to load firmware! drmn0: Fatal error during GPU init [drm] radeon: finishing device. [drm] radeon: ttm finalized Warning: can't remove non-dynamic nodes (dri)! device_attach: drmn0 attach returned 2 安裝firmware ...

September 12, 2023

FreeBSD Make World

Update src tree git clone https://git.freebsd.org/src.git /usr/src git checkout releng/x.x 查看可用Branch git branch -r 更新 git pull git status 記錄一下更新所需時間 FreeBSD 13.2-RELEASE releng/13.2-525ecfdad Welcome to FreeBSD! ``` ` ` `.....---.......--.``` -/ ------- +o .--` /y:` +. OS: FreeBSD 13.2-RELEASE amd64 yo`:. :o `+- Uptime: 1 day, 29 mins y/ -/` -o/ Packages: 187 (pkg) .- ::/sy+:. Terminal: /dev/pts/0 / `-- / CPU: Intel Xeon E5-2690 v4 (28) @ 2.594GHz [32.0°C] `: :` GPU: Caicos [Radeon HD 6450/7450/8450 / R5 230 OEM] `: :` Memory: 35.44GiB / 63.88GiB / / CPU Usage: 99% .- -. Disk (/): 12G / 880G (1%) -- -. Disk (/tank/share): 13T / 21T (63%) `:` `:` .-- `--. .---.....----. Build World make -j28 buildworld --- buildworld_epilogue --- -------------------------------------------------------------- >>> World build completed on Sat Dec 23 13:20:12 EST 2023 >>> World built in 1405 seconds, ncpu: 28, make -j28 -------------------------------------------------------------- Build Kernel KERNCONF=GENERIC Z440 in make.conf ...

June 22, 2023

FreeBSD Migrate to New Disk

安裝新系統 利用FreeBSD安裝程式安裝系統到新硬碟,安裝時命名zroot為zroot2(或其他名字) zfs export 新系統開機後 zpool export zroot2 關機 zfs import 接上舊硬碟,選擇用舊硬碟開機 zpool import -f zroot2 zfs snapshot -r zroot@123456隨便你 zfs send -R zroot@123 | zfs recv -F zroot2 關機 reboot 用新硬碟開機 swap 記得去改/etc/fstab中的swap disk # Device Mountpoint FStype Options Dump Pass# /dev/gpt/efiboot0 /boot/efi msdosfs rw 2 2 /dev/新硬碟代號p3 none swap sw 0 0

April 23, 2023