No description
Find a file
2024-12-08 08:33:33 +05:30
bindmounts.service Add bindmounts.service 2024-12-08 08:32:43 +05:30
bindmounts.sh Add bindmounts.sh 2024-12-08 08:33:33 +05:30
LICENSE Initial commit 2024-12-08 08:30:53 +05:30
proxmox-bindmounts.conf Add proxmox-bindmounts.conf 2024-12-08 08:32:16 +05:30
README.md Update README.md 2024-12-08 08:31:15 +05:30

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:
sudo wget -O /opt/bindmounts.sh https://your-script-location
# or copy manually using your preferred method
  1. Make the script executable:
sudo chmod +x /opt/bindmounts.sh
  1. 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
  1. 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

  1. Mount all configured containers:
sudo /opt/bindmounts.sh up
  1. Unmount all containers:
sudo /opt/bindmounts.sh down
  1. 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

  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.