Shared media folder
The media folder of the Proxmox host under /media, shared by Jellyfin, downloaders and co. – bind mount in LXCs, virtiofs in VMs, group media (GID 2000) in every guest. Attach it when creating the guest: var_media=<Directory Mapping>
Add to a guest
In the guest as root – container and VM alike:
update --add-modules media-shareRuns a normal update and installs the module on the way.
From the Proxmox node, without logging in:
pct exec <ID> -- update --add-modules media-share # container
ssh root@<IP> update --add-modules media-shareChoose when creating a guest
Without a dialog, on the Proxmox node:
IAC_NONINTERACTIVE=1 var_modules=auto-update,media-share \
bash -c "$(curl -fsSL https://iac.heyer.systems/<app>/ct.sh)"var_modules replaces the app's preselection – keep auto-update in the list if you want it. Interactive: choose “advanced” in the dialog, or tick the module in the generator on the app page.
Remove
update --remove-modules media-shareRemoves the module's packages, services, firewall rules and configuration again. Data stays.
Details
One media folder on the Proxmox host, mounted under /media in every guest that needs it:
downloaders write into it, Jellyfin and co. read from it. Containers get it as a bind mount,
VMs over virtiofs – no network share and no NFS inside the guests. Because everything is one
file system, moving a finished download into the library is a rename or a hardlink, not a copy.
Every guest gets the group media with GID 2000. Containers map this GID 1:1 to the host,
virtiofs passes IDs unchanged – so whatever any guest writes belongs to the group media on the
host and in every other guest. Apps that use the folder put their user into the group.
Once on the Proxmox host
iac does not manage the storage of the host – this part is yours:
zfs create data-pool/media # or any directory, e.g. a mounted NAS share later
chown 100000:2000 /data-pool/media # 100000 = root of the containers, 2000 = media
chmod 2775 /data-pool/media # setgid: new files and folders get the group
echo 'root:2000:1' >> /etc/subgid # lets containers map GID 2000 1:1
Root of a container may not change anything that belongs to root of the host (UID 0) – the
owner 100000 lets the guests create their folders. Folders you create on the host yourself
(movies, tv, …) need the same: chown -R 100000:2000 /data-pool/media and
find /data-pool/media -type d -exec chmod 2775 {} +.
Then Datacenter → Resource Mappings → Directory Mappings → Add: ID media, path
/data-pool/media on this node (Proxmox VE 8.4 or later).
New guests
var_media=media bash -c "$(curl -fsSL https://iac.heyer.systems/<app>/ct.sh)"
var_media is the ID of the Directory Mapping. For a container ct.sh adds mp0 (the path of
the mapping on this node) and the lxc.idmap for GID 2000, for a VM vm.sh adds virtiofs0.
Both select this module. The interactive dialog asks for it under “advanced”.
Existing guests
Attach the folder on the host, restart the guest, then inside it: update -am media-share.
VM:
qm set <id> --virtiofs0 mediaContainer:
pct set <id> --mp0 /data-pool/media,mp=/media, then append to/etc/pve/lxc/<id>.conf:lxc.idmap: u 0 100000 65536 lxc.idmap: g 0 100000 2000 lxc.idmap: g 2000 2000 1 lxc.idmap: g 2001 102001 63535
Files already in /media of the guest are hidden by the mount – move them to the host first.
The update after attaching also creates the folders of the app (e.g. /media/downloads/usenet)
in the shared folder.
A VM with a mapping that is not called media: media_share_tag=<ID> in
/etc/iac/settings.env, then update.
Use it
Keep everything under /media, the downloads too – e.g. /media/downloads, /media/movies,
/media/tv. Apps that write there need UMask=0002, so the group may change their files.
Limits
- Proxmox backups do not contain the folder – neither bind mounts nor virtiofs.
- A VM with virtiofs cannot be live-migrated and has no snapshots with RAM.
- Containers and VMs on other nodes need the same mapping there, with the same data (e.g. a NAS share mounted on every node).
Check it
findmnt /media
getent group media # media:x:2000:<users>
nobody:nogroup on everything in /media of a container: the host folder does not belong to
100000:2000 – fix it on the host as above, then update in the guest.
When the module is removed, a VM unmounts the folder; the group and all files stay. In a
container the bind mount stays until you remove mp0 on the host.