Skip to content

Instantly share code, notes, and snippets.

@packerdl
Created October 12, 2020 23:48
Show Gist options
  • Save packerdl/c910034d359835ea52e158f46a7eab72 to your computer and use it in GitHub Desktop.
Save packerdl/c910034d359835ea52e158f46a7eab72 to your computer and use it in GitHub Desktop.
Bind mount a CIFS share on a Proxmox host to an LXC container.

Bind Mount CIFS Volume to LXC Container

This example mounts a read-only Media share to the Promox hosts and bind mounts the volume to an LXC container running a Plex Media Server.

  1. Open a shell on the Proxmox node
  2. In the /root create a file called cifs_credentials.
  3. Inside the file place the username and password for the share in the following format:
username=USERNAME
password=PASSWORD
  1. Make the credential file only accessible to the owner (root):
chown 600 /root/cifs_credentials
  1. Add a new entry to /etc/fstab to mount the share on boot. Omit the ro option if you wish to the node to have write permissions to the share.
//SERVER_HOST/Media /mnt/Media cifs ro,vers=3.0,credentials=/root/cifs_credentials,iocharset=utf8,nofail 0 0
  1. Bind mount the CIFS share to the container running Plex:
# In the container configuration file: /etc/pve/lxc/CONTAINER_ID.conf
lxc.mount.entry: /mnt/Media mnt/Media none ro,bind,optional,create=dir 0 0

The Media share will now be available within the Plex container with read-only access. If write access is required you will need to remove the ro option from the mount.entry command and add the appropriate idmap configuration to have the Plex user in the container map to a user with access to the share on the host system.

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