Skip to content

Instantly share code, notes, and snippets.

@rngadam
Last active February 11, 2025 01:00
Show Gist options
  • Save rngadam/fac49aedcce79709b262eaf1ec6e1950 to your computer and use it in GitHub Desktop.
Save rngadam/fac49aedcce79709b262eaf1ec6e1950 to your computer and use it in GitHub Desktop.
Sharing Proxmox host mount with VM with virtiofs

virtiofsd on Proxmox

installing

root@pve:/home/rngadam# apt install virtiofsd -y
root@pve:/home/rngadam# /usr/lib/kvm/virtiofsd --version
virtiofsd 1.10.1

follow instructions in https://gist.github.com/Drallas/7e4a6f6f36610eeb0bbb5d011c8ca0be

in proxmox

cd /var/lib/vz/snippets
curl https://raw.githubusercontent.com/Drallas/Virtio-fs-Hookscript/refs/heads/main/Script/virtiofs_hook.pl -o virtiofs_hook.pl
curl https://raw.githubusercontent.com/Drallas/Virtio-fs-Hookscript/refs/heads/main/Script/virtiofs_hook.conf
chmod u+x virtiofs_hook.pl 

setup vmid 108 (example):

qm set 108 --hookscript local:snippets/virtiofs_hook.pl
qm start 108
systemctl status virtiofsd-108-media@108

in VM:

mkdir -p /media
mount -t virtiofs 108-media /media

in fstab:

108-media /media virtiofs nofail 0 2

TODO: uid and gid mapping

Similar to how LXC bindmounts do mapping of uid from 100000 (on Proxmox host) to 0 (on VM_, we try to have mapping uid and gid, modify the systemd service.

Modify:

/etc/systemd/system/[email protected]

at the ExecStart line, append:

  --uid-map :0:100000:65536: --gid-map :0:100000:65536:

then

systemctl daemon-reload
systemctl restart virtiofsd-108-media@108

but journalctl -u virtiofsd-108-media@108 shows:

Feb 10 19:31:35 pve virtiofsd[1389112]: [2025-02-11T00:31:35Z ERROR virtiofsd] Error entering sandbox: gid_map can only be used by unprivileged user where sandbox mod is namespace (Use '--sandbox namespace' instead)
Feb 10 19:31:35 pve systemd[1]: [email protected]: Main process exited, code=exited, status=1/FAILURE

Tried --sandbox namespace with no changes

references

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