Share files from your host machine with virtual machine guests with 9p and virtual machine manager
(Infinity symbol source, Virtual Machine Manager logo traced from the logo on the official site automatically with Inkscape)
Recently I've been looking at Virtual Machine Manager with qemu and KVM to set up a few virtual machines for my next year at university. During this learning and planning process, I've discovered a way (source) to setup an environment such that you can share a folder on your host machine (optionally read-only) with a guest machine running inside a virtual machine with a technology called 9p, and I wanted to share how I did it here.
To start make sure your virtual machine is powered off, and go to Add Hardware → Filesystem, and fill in the boxes:
- Source path - The path on the host system to the folder you can to share.
- Target path - The path at which the guest will see it. Note that this isn't a place on the guest file system, from what I can tell - see below.
- Export filesystem as readonly mount - Check this box to make the share read-only.
Next, click "Finish", and start your virtual machine. Next, open a terminal on the guest machine and type something similar to this:
sudo mkdir /mnt/host_files sudo mount -t 9p -o trans=virtio,version=9p2000.L /target /mnt/host_files
...this should mount the host share at
/tmp/share to the path
/mnt/host_files on the guest machine.
Found this different sort of post useful? Got something to add? Post about it in the comments!