How to share folder between host and guest VM
Today, I had to quickly share some files between my guest VM and host OS1 to troubleshoot a problem1. Because I’m using the virt-manager GUI, the instructions on these pages were enough to accomplish the task.
I’m documenting steps2 here for future self who definitely will have forgotten all this:
1) Create 9pvirtio filesystem device in VM configuration
Option A: qemu-kvm CLI
I didn’t use this option. See 9p virtio doc for more details.
Option B: virt-manager GUI
- Open virt-manager.
- Click Add Hardware.
- Choose Filesystem.
- Set option values:
|Mode||Squash||See qemu wiki for more values and details.|
|Source path||/share/folder||Path to share folder on host.|
|Target path||/host_share||Not an actual fs “path”, simply a name to identify mountpoint.|
- Confirm and Apply Settings.
2) Mount 9p host filesystem in VM
- Start up VM.
- Make share folder and mount the filesystem from the host:
mkdir /tmp/share mount -t 9p -o trans=virtio,version=9p2000.L /host_share /tmp/share
And that’s it. Now we can start reading/writing3 files between guest and host in