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.
-
- 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
-
- 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).
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
-
- 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 1maps the root user (UID 0) from the container to the host user ID 100000. -
- 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.