gyf304 / vmcli

A set of utilities (vmcli + vmctl) for macOS Virtualization.framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to share host folders into VM?

zengbo opened this issue · comments

How to share host folders into VM?

SSHFS is a good way of doing that. Setup SSH on your Mac, and sshfs mount it in the client.
See https://help.ubuntu.com/community/SSHFS .

With macOS 12 and Xcode 13 beta
Add the following to the code

    let directory = VZSharedDirectory(url: URL(fileURLWithPath: "/PATH/TO/FOLDER"), readOnly: false)
    let fsdConfig = VZVirtioFileSystemDeviceConfiguration(tag: "myshare")
    fsdConfig.share = VZSingleDirectoryShare(directory: directory)
        
    vmCfg.directorySharingDevices = [fsdConfig]

then type in started VM:

mkdir -p /mnt/myshare
mount -t virtiofs myshare /mnt/myshare