No description
bindmounts.service | ||
bindmounts.sh | ||
LICENSE | ||
proxmox-bindmounts.conf | ||
README.md |
Proxmox Bind Mount Script
A lightweight script to manage bind mounts across multiple Proxmox containers. This script allows for easy configuration of shared storage across containers and persists configuration for subsequent boots.
Features
- Interactive first-time setup
- Persistent configuration storage
- Path validation
- Safe unmounting and cleanup
- systemd integration
- Reconfiguration support
Prerequisites
- Proxmox VE installed
- Root or sudo access
- Basic understanding of bind mounts
- ZFS if using ZFS storage (recommended)
Installation
- Save the script to
/opt/bindmounts.sh
:
sudo wget -O /opt/bindmounts.sh https://your-script-location
# or copy manually using your preferred method
- Make the script executable:
sudo chmod +x /opt/bindmounts.sh
- Create the systemd service file at
/etc/systemd/system/bindmounts.service
:
[Unit]
Description=Bind mounts for containers
Requires=zfs.target
After=zfs.target
[Service]
ExecStart=/opt/bindmounts.sh up
ExecStop=/opt/bindmounts.sh down
[Install]
WantedBy=multi-user.target
- Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable bindmounts
sudo systemctl start bindmounts
First-Time Setup
On first run, the script will prompt for:
- Mount source path (e.g., /z/media)
- Mount target path (e.g., /media)
- Container base path (e.g., /z/pve)
- Container IDs (space-separated list)
This configuration is stored in /etc/proxmox-bindmounts.conf
Usage
Basic Commands
- Mount all configured containers:
sudo /opt/bindmounts.sh up
- Unmount all containers:
sudo /opt/bindmounts.sh down
- Reconfigure settings:
sudo /opt/bindmounts.sh reconfigure
Service Management
Start the service:
sudo systemctl start bindmounts
Stop the service:
sudo systemctl stop bindmounts
Check service status:
sudo systemctl status bindmounts
Configuration File
The configuration is stored in /etc/proxmox-bindmounts.conf
with the following format:
MNT_SOURCE="/path/to/source"
MNT_TARGET="/path/to/target"
CT_BASE="/path/to/container/base"
CT_IDS=(101 102 103)
Security Considerations
- The configuration file is created with 600 permissions (readable only by root)
- The script validates paths before mounting
- Unmounting is performed safely with proper cleanup
Troubleshooting
-
If mounts fail:
- Check if source and target paths exist
- Verify container IDs are correct
- Check system logs:
journalctl -u bindmounts
-
If configuration is corrupted:
- Run
sudo /opt/bindmounts.sh reconfigure
- Or manually edit
/etc/proxmox-bindmounts.conf
- Run
Limitations
- Currently supports one shared mount point across all configured containers
- Requires manual configuration of systemd dependencies if not using ZFS
- Must be run as root or with sudo privileges
Contributing
Feel free to submit issues and pull requests to improve the script.
License
This script is provided "as is", without warranty of any kind. Use at your own risk.