(setq plaintext 'everywhere)



KVM: Setup A Shared Direcory Between A Host And Guest

[2022-12-15 Thu]

Follow the instruction below to set up a shared directory between a host and a KVM guest virtual machine.

1 KVM: Setup A Shared Direcory Between A Host And Guest

Create the directory to be shared on you host machine and set the permissions.

mkdir ~/shared
chmod 777 ~/shared

In virt-manager open the settings (i.e. click the open button in the top left corner) of the VM you wish to share a directory with. Then click "Show virtual hardware details" (i.e. the light bulb in the top left corner). In the bottom left click the "Add hardware". A new window should pop up. In the menu on the left click "Filesystem". Use the follow settings

Driver: virtio-9p
Source path: /full/path/to/shared/on/host
Target path: /sharedir

Now start the VM. To mount the shared directory use:

sudo mkdir /shared
sudo mount -t 9p -o trans=virtio /sharedir /shared

Or if you want the directory to automatically be mounted on boot add this to your /etc/fstab:

/sharedir /shared 9p trans=virtio,version=9p2000.L,rw 0 0

2 Sources



If something is not working, please create an issue here.