[mythtv-users] Storage directory file system: too easy to unmount?

Stephen Worthington 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?
>
>Thanks,
>Dave

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
[Unit]
Description=Check free space on /
After=time-sync.target
OnFailure=notify-failure@%n.service

[Service]
ExecStart=/bin/bash -c "/usr/local/bin/check-free-space.sh"

[Install]
WantedBy=multi-user.target

root at mypvr:/etc/systemd/system# cat check-free-space.timer
[Unit]
Description=Hourly root free space check.

[Timer]
OnCalendar=hourly
Persistent=true

[Install]
WantedBy=timers.target

root at mypvr:/etc/systemd/system# cat notify-failure at .service
#notify-failure at .service:

[Unit]
Description=OnFailure for %i

[Service]
Type=oneshot
ExecStart=/usr/local/bin/onfailure.sh %i

root at mypvr:/usr/local/bin# cat check-free-space.sh
#!/bin/bash

DEFAULT_MIN=16106127360

if [ -z "$1" ]; then
    min_required=$DEFAULT_MIN
else
    REGEX="^[[:digit:]]*$"
    if ! [[ $1 =~ $REGEX ]] ; then
        min_required=$DEFAULT_MIN
    elif [[ $1 -eq 0 ]]; then
        min_required=$DEFAULT_MIN
    else
        min_required=$1
    fi
fi

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
on
    # mythconverg.recordedseek table.
    echo "Free space too low (< $min_required)"
    exit 1
fi

# Free space is sufficient.
echo "Free space is sufficient (>= $min_required)"
exit 0

root at mypvr:/usr/local/bin# cat onfailure.sh
#!/bin/bash

#
# Author: Kyle Manna <kyle at kylemanna.com>
#
# Simple systemd script used to be called via something like:
#
# Example Unit section of a service file:
#
# [Unit]
# ...
# Onfailure=failure-email@%i.service
#
#
# failure-email at .service:
#
# [Unit]
# Description=OnFailure for %i
#
# [Service]
# Type=oneshot
# ExecStart=/path/to/onfailure.sh %i
#

svc=${1-unknown}
email="root ******@************* ******@********"

cat <<EOF | sendmail -i "$email"
Subject: [$HOSTNAME] OnFailure Email for $svc
# Status
$(systemctl status -l -n 1000 "$svc")
EOF


More information about the mythtv-users mailing list