Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Sep 2025 14:48:04 +0100
From:      Lexi Winter <ivy@freebsd.org>
To:        freebsd-virtualization@freebsd.org
Subject:   Re: bhyve rw access to host filesystem?
Message-ID:  <aMAwFNbSSfKAGh5D@amaryllis.le-fay.org>
In-Reply-To: <aMAjoodDyaJIahJl@int21h>
References:  <aMAjoodDyaJIahJl@int21h>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
void:
> I'd like to have one bhyve vm access the bhyve *host's* filesystem

this is what p9fs(4) is for.

> I can't seem to find instructions how to do this, although 9p looks
> promising, am not sure this can be accessed from the host.

p9fs exports an existing directory tree from the host (similar to the
NFS server), so the host can always access the files by definition.

to export the filesystem, add a virtio-9p device to bhyve:
	bhyve [...] -s 5:0,virtio-9p,myshare=/some/path,rw
'myshare' should be replaced with a descriptive name for the share,
and change 'rw' to 'ro' to make it read-only.

in the guest, mount the filesystem as normal in /etc/fstab using the
same share name:
	myshare		/myshare	p9fs rw 0 0

note that unlike NFS, this doesn't work automatically for descendent
mountpoints on the host (e.g., ZFS filesystem hierarchies); instead
you need to export and mount each child filesystem separately.

this is compatible on both the host and guest side with virtio-9p in
Linux and other operating systems, but not with the newer version
which i can't remember the name of (VirtFS?).

[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----

iHUEABYKAB0WIQSyjTg96lp3RifySyn1nT63mIK/YAUCaMAwEQAKCRD1nT63mIK/
YJTsAP9rRjJtXwesFIHCCeYl4IhdU6zGM/jVaN8MJK55gjIVKgEAlnrsStp34o1H
HxBm2erlpE2OGEi4DSh+QZkjFKgcrQU=
=LmyY
-----END PGP SIGNATURE-----

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?aMAwFNbSSfKAGh5D>