O'Reilly logo

KVM Virtualization Cookbook by Konstantin Ivanov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

To share a directory from the host OS to the KVM guest, execute the following:

  1. Create a new directory on the host OS and add a file to it:
root@kvm:~# mkdir /tmp/sharedroot@kvm:~# touch /tmp/shared/fileroot@kvm:~#
  1. Add the following definition to the stopped KVM instance:
root@kvm:~# virsh edit kvm1 ... <devices>   ...   <filesystem type='mount' accessmode='passthrough'>     <source dir='/tmp/shared'/>     <target dir='tmp_shared'/>   </filesystem>   ... </devices> ...Domain kvm1 XML configuration edited.root@kvm:~#
  1. Start the VM:
root@kvm:~# virsh start kvm1Domain kvm1 startedroot@kvm:~#





 

 

  1. Connect to the console as follows:
root@kvm:~# virsh console kvm1Connected to domain kvm1Escape character is ^]Debian GNU/Linux 8 debian ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required