[TUTORIAL] Proxmox storage - Host to VM folder passthrough with 9p

stevenbrunstein

New Member
Feb 3, 2023
1
3
0
Denver
I use 9p mainly because of ZFS. ZFS over NFS uses ZFS sync.
This means the writes are completed to disk before they're written.... instead of being written into ZFS RAM. If you disabled ZFS sync over NFS, you'll will lose 5 seconds or so of writes on a power failure. No biggie, but why bother -- 9p works great!



## Proxmox Passthrough Host Storage to VM
After you have a working VM, let's say you need to get to an area on the host.
Dont want to use NFS, SMB to give access to local host data?
Try using 9p to passthrough the datashare you want!
[Documentation/9psetup]


### Loading 9p on Proxmox
ONLY WORKS ON DEBIAN:
Add to this file so that the initial filesystem can load the new kernel modules you wanted:
`nano /etc/initramfs-tools/modules`
```
9p
9pnet
9pnet_virtio
```
With those added above (someone commented you only need the last one on newer versions of debain), your fstab should work and automount the new 9p filesystem.
After you **MAKE SURE TO**:
`sudo update-initramfs -u`



### Modify the VMs config to passthrough a path we specify using 9p virtfs
To do this we have to edit the VM's config. There is no GUI option to make this work.
Open `/etc/pve/qemu-server/<vmid>.conf` and add the following (substituting relevant parts for your setup):
* * *
Documentation page:
`args: -virtfs local,id=<some_id>,path=/tank,security_model=passthrough,mount_tag=<some_tag>`

Here is my example setup:
`args: -virtfs local,id=faststore9p,path=/rpool/faststore,security_model=passthrough,mount_tag=faststore9p`

**This text above was added in the .conf file -- at the top, before `cores: 2`**
* * *

#### Add the new mount to FSTAB
To make sure the mount is started everytime:
edit `/etc/fstab` to mount on boot with:

Documentation page:
`<you_mount_tag_name> <mount_point> 9p trans=virtio,rw,_netdev 0 0`

Here is my example setup:
`faststore9p /faststore 9p trans=virtio,rw,_netdev 0 0`

[SOURCE for the netdev requirement above]



## REBOOT
Great idea to reboot right about now.
 
Last edited:
Very interesting. I didnt read sufficiently, but do you know if this is pipeable via tcp/rdma? its not particularly useful if it can only serve guests on the same physical machine, but if it can be used instead of nfs it can potentially solve some painpoints...
 
First of all, thank you. I bookmarked this.

I did read the post on superuser about netdev though. What do you make of this?

"This is not a good solution. _netdev only tells systemd to not mount that file system as long as the system has no network connectivity. Yet when transport is virtio, then 9p is not even used over network and on the other hand, the system may have network connectivity before it has access to /lib/modules (e.g. if network drivers are on initramfs). If that isn't the case on your system, then this is coincident but you must not rely that this will always for sure be the case."
 
I wanted to come in and first thank you and second say that this seems to work fantastic on Gentoo, e.g. not Debian only (although I suspect the Debian only portion comes from copy pasta?)

My use case is to keep a shared /home between my VMs.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!