Skip to content

share_folder

Alonso Cárdenas edited this page Oct 23, 2025 · 1 revision

Share folder with virtio-9p

One easy way to share a host folder with a guest on bhyve is using virtio-9p devices.

Requeriments

  • FreeBSD host running bhyvemgr
  • FreeBSD guest

FreeBSD host and bhyvemgr configuration

My host is a FreeBSD 15-amd64. From bhyvemgr, add a new virtio-9p (Shared folders) device from Devices Settings. Sharename will be used to identify virtio-9p device which will mount in the guest. I'm putting host-folder like name. Path is the folder location in the host that will be share with the guest. In this case, I'm sharing /home/acm/sample-folder directory.

image image

FreeBSD guest configuration

In this guide, I'm using a FreeBSD 16.x CURRENT like a guest. It supports virtio-p9fs module.

When the guest boot is done, you can look into dmesg output if virtio-9p device is detected.

virtio_pci1: <VirtIO PCI (legacy) Entropy adapter> port 0x2240-0x225f mem 0xc2002000-0xc2003fff irq 17 at device 20.0 on pci0
virtio_pci2: <VirtIO PCI (legacy) 9P Transport adapter> port 0x2000-0x21ff mem 0xc2000000-0xc2001fff irq 19 at device 22.0 on pci0

The virtio-p9fs module is not loaded by default on boot time. You can add an entry to /boot/loder.conf to change it.

# echo virtio_p9fs_load=\"YES\" >> /boot/loader.conf

For testing purpose, load the driver manually

# kldload virtio_p9fs
virtio_p9fs0: <VirtIO 9P Transport> on virtio_pci2
virtio_p9fs0: Mount tag: host-folder

Now, mount virtio-9p filesystem into the guest

# mount -t p9fs host-folder /mnt
# ls /mnt
testfile		testfile1		testfile2

Also, you can put an entry to /etc/fstab file

# echo "host-folder     /mnt    p9fs    rw      0       0" >> /etc/fstab

Notes

virtio-9p driver support is included in FreeBSD 14-STABLE, 15-STABLE, 15-RELEASE and 16-CURRENT branches.

Clone this wiki locally