Skip to content

Instantly share code, notes, and snippets.

@heitbaum
Last active September 18, 2025 13:55
Show Gist options
  • Save heitbaum/6a5b52303620c1e58317c94d05431fd5 to your computer and use it in GitHub Desktop.
Save heitbaum/6a5b52303620c1e58317c94d05431fd5 to your computer and use it in GitHub Desktop.

To share a Proxmox host folder into an LXC container, first mount the desired host folder to a temporary location on the PVE host, then use the pct.set command or modify the LXC's configuration file to bind-mount this temporary directory into the container. Ensure the container's user has the correct permissions for the mounted folder, adjusting User ID (UID) and Group ID (GID) as necessary, which can be done in the container's configuration file.

Step-by-Step Guide

  • Mount the folder on the Proxmox host:

    • Ensure you have the necessary network share (NFS or SMB/CIFS) mounted on your PVE host.
    • Create a directory on the host to serve as a temporary mount point for your shared folder.

mkdir /mnt/my-shared-folder

  • Configure the LXC Container:

    • You can use the pct.set command to add the mount to the LXC's configuration.

pct.set <container_id> --mp0 <<host_path>>,mp=<container_path>

  • Replace <container_id> with the ID of your LXC container.
  • Replace <host_path> with the path you created on the PVE host (e.g., /mnt/my-shared-folder).
  • Replace <container_path> with the desired path inside the container (e.g., /shared).

Example:

If your shared folder is at /mnt/my-shared-folder on the host and you want to access it as /shared inside LXC with ID 100, you would run:

pct.set 100 --mp0 /mnt/my-shared-folder,mp=/shared

  • Adjust Permissions (if needed):

    • For unprivileged LXC containers, you'll likely need to adjust the user and group IDs so that the container can access the mounted folder.
    • You can do this by adding lines to the LXC's configuration file (e.g., /etc/pve/lxc/<container_id>.conf).
lxc.idmap = u 0 100000 1
lxc.idmap = g 0 100000 1
# Add more entries to map specific host users/groups to container users/groups
  • Note: 0 100000 1 maps the root user (UID 0) from the container to the host user ID 100000.

  • Restart the Container:

    • After making these changes, restart the LXC container for the new mount point to take effect.
pct stop <container_id>
pct start <container_id>

By following these steps, you can effectively share a folder from the Proxmox host to your LXC container using a bind mount. This method allows the container to directly access and interact with files and directories that are managed on the Proxmox VE host.

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