Skip to content

Instantly share code, notes, and snippets.

@bingzhangdai
Created July 18, 2020 08:13
Show Gist options
  • Save bingzhangdai/7cf8880c91d3e93f21e89f96ff67b24b to your computer and use it in GitHub Desktop.
Save bingzhangdai/7cf8880c91d3e93f21e89f96ff67b24b to your computer and use it in GitHub Desktop.
Set up VirtFS (9p virtio) for sharing files between Guest and Host on Proxmox VE

How-to

  1. On Host(PVE), edit /etc/pve/qemu-server/VMID.conf
args: -fsdev local,security_model=mapped,id=fsdev0,path=/path/to/share -device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=hostshare

This tells qemu to create a 9pvirtio device exposing the mount_tag hostshare (just a name to identify the mount point). That device is coupled to an fsdev named fsdev0, which specifies which portion of the host filesystem we are sharing, and in which mode.

According to the QEMU wiki, mapped security_model,

Files are created with Qemu user credentials and the client-user's credentials are saved in extended attributes.

I think it is better to use mapped over passthrough

  1. On Guest

edit /etc/fstab, add a line

hostshare   /path/to/mount 9p  trans=virtio,version=9p2000.L   0   0

Then, mount -a. Voilà!

Troubleshoot

  1. 9p: Could not find request transport: virtio

Add following lines to /etc/initramfs-tools/modules

# 9p
# 9pnet
9pnet_virtio

then,

sudo update-initramfs -u

Reference

@SalimF
Copy link

SalimF commented Oct 30, 2023

Hi ho to do that using Virt-Manager GUI, I already add virtio-9p Filesystem but how to access it from my OS (arch Linux ) and the gust OS (win 11)

@bingzhangdai
Copy link
Author

bingzhangdai commented Jun 25, 2024

Hi ho to do that using Virt-Manager GUI, I already add virtio-9p Filesystem but how to access it from my OS (arch Linux ) and the gust OS (win 11)

I do not know if you can access 9p config via GUI and if Windows supports it. But if the host and guest OS are both Linux, you can follow the above guide.

However, I do not notice a great performance gain by 9p compared to nfs. Since 9p also uses network to share the data. I switch to nfs for compatibility reasons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment