# 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 1. Save the script to `/opt/bindmounts.sh`: ```bash sudo wget -O /opt/bindmounts.sh https://your-script-location # or copy manually using your preferred method ``` 2. Make the script executable: ```bash sudo chmod +x /opt/bindmounts.sh ``` 3. Create the systemd service file at `/etc/systemd/system/bindmounts.service`: ```ini [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 ``` 4. Enable and start the service: ```bash 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 1. Mount all configured containers: ```bash sudo /opt/bindmounts.sh up ``` 2. Unmount all containers: ```bash sudo /opt/bindmounts.sh down ``` 3. Reconfigure settings: ```bash sudo /opt/bindmounts.sh reconfigure ``` ### Service Management Start the service: ```bash sudo systemctl start bindmounts ``` Stop the service: ```bash sudo systemctl stop bindmounts ``` Check service status: ```bash sudo systemctl status bindmounts ``` ## Configuration File The configuration is stored in `/etc/proxmox-bindmounts.conf` with the following format: ```bash 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 1. If mounts fail: - Check if source and target paths exist - Verify container IDs are correct - Check system logs: `journalctl -u bindmounts` 2. If configuration is corrupted: - Run `sudo /opt/bindmounts.sh reconfigure` - Or manually edit `/etc/proxmox-bindmounts.conf` ## 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.