Solved Mount a disk from the host to guest

Hi,

I would like to mount a disk from the host in guest in vm-bhyve.

this is the disk from host which is not mounted:
Code:
ada0 at ahcich4 bus 0 scbus2 target 0 lun 0
ada0: <CT1000BX500SSD1 M6CR030> ACS-3 ATA SATA 3.x device
ada0: Serial Number 2040E4B5D23D
ada0: 600.000MB/s transfers (SATA 3.x, UDMA6, PIO 512bytes)
ada0: Command Queueing enabled
ada0: 953869MB (1953525168 512 byte sectors)

Guest config is this:
Code:
loader="uefi"
graphics="no"
xhci_mouse="yes"
cpu=1
memory=1G
ahci_device_limit="8"
network0_type="virtio-net"
network0_switch="public"
disk0_type="nvme"
disk0_name="disk0.img"
utctime="no"

I read this but I can't figure it out this part:
Code:
[HEADING=2]Custom Disk[/HEADING]
This allows you to specify a custom path to a disk image. The disk could be a sparse file, a ZVOL, or even a real disk under /dev/

disk0_type="virtio-blk"
disk0_name="/dev/ada10"
disk0_dev="custom"

Best regards,
 
If you want to pass disk to vm as device, you must use this:

Code:
disk1_type="virtio-blk"
disk1_dev="custom"
disk1_name="/dev/ada0"

In vm-bhyve templates there is file named config.sample with well-described parameters.
 
I edited the guest configuration then I restarted the guest. Dmesg do not show the disk... Where has to be normally?
 
Can you show the current configuration of that VM?
Code:
loader="uefi"
graphics="no"
xhci_mouse="yes"

cpu=1

memory=1G

ahci_device_limit="8"

network0_type="virtio-net"
network0_switch="public"

disk0_type="nvme"
disk0_name="disk0.img"

disk1_type="virtio-blk"
disk1_dev="custom"
disk1_name="/dev/ada0"

#passthru0="2/0/0"

#disk1_type="ahci-cd"
#disk1_dev="custom"
#disk1_name="/bhyve/ISO/virtio-win-0.1.229.iso"

utctime="no"
uuid="ac651e16-4299-11ee-acc6-b42e99628bca"
network0_mac="58:9c:fc:0d:17:40"
 
That looks to be in order. It will probably show up as vtbd0 in the guest, maybe you were expecting ada0 and therefor missed it?
 
Still can't find it, anyway this is my dmesg:
Code:
---<<BOOT>>---
Copyright (c) 1992-2023 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 14.1-RELEASE-p5 GENERIC amd64
FreeBSD clang version 18.1.5 (https://github.com/llvm/llvm-project.git llvmorg-18.1.5-0-g617a15a9eac9)
VT(vga): text 80x25
CPU: AMD Ryzen 5 2400GE with Radeon Vega Graphics    (3194.19-MHz K8-class CPU)
  Origin="AuthenticAMD"  Id=0x810f10  Family=0x17  Model=0x11  Stepping=0
  Features=0x1783fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE,SSE2,HTT>
  Features2=0xfed83203<SSE3,PCLMULQDQ,SSSE3,FMA,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AESNI,XSAVE,OSXSAVE,AVX,F16C,RDRAND,HV>
  AMD Features=0x26500800<SYSCALL,NX,MMX+,FFXSR,Page1GB,LM>
  AMD Features2=0x44231fb<LAHF,CMP,ExtAPIC,CR8,ABM,SSE4A,MAS,Prefetch,SKINIT,WDT,TCE,Topology,DBE>
  Structured Extended Features=0x201401a9<FSGSBASE,BMI1,AVX2,SMEP,BMI2,RDSEED,SMAP,SHA>
  XSAVE Features=0x1<XSAVEOPT>
  AMD Extended Feature Extensions ID EBX=0x7<CLZERO,IRPerf,XSaveErPtr>
  TSC: P-state invariant
Hypervisor: Origin = "bhyve bhyve "
real memory  = 1073741824 (1024 MB)
avail memory = 1000120320 (953 MB)
Event timer "LAPIC" quality 600
ACPI APIC Table: <BHYVE  BVMADT  >
random: registering fast source Intel Secure Key RNG
random: fast provider: "Intel Secure Key RNG"
random: unblocking device.
ioapic0: MADT APIC ID 1 != hw id 0
MADT: Forcing active-low polarity and level trigger for SCI
ioapic0 <Version 1.1> irqs 0-31
Cuse v0.1.37 @ /dev/cuse
random: entropy device external interface
kbd1 at kbdmux0
efirtc0: <EFI Realtime Clock>
efirtc0: registered as a time-of-day clock, resolution 1.000000s
vtvga0: <VT VGA driver>
smbios0: <System Management BIOS> at iomem 0x3fbd0000-0x3fbd001e
smbios0: Version: 2.8, BCD Revision: 2.8
aesni0: <AES-CBC,AES-CCM,AES-GCM,AES-ICM,AES-XTS,SHA1,SHA256>
acpi0: <BHYVE BVFACP>
acpi0: Power Button (fixed)
atrtc0: <AT realtime clock> port 0x70-0x71,0x72-0x77 irq 8 on acpi0
atrtc0: registered as a time-of-day clock, resolution 1.000000s
Event timer "RTC" frequency 32768 Hz quality 0
attimer0: <AT timer> port 0x40-0x43 irq 0 on acpi0
Timecounter "i8254" frequency 1193182 Hz quality 0
Event timer "i8254" frequency 1193182 Hz quality 100
hpet0: <High Precision Event Timer> iomem 0xfed00000-0xfed003ff on acpi0
Timecounter "HPET" frequency 16777216 Hz quality 950
Event timer "HPET" frequency 16777216 Hz quality 550
Event timer "HPET1" frequency 16777216 Hz quality 450
Event timer "HPET2" frequency 16777216 Hz quality 450
Event timer "HPET3" frequency 16777216 Hz quality 450
Event timer "HPET4" frequency 16777216 Hz quality 450
Event timer "HPET5" frequency 16777216 Hz quality 450
Event timer "HPET6" frequency 16777216 Hz quality 450
Event timer "HPET7" frequency 16777216 Hz quality 450
Timecounter "ACPI-fast" frequency 3579545 Hz quality 900
acpi_timer0: <32-bit timer at 3.579545MHz> port 0x408-0x40b on acpi0
pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
pci0: <ACPI PCI bus> on pcib0
nvme0: <Generic NVMe Device> mem 0x800000000-0x800003fff,0xc0002000-0xc0003fff at device 4.0 on pci0
virtio_pci0: <VirtIO PCI (legacy) Network adapter> port 0x2000-0x203f mem 0xc0000000-0xc0001fff irq 18 at device 5.0 on pci0
vtnet0: <VirtIO Networking Adapter> on virtio_pci0
vtnet0: Ethernet address: 58:9c:fc:0d:17:40
vtnet0: netmap queues/slots: TX 1/1024, RX 1/512
000.000152 [ 452] vtnet_netmap_attach       vtnet attached txq=1, txd=1024 rxq=1, rxd=512
xhci0: <Intel Panther Point USB 3.0 controller> mem 0xc0004000-0xc0004fff irq 19 at device 6.0 on pci0
xhci0: 32 bytes context size, 64-bit DMA
xhci0: Port routing mask set to 0xffffffff
usbus0 on xhci0
isab0: <PCI-ISA bridge> at device 31.0 on pci0
isa0: <ISA bus> on isab0
atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0
atkbd0: <AT Keyboard> irq 1 on atkbdc0
kbd0 at atkbd0
atkbd0: [GIANT-LOCKED]
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: [GIANT-LOCKED]
WARNING: Device "psm" is Giant locked and may be deleted before FreeBSD 15.0.
psm0: model Generic PS/2 mouse, device ID 0
uart0: <16550 or compatible> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0
uart0: console (115200,n,8,1)
uart1: <16550 or compatible> port 0x2f8-0x2ff irq 3 on acpi0
vga0: <Generic ISA VGA> at port 0x3b0-0x3bb iomem 0xb0000-0xb7fff pnpid PNP0900 on isa0
Timecounter "TSC-low" frequency 1597005098 Hz quality 1000
Timecounters tick every 10.000 msec
nvme0: temperature threshold not supported
nvme0: SET_FEATURES (09) sqid:0 cid:10 nsid:0 cdw10:00000008 cdw11:00000000
nvme0: FEATURE NOT CHANGEABLE (01/0e) crd:0 m:0 dnr:0 p:1 sqid:0 cid:10 cdw0:0
usbus0: 5.0Gbps Super Speed USB v3.0
Trying to mount root from ufs:/dev/nvd0p2 [rw]...
nda0 at nvme0 bus 0 scbus0 target 0 lun 1
nda0: <bhyve-NVMe 1.0 NVME-4-0>
nda0: Serial Number NVME-4-0
nda0: nvme version 1.4
nda0: 1024000MB (2097152000 512 byte sectors)
ugen0.1: <Intel XHCI root HUB> at usbus0
uhub0 on usbus0
uhub0: <Intel XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1> on usbus0
uhub0: 8 ports with 8 removable, self powered
Root mount waiting for: usbus0
ugen0.2: <BHYVE HID Tablet> at usbus0
lo0: link state changed to UP
vtnet0: link state changed to UP
ums0 on uhub0
ums0: <BHYVE HID Tablet, class 0/0, rev 3.00/0.00, addr 1> on usbus0
ums0: 3 buttons and [Z] coordinates ID=0
warning: total configured swap (1036288 pages) exceeds maximum recommended amount (983448 pages).
warning: increase kern.maxswzone or reduce amount of swap.
 
The ahci(4) controller also appears to be absent. You restarted the guest? Have you tried turning it off entirely, then back on again? In the VM's directory (/vm/<guestname>/ typically), there should be a vm-bhyve.log. Have a look through there, it should show the exact bhyve(8) command line it executes and perhaps some other clues.
 
I shuted down the guest, then I started up. Here is my current log:
Code:
Nov 12 22:44:48: initialising
Nov 12 22:44:48:  [loader: uefi]
Nov 12 22:44:48:  [cpu: 1]
Nov 12 22:44:48:  [memory: 1G]
Nov 12 22:44:48:  [hostbridge: standard]
Nov 12 22:44:48:  [com ports: com1]
Nov 12 22:44:48:  [uuid: ac651e16-4299-11ee-acc6-b42e99628bca]
Nov 12 22:44:48:  [debug mode: no]
Nov 12 22:44:48:  [primary disk: disk0.img]
Nov 12 22:44:48:  [primary disk dev: file]
Nov 12 22:44:48: initialising network device tap1
Nov 12 22:44:48: adding tap1 -> vm-public (public addm)
Nov 12 22:44:48: bring up tap1 -> vm-public (public addm)
Nov 12 22:44:48: booting
Nov 12 22:44:48:  [bhyve options: -c 1 -m 1G -Hwl bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd -U ac651e16-4299-11ee-acc6-b42e99628bca]
Nov 12 22:44:48:  [bhyve devices: -s 0,hostbridge -s 31,lpc -s 4:0,nvme,/bhyve/multimedia/disk0.img -s 5:0,virtio-blk,/dev/ada0 -s 6:0,virtio-net,tap1,mac=58:9c:fc:0d:17:40 -s 7:0,xhci,tablet]
Nov 12 22:44:48:  [bhyve console: -l com1,/dev/nmdm-multimedia.1A]
Nov 12 22:44:48: starting bhyve (run 1)
 
I dont want to sound an idiot but can it be this line from dmesg?

Code:
vtblk0: <VirtIO Block Adapter> on virtio_pci0
vtblk0: 953869MB (1953525168 512 byte sectors)

In my previous dmesg "vtblk0" wasn't present, maybe a simple restart on the guest doesnt do anything. The disk device appeared after a shutdown/start of the guest.
 
maybe a simple restart on the guest doesnt do anything.
Restarting the guest doesn't restart bhyve(8), thus it won't pick up on the 'hardware' changes, vm(8) is a "simple" shell script wrapper around bhyve(8). The configuration determines what options should be added to the command, but it only does this when it starts. It doesn't change the configuration dynamically.
 
Back
Top