Share a Host Directory with VM Instance

Using the VM [name] page, Cockpit Administrators can share files on the managed host system with a VM instance.

Note:

To share files between the host and a VM instance, Cockpit uses the virtiofs virtualization feature. Virtiofs is a shared file system feature that lets virtual machines access a directory tree on the managed host system.

What Do You Need?

  • The Cockpit web console must be installed and accessible.

    For details, see these topics: Install and Enable Cockpit and Log in to the Cockpit Web Console.

  • The Cockpit-machines add-on application must be installed in the web console and the Oracle Linux virtualization packages must be installed and enabled on the host system.

    Note:

    Virtiofs is available in most Linux distributions. It works with the virtualization packages (libvirt).

    For more information, see Install Cockpit-Machines and Enable Virtualization.

  • The VM instance that you want to share host files with must have a Linux guest OS.
  • The VM instance must be in a Shut off state to add shared directories.
  • The host directory that you want to share must already exist.
  • The shared host directory must be manually mounted inside the VM. For example:
    mount -t virtiofs hostshare [mount point]

    In the command, mount point in the mount point inside the VM instance.

    For more details, click the question mark icon [?] next to the Shared directories title on the VM [name] page.

Steps

Using the Cockpit web console, follow these steps to add a shared host directory to a VM instance.

  1. In the Cockpit navigation pane, click Virtual machines.

    The Virtual machines page appears.

  2. In the Virtual machines page, click the name of the virtual machine of interest.

    The Virtual machines [VM name] page appears.

  3. In Virtual machines [VM name] page, navigate to the Shared directory section and click Add shared directory.

  4. In the Add shared directory dialog, specify the following properties and then click Share.

    Source path In the Source path drop-down list box, specify the full host file path that you want to share with the VM instance.
    Mount tag In the Mount tag list box, specify a tag name that the VM instance uses to mount the source path.
    Additional Options: Extended attributes Select the Extended attributes checkbox to enable (xattr) on the shared directory and files.

    or

    Clear the Extended attributes checkbox to disable this option.

  5. The newly created shared directory appears in the Shared directory section on the VM [name] page. You can now open the stored files on the shared host directory from the VM instance.

    Note:

    You can remove an existing shared directory from the VM instance by clicking Remove on the VM page.