[mythtv-users] Storage directory file system: too easy to unmount?
stephen_agent at jsw.gen.nz
Fri Feb 14 01:10:05 UTC 2020
On Thu, 13 Feb 2020 10:30:07 -0600, you wrote:
>Recently, after adjusting the mount points for a few NFS file systems,
>work that involved unmounting several file systems unrelated to MythTV,
>I visited MythWeb's Recorded Programs page and discovered that all of
>the recordings lacked a thumbnail...the last time I'd checked they all
>had thumbnails. Then I ran mythfrontend and went into Watch Recordings.
>Every recording showed a gray status. Not good!
>Then I thought back to what I'd just been working on with mount points
>so I ran 'df'. What had happened is I'd accidentally unmounted the file
>system that holds my MythTV storage directories. This was possible
>because evidently mythfrontend & mythbackend only open files in the
>storage directories when they are working with them, so if no program is
>being recorded or watched the file system is free of activity and is
>thus free to be unmounted. MythWeb's thumbnails reappeared as soon as I
>mounted the file system. If I'd not discovered the unmounted file system
>I suppose I'd have had some failed recordings.
>Is there anything I can do to prevent my storage directory file system
>from being unmounted while MythTV is running or do I just need to be
>more careful in the future?
This is working as designed. It is very useful to be able to unmount
drives that might be used by MythTV but are currently not. I do it
all the time, but I have seven recording drives, so having one or
three unavailable does not cause problems. If you have only one
recording drive, then you may want to write a monitoring script that
will let you know if it is unavailable.
I have a systemd/script setup that does an hourly check for enough
free space available on my / mount point, and it will email me if the
check fails. You could use something similar. It requires that
sendmail is installed and configured (I have a minimal postfix install
that includes sendmail):
root at mypvr:/etc/systemd/system# cat check-free-space.service
Description=Check free space on /
ExecStart=/bin/bash -c "/usr/local/bin/check-free-space.sh"
root at mypvr:/etc/systemd/system# cat check-free-space.timer
Description=Hourly root free space check.
root at mypvr:/etc/systemd/system# cat notify-failure at .service
#notify-failure at .service:
Description=OnFailure for %i
root at mypvr:/usr/local/bin# cat check-free-space.sh
if [ -z "$1" ]; then
if ! [[ $1 =~ $REGEX ]] ; then
elif [[ $1 -eq 0 ]]; then
root_free_space=$(($(stat -f --format="%a*%S" /)))
echo "Free space on root is $root_free_space"
if [ $root_free_space -lt $min_required ]; then
# Free space too low for /etc/cron.daily/optimize_db to run safely
# mythconverg.recordedseek table.
echo "Free space too low (< $min_required)"
# Free space is sufficient.
echo "Free space is sufficient (>= $min_required)"
root at mypvr:/usr/local/bin# cat onfailure.sh
# Author: Kyle Manna <kyle at kylemanna.com>
# Simple systemd script used to be called via something like:
# Example Unit section of a service file:
# failure-email at .service:
# Description=OnFailure for %i
# ExecStart=/path/to/onfailure.sh %i
email="root ******@************* ******@********"
cat <<EOF | sendmail -i "$email"
Subject: [$HOSTNAME] OnFailure Email for $svc
$(systemctl status -l -n 1000 "$svc")
More information about the mythtv-users