Proxmox | automatically restore SMB/CIFS share connections
If at some point Proxmox loses connectivity with an SMB/CIFS share, it will not restore the connection by itself until a restart of the Proxmox node is performed. With the script below, the Proxmox node restores the connection automatically.
On the node’s shell, create a bash script that looks for mount points in /mnt/pve/ and unmounts them if they become stale:
nano remount.shPut this content into the file:
#!/bin/bashlist=$(ls /mnt/pve)
for i in $listdo status=$(ls /mnt/pve/$i 2>&1)
if [[ $status =~ .*Stale.* ]] then umount /mnt/pve/$i fidoneRemember to make the script executable by the user creating it:
chmod 766 /root/remount.shAdd a cron job for this script to run automatically:
* * * * * /root/remount.sh >/dev/null 2>&1With that, any SMB/CIFS connections are restored automatically. That is because the service pvestatd tries to remount every SMB share every 10 seconds.
This approach could work for NFS shares too, but that possibility has not been tested.