lucyllewy / macOS-Linux-VM-with-Rosetta

313 stars 27 forks source link

Mount a folder shared by the macOS host system inside the Ubuntu VM #23

Closed kvz closed 1 year ago

kvz commented 1 year ago

I got a VM running, already so amazing 🤩 thank you for the work here.

It's not entirely clear to me how I can mount a folder into the VM. Use case: I have code in a local directory that I would like to be accessible in the VM, so I can make changes in my local code editor and watch & run them directly.

I guess I could use NFS or something like that for this, but configuring that correctly can be troublesome. I came across virtiofs and noticed this is also what is used to share Rosetta with the VM. I suspect this will be faster than going over NFS as well.

It is my understanding that from the VM side, we could just run this for example to mount a Shared Folder if it was tagged api2: sudo mount -t virtiofs api2 /srv/current. All that is missing now is sharing the folder with same tag from the host side.

Is this something that would need to be supported in the RosettaVM program that you built, or is there some way I can do this on the CLI already? The the former, a command line argument or cfg file to define a share would already be a lifesaver, no need for any ui :)

mifi commented 1 year ago

Seems like the ROSETTA device gets attached from the host here: https://github.com/diddledani/macOS-Linux-VM-with-Rosetta/blob/0d7d8697339663611186b96fe5109b6a00f9ebe9/RosettaVM/AppDelegate.swift#L275

So we need to add similar code there for exposing our own Fuse directory on the host to the guest via virtiofs

kvz commented 1 year ago

There are build instructions in this project's readme, but i don't know any Swift so will make all the beginner mistakes. Perhaps with some help of @donnywals we can PR it? 🤔 Do you know Swift @mifi?

mifi commented 1 year ago

Unfortunately I dont know much swift, although I think it’s a relatively straight forward language for doing simple things. Alternatively we could look into a project called UTM. Seems they support Rosetta too and uses Virtualization.framework! https://docs.getutm.app/advanced/rosetta/

donnywals commented 1 year ago

I would for sure be a little bit out of my depth regarding the domain of this all but would be willing to take a look and help out with the code itself

kvz commented 1 year ago

We'll try UTM for now 👌