Skip to content

Shared Volumes

The volumes section allows you to define directories to share between the host and the guest.

The volume entries are colon-separated fields, in order:

  1. The source directory (with . above, the folder where the virtfile exists)
  2. The mountpoint location inside the guest
  3. (Optional) Mount options
  4. (Optional) Virtiofs driver options

Note

If your working directory has colons or commas in its path, you might run into trouble.

Example: Current directory shared and writable by the guest

volumes:
- .:/shared:rw
This will mount the current directory (.) at /shared in the guest. It is writable, meaning changes in the guest also apply to the source filesystem on the host.

Example: Current directory mounted read-only

volumes:
- .:/shared:ro:readonly=true
This will enforce the read-only flag in the guest mount options (ro) and in the virtiofs driver (readonly=true). This also happens to be identical to the default shared volume.

Default shared volume

If you do not specify any volumes, the default is to mount the current directory read-only at /shared.

Disabling the default

If you prefer not to have the default, you can specify your own volumes (in which case the default will not be included), or you can add the following flag:

Example: Flag disabling the default shared volume

flags:
- no-default-volume

Very custom shared volumes

If you need more control over the mount, such as to use protocols other than virtiofs, consider using the --filesystem option for virt-install.

Example

These filesystem options can be specified like:

machine:
- filesystem: /source,share1,driver.type=virtiofs,readonly=true

This can be made to auto-mount by adding a line to the guest's /etc/fstab:

share1 /dest virtiofs defaults,nofail,ro 0 0