Skip to content

Instantly share code, notes, and snippets.

@JSinghDev
Forked from bingzhangdai/9p_virtio.md
Last active March 12, 2024 22:19
Show Gist options
  • Save JSinghDev/9569a9260f5a8b0ffa393c2b0f931cf7 to your computer and use it in GitHub Desktop.
Save JSinghDev/9569a9260f5a8b0ffa393c2b0f931cf7 to your computer and use it in GitHub Desktop.
Set up VirtFS (9p virtio) for sharing files between Guest and Host on Proxmox VE (Share a ZFS dataset)

How-to

  1. Prep Check if 9pnet_virtio module is loded using the command
modinfo 9pnet_virtio

if it's not loaded check trouble shooting step 1. below

  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

Though it is recomended to add some parameters

hostshare   /path/to/share 9p  trans=virtio,version=9p2000.L,posixacl,msize=104857600,cache=mmap   0   0

Note: The mount point needs to be created first before Then, mount -a. Voilà!

Troubleshoot

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

Add following lines to /etc/initramfs-tools/modules on the guest

# 9p
# 9pnet
9pnet_virtio

then,

sudo update-initramfs -u

Reference

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