Adding a bind mount using a remote folder using SSHFS.

I wanted to add a bind mount to a container to index content for playback. This setup allows the program within the container to index the data without needing to store it locally. The content in question is my music library, which I want to access while driving or at work.

Implementing this required a multi-step process. First, I had to mount a remote folder on my Proxmox host. Then, I needed to provide that folder as a bind mount to the container where the program requiring the data operates.

The process involves two main steps to securely communicate with the remote computer. I used SSHFS to connect to the server and mount the connection on the Proxmox Virtual Environment (PVE) host. I stored the SSH keys and configuration file in the /root directory on the host. Additionally, I edited the /etc/fstab file to set up a FUSE mount for the remote share, utilizing the stored keys and configuration file.

Here are the detailed steps to set up the Proxmox host and configure the SSHFS mount:

  1. Configure the SSHFS mount in the /etc/fstab file on your Proxmox host (PVE environment). Mount the SSHFS device into a directory such as /media/folder or /mnt/folder.
  2. Ensure that the corresponding directory is also created in the container. This allows you to mount the SSHFS directory from the PVE host to the designated directory in the container.
  3. Once the directories are set up, note the path and folder name in the container, then shut down the container.

Next, on the host, use a command like the following as an example to set up the bind mount:

sudo pct set100-mp0 /media/nas/audiobooks,mp=/media/AudioBooks/

Note: Do not include spaces between /media/nas/audiobooks and mp=.

In this command, for container ID 100, you are setting mp0 to /media/nas/audiobooks on the host and mounting it inside the container at /media/AudioBooks.

Be sure to replace the container ID (100 in this example) with the ID of your specific container. Additionally, ensure that the path and folder names match those on your system.

Remember, the best solution is to shut down the container before hand. Also verify your work.