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:
Put this content into the file:
#!/bin/bash
list=$(ls /mnt/pve)
for i in $list
do
status=$(ls /mnt/pve/$i 2>&1)
if [[ $status =~ .*Stale.* ]]
then
umount /mnt/pve/$i
fi
done
Remember to make the script executable by the user creating it:
Add a cron job for this script to run automatically:
With 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.