User:Tsu2/virtfs

Jump to: navigation, search

Sharing a Folder between Host and Guests using VM Manager

Overview

This page covers how to share a filesystem folder between a Host and a Guest using libvirt (VM Manager). Today, the SDB KVM documentation mainly covers how to launch a Guest from the CLI sharing a directory between Host and Guest, but AFAIK no SDB documentation describes how to configure using vm manager.

vm manager today supports xen, kvm and lxc, and these configuration instructions apply to any Guest using these virtualization technologies

Note that there are advantages to enabling a "Shared Directory" object unattached to a specific Guest, once created it can be used by multiple Guests and even Guests using different virtualization technologies, all that is required is support for the 9p protocol.

NOTE the numerous faulty descriptions on the Web which insert commas where there should be spaces.

Overall description of procedure

Create a virtual device (give it a label or name) and enable it to be accessed using the virtio transport.
Once the virtual filesystem object has been created and given a name, the Guest mounts the virtual device using the name/label.

The following example code shares a folder on the Host (/home/user/virtfs) with a Guest (/mnt/shared)
A label called "/hostshare" is used
NOTE You can replace the "user" in /home/user/virtfs with your own Username

Install

Run the following zypper command which installs vm manager, vm install, virt-install and client utilities

zypper in libvirt* virt-manager

1. Configure the Host

Launch vm manager from the Desktop Application Launcher or YAST
Select an existing VM
Click "Open" button
On the VM window, click the blue "I" button
Add File system
Select squashfs as the mode
Point Source to a location on the Host (example /home/user/virtfs)
Set proper permissions on the folder (assume allow read-write by both any Guest and Host) with the following command

chmod -R 0777 /home/user/virtfs

Specify a label which will be presented to the Guest, the label should be preceded by a forward slash (/) (example /hostshare)

The following screenshot is an example based on the above parameters Vm manager setup shared folder.png

2. Configure Guest

Mount shared directory
Open a root console, then execute the following which creates a mount point at /mnt/shared, specifying a mount type of 9p, setting an option transport is virtio using the label /hostshare

mkdir /mnt/shared
mount -t 9p -o trans=virtio /hostshare /mnt/shared

Additional:

Do you still want to deploy from a command line? Specify the virtfs configuration in your launch parameters
QEMU wiki
QEMU
KVM official - qemu-kvm (command line) and libvirt
Linux-KVM manual