gyf304 / vmcli

A set of utilities (vmcli + vmctl) for macOS Virtualization.framework
BSD 2-Clause "Simplified" License
826 stars 44 forks source link

How to share host folders into VM? #20

Closed zengbo closed 2 years ago

gyf304 commented 3 years ago

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 .

tiehfood commented 3 years ago

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