a shared file system that lets virtual machines access a directory tree on the host. It allows the
guest to access files on the host machine. This section will explain how to create a shared
directory. You can also find a runnable sample in
Creating a Shared Directory on the Host Machine
Run following commands in host machine, to create a shared directory:
mkdir host_shared_dir HOST_SHARED_DIR=$(pwd)/host_shared_dir crosvm run \ --shared-dir "$HOST_SHARED_DIR:my_shared_tag:type=fs" \ ... # usual crosvm args
- The first field is the directory to be shared (
$HOST_SHARED_DIRin this example).
- The second field is the tag that the VM will use to identify the device (
my_shared_tagin this example).
- The remaining fields are key-value pairs configuring the shared directory.
To see available options, run
crosvm run --help.
Mount the Shared Directory in the Guest OS
Next, switch to the guest OS and run the following commands to set up the shared directory:
sudo su mkdir /tmp/guest_shared_dir mount -t virtiofs my_shared_tag /tmp/guest_shared_dir
You can now add files to the shared directory. Any files you put in the
appear in the
host_shared_dir on the host machine, and vice versa.