1

Premise

     On Windows, Windows Subsystem for Linux — I use WSL 2, but this also applies for WSL 1, as I understand it — makes the guest Linux instance's filesystems available to the Windows host over 9p, specifically 9p2000.L. Is there a way to do something similar between a VirtualBox guest OS and host OS? I'm interested in this for multiple host OSes, including:

  • macOS
  • Windows

and multiple guest OSes, including:

(Feel completely free to focus on the more well-known and well-maintained of these; I'm not asking for undue effort here.)
     Some potential avenues of inquiry I'm aware of are:

  • 9p, as used by WSL2 as mentioned before.

  • virtio

         (Note:

  • VirtFS

  • Not virtiofs, as its most prominent documentation states that it's for sharing files from a host OS to a guest OS, instead of the other way around like I want.

  • virt-manager, maybe…?

  • SSHFS

(Answers may pick between using one or more of these as the solution they cover.) Additionally, I know that QEMU/KVM have virito/9p support, but I'd like to know/see if the sort of file-sharing arrangement I'm looking for is possible with VirtualBox. I'm familiar with it, and it's easier to set up, at least in the sense that you don't have to modify raw configuration files or execute CLI commands.

Background Rationale

     The reason I'd like to know how to share a VM guest OS's filesystem contents with a host OS is:

  • For:

    • Kernel and OS development
    • Maybe kernel extension development in the future
  • Where the performance overhead comes into play:

    • When the host OS accesses files in the guest OS's filesystem,
    • Not every time when the guest OS needs to access build and other project files.

    I don't want to store build/project files somewhere on a host OS filesystem location, thus forcing the guest OS to encounter the performance overhead and cost of having to round-trip through the file-sharing mechanism in use. Guest OS accesses to filesystem locations within its containing VM disk image are what should get close-to-native/-raw performance, or at least closer-to-native or higher performance.

2 Answers2

1

Never heard of 9p myself but i found https://wiki.qemu.org/Documentation/9psetup and particularly https://wiki.qemu.org/Documentation/9p intresting.

I also think Qemu with Virsh may suit your development and debugging requirements more (and its maybe more speedy). Qemu, and/or libvirt is supported on the MacOS platoform and windows may work but i feel its more restrictive by MS choice and design (HyperV being their thing and all)

Why not a Linux host? but ill stay with answering your broad question. Noting your background rationale, why not mount the virtual harddisk when required? libguestfs or my favorite qemu-nbd might allow you to mount it at times that you require. qemu-ndb worked for me in the past with multiple kinds of client OS, including mac, xbox and ntfs (windows)

How to share a directory with the host without networking in QEMU? seems to answer maybe your questions partially maybe? Qemu's system and kernel debugging abilities also add alott to the toolbox. Virsh as its front end may be a bit awkward but more automated in a way.

CodeAsm
  • 121
1

VirtualBox has a Shared Folders feature that is available when you install their Guest Additions in your Guest OS (Chapter 4. Guest Additions).

I don't have any experience with Shared Folders, but I have installed the Guest Additions in some VMs for the mouse pointer integration support.

Edit: I was just perusing the the link above and found the Guest Control File Manager (4.8. Guest Control File Manager) which might be more friendly than the Shared Folders.