DEV Community

Cover image for Weekend Rec Build: cifs-watch
Keith Solomon
Keith Solomon

Posted on • Originally published at keithsolomon.net

Weekend Rec Build: cifs-watch

It all started with an email from my Proxmox box, saying that the boot partition was out of space…

Every homelab has that one little annoyance that slowly drives you up the wall. For me, it was CIFS shares occasionally dropping off the radar. Sometimes it’s the network hiccuping, sometimes it’s the file server rebooting, and sometimes it’s just gremlins. Either way, when a mount goes stale, it breaks workflows and backups alike. So this weekend’s build tackled exactly that.
The Problem

I’ve got a handful of CIFS mounts defined in /etc/fstab across several machines, all pointing back to my central file server. When that server or a network hop goes down, the mounts don’t always recover cleanly. Manually remounting them works fine, but doing that across half a dozen machines? Not sustainable.
The Solution

Enter cifs-watch — a lightweight Bash script that monitors all CIFS mounts listed in /etc/fstab, checks if they’re reachable, and automatically remounts them when they’re not. It’s polite about it too: it verifies that the file server is online first, logs its actions, and only touches mounts that actually need fixing.

Think of it as a health check for your network shares. The script runs silently in the background, and you can set it up as a systemd timer or cron job depending on your setup.

How It Works

It’s a very simple script at it’s heart. There are four main processes it wraps:

  • Scans /etc/fstab for lines using the cifs filesystem type.
  • Verifies whether each mount target is currently available.
  • Pings the host to confirm it’s up before attempting a remount.
  • Logs every action — successful checks, reconnections, and errors — to /var/log/cifs-watch.log.

Setup is simple: drop the script into /usr/local/bin/, make it executable, and add it to cron or a timer unit. That’s it. Your mounts stay connected, your logs stay clean, and your sanity stays intact.

Why It Matters

In the spirit of Weekend Rec Builds, cifs-watch isn’t a massive overhaul or flashy new service — it’s one of those little quality-of-life automations that keeps the lab running smoothly. Small scripts like this free up brainspace for the next big idea (and save a few “why isn’t this mounted?” headaches along the way).

Top comments (0)