Proxmox has a neat UI for adding extra storage to containers. However, if that storage already exists somewhere or needs to exist for more than one container, you're SOL. Bind mounting is an easy way to take a mount and make it exist in more than one place. However, bind mounting has to be done in a particular order with Proxmox due to how it creates device nodes and pre-populates directories. This is very frustrating, but not unsolvable.
If you are using ZFS for your storage (which you should), you need to ensure that all of ZFS's mounts are fully online before proxmox does anything. You will need to add After=zfs.target
to the [Unit]
section of the Proxmox Systemd service files. The change needs to be applied to the following files:
/lib/systemd/system/pve-cluster.service
/lib/systemd/system/pve-ha-crm.service
/lib/systemd/system/pve-ha-lrm.service
/lib/systemd/system/[email protected]
/lib/systemd/system/pve-firewall.service
/lib/systemd/system/pvefw-logger.service
/lib/systemd/system/pve-daily-update.service
/lib/systemd/system/pve-guests.service
/lib/systemd/system/pvebanner.service
/lib/systemd/system/pvedaemon.service
/lib/systemd/system/pvenetcommit.service
/lib/systemd/system/pveproxy.service
/lib/systemd/system/pvesr.service
/lib/systemd/system/pvestatd.service
You will need to make a simple script that can be run by Systemd that can do a little cleanup and perform the mounts. An example should be attached to this gist a bit further down. Copy it to /opt/
and be sure to chmod it to be executable.
The Systemd service file that you want is included below. Copy it to /etc/systemd/system/
and do the following commands:
systemctl daemon-reload
systemctl enable bindmounts
The next time you reboot your host[s], this should allow all containers with the shared bind mount to come up properly. You can also do systemctl start bindmounts
if you would like to mount the paths for running containers.
- This method, while based on recommendations from Proxmox staff, is unsupported and has a chance of data loss. Use it at your own risk, and under no expectation of warranty.
- I have not tested this in what one might call a "production" environment. I am using it at home with some success, but that's about it.
- I plan to replace the bindmounts Bash script with a Python version. This will enable more complex mount definitions, such as more than one mount per container, containers that get different mounts from their neighbors, etc. This will be done as I have time.