Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]: How can I share a folder from my host system with a guest virtual machine running in QEMU ? #590

Open
2 tasks done
DartSteven opened this issue Sep 16, 2024 · 6 comments
Labels
question Further information is requested

Comments

@DartSteven
Copy link

Is your question not already answered in the FAQ?

  • I made sure the question is not listed in the FAQ.

Is this a general question and not a technical issue?

  • I am sure my question is not about a technical issue.

Question

Hi,

I would like to share a folder from my host system with a guest virtual machine running in QEMU. I’ve been trying to find the right way to do this, but I haven’t been able to get it to work. Could you please provide a step-by-step guide on how to properly share a host folder with a guest VM?

Specifically, I tried using the following command:

volumes:

  • /media/lvm/backup/Roon-Backups:/data/storage/bck:rw

Could you please guide me on how to correctly set up folder sharing between the host and the guest? Any help would be greatly appreciated!

Thank you!

@DartSteven DartSteven added the question Further information is requested label Sep 16, 2024
@EagAnarchy
Copy link

EagAnarchy commented Sep 25, 2024

could you tell how you are trying to achieve this?
(Network sharing or just sharing offline?)

@DartSteven
Copy link
Author

DartSteven commented Sep 25, 2024

could you tell how you are trying to achieve this? (Network sharing or just sharing offline?)

Sure! My idea is to use your fantastic project to run “Roon-Server.” You can check it out here: https://roon.app/. More specifically, the image to download is this one: https://download.roonlabs.net/builds/roonbox-linuxx64-nuc4-usb-factoryreset.img.gz. It is listed in this guide, section 3 “Download”: https://help.roonlabs.com/portal/en/kb/articles/rock-install-guide#3_Download.

In short, this is audio software for listening to music. My music is stored on a partition on my host, and the backup folder (which the application interacts with for regular backups) is also on a partition on my host. I would like to be able to pass these two directories (for example, /media/lvm/data/Music and /media/lvm/backup) to the virtual machine.

@fizzyduck
Copy link

Might there be some way to use QEMU's 9pfs to achieve this?

@DartSteven
Copy link
Author

Might there be some way to use QEMU's 9pfs to achieve this?

yes but how? i tried but always nothing comes from host to guest

@fizzyduck
Copy link

The way I am doing this is:

  1. Ensure that your guest has 9pfs support compiled in or available as a kernel module
  2. Add a volume in docker-compose.yml so that qemu will have access to your host's FS via a bind mount:
    volumes:
      - /mnt/shared:/mnt/shared
  1. Add an ARGUMENT parameter to the environment section of docker-compose.yml:
    environment:
       ARGUMENTS: "-fsdev local,id=fsdev0,path=/mnt/shared,security_model=none -device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=host_share"
  1. Boot the guest and then attempt to mount the shared location:
mount -t 9p -o trans=virtio host_share /mnt/guest_mountpoint

I have just tested this and it appears to work as expected.

@fizzyduck
Copy link

What would be good is to put this in the main readme ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants