[one-users] Host directory sharing with KVM VM's
Maxim Mikheev
mikhmv at gmail.com
Wed Feb 8 11:18:08 PST 2012
Hi Everyone,
There are lack of information how to use 9p on KVM. I finally made it
work! Here is how:
*
On host:
1. modify /etc/libvirt/qemu.conf change owner and group to which will be
used for starting KVM. The description how to use user/group at the end.
in my case I used oneadmin:cloud
and change security_driver to "none"
2. sudo touch /etc/apparmor.d/disable/usr.sbin.libvirtd
I was not able to modify apparmor. in theory need to add lines like:
/path/to/media/ rw,
/path/to/media/** rw,
to file: /etc/apparmor.d/abstractions/libvirt-qemu
but it doesn't work in my case. I will be happy if someone will give an
advice how to setup apparmor.
3. in OpenNebula Template add:
RAW=[
DATA=" <devices><filesystem type='mount' accessmode='mapped'> <source
dir=**/path/to/media/on/host**'/> <target dir='VirtFS'/> </filesystem>
</devices>",
TYPE=kvm ]
***
*"target dir"* is anything which will be used for mounting. In this
example "VirtFS"
*
4. change user/group for shared folder:
sudo chown -R **oneadmin:cloud **/path/to/media/on/host**
in VM's
1. sudo apt-get install linux-image-extra-virtual
2. create folder and setup correct user/group
sudo mkdir /srv/vfs
sudo chown -R max:maxgroup /srv/vfs
3. and add line to /etc/fstab
VirtFS/srv/data9ptrans=virtio,version=9p2000.L00
4. you can mount manually
sudo mount -t 9p -otrans=virtio,version=9p2000.L VirtFS/srv/vfs
*
How it is works:
After mounting the system will map user/group which used for mounting
point (here is *max:maxgroup) with user/group for kvm process
(oneadmin:cloud).
Inside VM user oneadmin (from host) will be shown as max, similar
conversion with groups. All other groups will not be changed
Hope it will be helpful.
Max
*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20120208/1b744d26/attachment.htm>
More information about the Users
mailing list