9

I am trying to run a Linux Debian with qemu with MacOS Big Sur host.

Unfortunately virtfs doesn't work on Mac and there is no easy alternative that I have found.

Is there a way to share folders with plan9?

Thanks!!

EDIT:

This is what I need: https://github.com/NixOS/nixpkgs/pull/122420 but it is still in progress !!

Thanks to all!

3
  • 1
    Do you mean plan9 or Linux they are different operating systems
    – mmmmmm
    Commented May 21, 2021 at 8:08
  • @mmmmmm I mean this wiki.qemu.org/Documentation/9psetup
    – laurajaime
    Commented May 21, 2021 at 14:29
  • For Linux on VMs on macOS I would look at Parallels or Docker which work on Intel or ARM or VMWare or Virtual Box for Intel only
    – mmmmmm
    Commented May 21, 2021 at 15:17

3 Answers 3

7

As of March 2022, 9pfs is available in QEMU on macOS if you're using homebrew. My qemu-system-x86_64 command includes the following parameter:

-virtfs local,path=/Users/gsf/Downloads,security_model=none,mount_tag=Downloads

And my /etc/fstab in the guest includes this line:

Downloads /home/gsf/Downloads 9p _netdev,trans=virtio,version=9p2000.u,msize=104857600 0 0

With security_model=none I did have to modify user and group IDs in the guest to match the host. You may prefer security_model=mapped instead.

Also I tried version=9p2000.L but that resulted in "Network dropped connection on reset" errors when trying to access the shared directory. For more info on my full setup, see my Ubuntu VM on macOS with QEMU.

For a documentation of 9pfs from QEMU, visit here.

1
  • I'm using this right now, but I'm using the xml configuration for libvirt <filesystem type='mount' accessmode='mapped'> <source dir='/.../test'/> <target dir='hostshare'/> </filesystem>. If you have any idea, where do I change the user and group, because on the mac guest it sets both user and group to 1000, which is the id of my current user.
    – jasxir
    Commented Jul 12, 2022 at 10:53
5

As of July 2021, 9pfs and virtfs are not available in QEMU on macOS.

An alternate method to share folders with read-write access from a macOS host to a Linux VM is to use sshfs.

Read-write access using SSHFS
  1. Install sshfs on Linux VM.
  2. Allow remote login on macOS host: System Preferences > Sharing > Remote login.
  3. Mount macOS directory on Linux VM via:
sshfs user@macos_ip:/Users/user/mydir ~/host_mydir

If you cannot use ssh to access the macOS host you can still share the directory with read-only access using QEMU virtual FAT disk images:

Read-only access using a virtual FAT disk image
  1. Add directory as a disk image via:

Note: VM will not start without fat:rw:

qemu-system-x86_64 \
  -machine type=q35,accel=hvf \
  -cpu host \
  -hda /images/linux.qcow2 \
  -drive file=fat:rw:/Users/user/mydir,format=raw,media=disk
  1. Mount directory in Linux VM via:

Note: directory will not mount without -o ro

# 'ro' is required to mount directory
sudo mount -t auto -o ro /dev/sdb1 /media

This method has some limitations:

  • [never] use non-ASCII filenames
  • [never] use “-snapshot” together with “:rw:”
  • [never] expect it to work when loadvm’ing
  • [never] write to the FAT directory on the host system while accessing it with the guest system
1

This is what I need: https://github.com/NixOS/nixpkgs/pull/122420

Thanks to all!

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Jan 28, 2023 at 12:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .