How to mount an nfs share inside an lxc container

Mattias Hedman

Well-Known Member
Jan 19, 2019
122
10
58
55
I have googeled and tried more than one solution but none seems to work.
I have edited apparmour, added mp0 to the lxc config, fiddling with other things inside lxc 100.cfg.
None seems to do what I want. Can it be that hard to mount an nfs inside an lxc container?

Got a container running Centos7.
 
I have googeled and tried more than one solution but none seems to work.
I have edited apparmour, added mp0 to the lxc config, fiddling with other things inside lxc 100.cfg.
None seems to do what I want. Can it be that hard to mount an nfs inside an lxc container?

Got a container running Centos7.
Came across your question. I have Jellyfin in a lxc container on Ubuntu, so not strictly Proxmox, but I don't see why it wouldn't work. My Video files are on a separate drive and I just need Jellyfin to read and play them. The following command line on the host Ubuntu 20.04 allows that:

lxc config device add MrJelly shared_dir disk path=/home/ubuntu/Videos source="/media/gort/black_drive_2/Videos/DVDs"

MrJelly: Is the name of the container for jellyfin

shared_dir: Any made up device name to implement the share

path=/home/ubuntu/Videos: Is a the reference directory for Jellyfin to find videos within the container (default user name being "ubuntu")

source="/media/gort/black_drive_2/Videos/DVDs": The location of the host video files

Works something like a symlink. Not sure if you can change the permissions on the host directory it would allow write access, as I haven't tried it, but it works fine readonly. You can create more than one link. Just change the shared_dir device name parameter and the path=/home/ubuntu/Videos to something different.

Good luck with your project, hope the above helps you out.
 
Last edited:
Using privileges LXCs using SMB/NFS shares is easy. You just need to enable the "allow CIFS/NFS" feature using the GUI for the LXC.
The problem are unprivileged LXCs where this feature is forbidden. But the bind-mount workaround oguz mentioned is still working.
 
Hi Everyone.

I'm trying to also give access to an NFS share inside the LXC.
I followed oguz recommendation and created the NFS mount on host then use the following command to add it to the LXC:

pct set 205 -mp0 /mnt/bindmounts/shared,mp=/shared

But this caused Snapshot feature to be disabled "The current guest configuration does not support taking new snapshots".

I tried adding It with the backup=0 flag:

pct set 205 -mp0 /mnt/bindmounts/shared,mp=/shared,backup=0

But still no luck. I really wanted to use the Snapshot in this LXC. Any workaround for this?

Thanks.

Proxmox: 7.1-7
 
Thank you for your suggestion.

If I use the LXC NFS direct mount method, Snapshots will work as intended?
 

Absolutely agree. Resharing in case the original goes away.


#TL;DR​

How do you mount NFS shares inside an LXC container?

  1. Create a privileged LXC container, using any guest distribution of your choosing
  2. Once created, modify the config file (/etc/pve/lxc/<id>.conf on Proxmox) and add features: mount=nfs
  3. Restart the container
  4. Mount your data (e.g. mount -t nfs 192.168.1.1:/data /mnt/data)
 
I am just starting w/ Proxmox and unable to get this to work.

To be able to copy files over to my Turnkey-FileServer I want to be able to mount the NFS within this LXC (privileged) but getting the below message:

root@FileServer ~# mount -t nfs 192.168.1.109:/i-data/4fd0b346/video /mnt/video
mount.nfs: Connection timed out

root@FileServer ~# mount -t nfs 192.168.1.109:/video /mnt/video
mount.nfs: Connection timed out

(Once I copied this over, I want the File Server to export that as SMB and make it accessible to Jellyfin)

I am able to mount my external NAS share (old Zyxel NSA320) as NFS on my PVE Datacenter. Note, I am unable to mount this as SMB for some reason (NT_CONNECTION_TIMEOUT or something like that). FYI, this is what I have in my /etc/pve/storage.cfg

nfs: nsa320_video
export /i-data/4fd0b346/video
path /mnt/pve/nsa320_video
server 192.168.68.109
content images
prune-backups keep-all=1

Appreciate any/all help.
 
Last edited: