10.xx.xx.xx:/mnt/user/data /mnt/data nfs soft,intr,timeo=10,retrans=2,_netdev,x-systemd.automount,noatime 0 0
10.xx.xx.xx:/mnt/user/data /mnt/data nfs soft,intr,timeo=10,retrans=2,_netdev,x-systemd.automount,noatime 0 0
10.xx.xx.xx:/mnt/user/data /mnt/data nfs soft,intr,timeo=10,retrans=2,_netdev,x-systemd.automount,noatime 0 0
sudo systemctl daemon-reload
sudo umount /mnt/data
sudo systemctl restart mnt-data.mount
sudo systemctl daemon-reload
sudo umount /mnt/data
sudo systemctl restart mnt-data.mount
sudo systemctl daemon-reload
sudo umount /mnt/data
sudo systemctl restart mnt-data.mount
#!/bin/bash
# Monitor NFS health and restart containers when it recovers CHECK_INTERVAL=30
STATE_FILE="/tmp/nfs-state" while true; do # Test if NFS is actually working (not just mounted) if timeout 2 ls /mnt/data/media >/dev/null 2>&1; then new_state="ok" else new_state="bad" fi old_state=$(cat "$STATE_FILE" 2>/dev/null || echo "unknown") echo "$new_state" > "$STATE_FILE" # If it just recovered, restart containers if [ "$old_state" = "bad" ] && [ "$new_state" = "ok" ]; then echo "[$(date)] NFS recovered - restarting media-stack" cd /home/youruser/docker/media-stack && docker compose restart fi sleep $CHECK_INTERVAL
done
#!/bin/bash
# Monitor NFS health and restart containers when it recovers CHECK_INTERVAL=30
STATE_FILE="/tmp/nfs-state" while true; do # Test if NFS is actually working (not just mounted) if timeout 2 ls /mnt/data/media >/dev/null 2>&1; then new_state="ok" else new_state="bad" fi old_state=$(cat "$STATE_FILE" 2>/dev/null || echo "unknown") echo "$new_state" > "$STATE_FILE" # If it just recovered, restart containers if [ "$old_state" = "bad" ] && [ "$new_state" = "ok" ]; then echo "[$(date)] NFS recovered - restarting media-stack" cd /home/youruser/docker/media-stack && docker compose restart fi sleep $CHECK_INTERVAL
done
#!/bin/bash
# Monitor NFS health and restart containers when it recovers CHECK_INTERVAL=30
STATE_FILE="/tmp/nfs-state" while true; do # Test if NFS is actually working (not just mounted) if timeout 2 ls /mnt/data/media >/dev/null 2>&1; then new_state="ok" else new_state="bad" fi old_state=$(cat "$STATE_FILE" 2>/dev/null || echo "unknown") echo "$new_state" > "$STATE_FILE" # If it just recovered, restart containers if [ "$old_state" = "bad" ] && [ "$new_state" = "ok" ]; then echo "[$(date)] NFS recovered - restarting media-stack" cd /home/youruser/docker/media-stack && docker compose restart fi sleep $CHECK_INTERVAL
done
[Unit]
Description=NFS Mount Health Monitor
After=docker.service [Service]
Type=simple
User=youruser
Group=youruser
ExecStart=/home/youruser/docker/nfs-monitor.sh
Restart=always
RestartSec=10 [Install]
WantedBy=multi-user.target
[Unit]
Description=NFS Mount Health Monitor
After=docker.service [Service]
Type=simple
User=youruser
Group=youruser
ExecStart=/home/youruser/docker/nfs-monitor.sh
Restart=always
RestartSec=10 [Install]
WantedBy=multi-user.target
[Unit]
Description=NFS Mount Health Monitor
After=docker.service [Service]
Type=simple
User=youruser
Group=youruser
ExecStart=/home/youruser/docker/nfs-monitor.sh
Restart=always
RestartSec=10 [Install]
WantedBy=multi-user.target
chmod +x /home/youruser/docker/nfs-monitor.sh
sudo cp /home/youruser/docker/nfs-monitor.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now nfs-monitor.service
chmod +x /home/youruser/docker/nfs-monitor.sh
sudo cp /home/youruser/docker/nfs-monitor.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now nfs-monitor.service
chmod +x /home/youruser/docker/nfs-monitor.sh
sudo cp /home/youruser/docker/nfs-monitor.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now nfs-monitor.service
sudo journalctl -u nfs-monitor.service -f
sudo journalctl -u nfs-monitor.service -f
sudo journalctl -u nfs-monitor.service -f
[Feb 09 13:24:15] NFS recovered - restarting media-stack
[Feb 09 13:24:15] NFS recovered - restarting media-stack
[Feb 09 13:24:15] NFS recovered - restarting media-stack - soft – Operations fail quickly instead of hanging forever
- intr – Allows interrupting stuck operations
- timeo=10,retrans=2 – Timeout after 1 second, retry twice
- x-systemd.automount – Auto-mount when accessed - When Unraid reboots, the NFS share becomes inaccessible
- The monitor detects it’s down (state = “bad”)
- When Unraid comes back, the mount auto-reconnects
- The monitor detects it’s working again (state = “ok”)
- It automatically restarts the media-stack containers
- Containers get fresh file handles and everything works - Make NFS fail gracefully (soft mount)
- Detect when it recovers (simple health check)
- Restart containers (one docker compose command) - Why Docker Compose and .env Can Break NFS Bind Mounts
- Provision Ubuntu VMs with NoCloud on Proxmox
- Automate Proxmox VMs with Cloud-Init