I wanted a simple way to add an external drive that already had data on it and to make that available to containers in Proxmox. The external drive obviously has to be persistently mounted into the Proxmox host. You do that by mounting it via the /etc/fstab.
When I first started I wasn’t able to get this done. On the WWW there was very little discussion on how to actually do this and as usual the discussions that did happen didn’t mention the important “between the lines” information that would make understanding this easier.
For instance, if you assign CPUs to a container the default is one (1) CPU and you think well, I have to increase that value to give more resources, but what isn’t mentioned is that if you blank that field it will assign all CPUs to the container. Once in a great while you may need to do that. It would be nice if the discussions actually spoke about the unlimited option.
In bind mounts the situation is also similar. When you create the bind mount in the webui it defaults to setting aside 8gb of space for the bind mount. Apparently if you put a zero in there it will provide you with all the available space. Another thing is that you can issue the command in the CLI and just leave off the size parameter and it will make all the space available including existing data. Another thing on bind mounts is that once you create the bind mount you have to shutdown (not reboot) the container and then start it back up. I mean you have to either use the webui and tell it to shut down or you have to tell it power off (sudo poweroff) within the container and then start it up again. Only after doing this are you able to see all the space (and the prior data).
Another thing is that if you are using ZFS do not format the external USB drive as ZFS because ZFS expects to have total hardware control of the interface. This will cause slow copies and other types of problems. You may be tempted to do so anyway because you think the benefits are greater in using ZFS than the trouble caused by using ZFS. Don’t think that. Just don’t do it.
One more thing is that the Proxmox documentation is deteriorating. I mean things are changing and little is being done with the documentation to describe (but superficially) the challenges associated with the changes. Few examples exist except bland commands with unexplained parameters and the consequences of using them, and it’s not written in plain language.
If you didn’t know it, the command to create a bind mount has to be issued on the Proxmox host. Prior to doing that you have to ensure that the path to the device (volume) is present in the Proxmox host and the path where you want to mount it has to be present in the container (as the container sees it).
For instance, if you want to bind mount your host’s /mnt/externaldrive to the container’s /mnt/externaldrive you should ensure that those paths are there in both the host and the container.
First shutdown the container then issue the example command below:
sudo pct set <containerID> -mp0 /mnt/externaldrive,mp=/mnt/externaldrive
Substitute your container id (e.g., 100) for the <containerID>
Notice there’s no space between the “,” and the “mp”. Also note the “=” sign.
The above command will set the mount point from the host’s /mnt/externaldrive to the container’s /mnt/externaldrive.
After you have issued the command you would then start the container. You can do that with:
sudo pct start <containerID>
Or you can start it from the webui.
After that you should login to the container and go to that path (/mnt/externaldrive) and verify that the files you are looking for are there. Obviously if your drive is empty there won’t be any data.
Some other things to note are that, as I stated above, you do this on the Proxmox host. What that command to set the bind mount does is it edits the configuration file for the container. These files are located in the /etc/pve/lxc folder on the proxmox host. You can sudo nano <containerID>.conf and either manually add the line (if you know the exact syntax) instead of doing it through the pct set command.