Delay TVHeadend Start Until After fstab mount?
Added by Anonymous almost 5 years ago
I am running tvheadend v4.2.8-36 from the repository (https://tvheadend.org/projects/tvheadend/wiki/AptRepositories) on Linux Mint 19.3.
The recording & timeshift directories are on a NFS share mounted via /etc/fstab.
Tvheadend ran fine for about 6 months on this system. I'm not a Linux expert, but it seems like a kernel update changed the timing of startup actions. First the NFS shares stopped mounting properly. I fixed that by adding "bg" to the entry options in fstab so it keeps retrying.
Now it seems tvheadend is looking for the mounts too soon and can't find the files. So is there a way to have tvheadend wait until fstab is finished mounting everything? I know there are some functions like this for systemd, but it looks like tvheadend runs from init.d? That is a bit beyond my skill level so far.
Now I have to remember to type "service tvheadend restart" after every reboot.
I saw another thread about delaying tvheadend start, but waiting for fstab to finish seems more robust, if possible.
Any info appreciated. Thanks
Replies (5)
RE: Delay TVHeadend Start Until After fstab mount? - Added by Teddy Thomas almost 5 years ago
I have actually encountered something similar a couple of days ago when swapping an external drive that seems to make partition mounting slower.
Anyway, I have not tested this much (barely tested actually), but it seems to work.
I added a while loop to the do_start function in /etc/init.d/tvheadend, right before the line "udevadm settle".
The while loop is:
while ! mountpoint -q /your/mount/point
do
sleep 1
done
I am not an expert in init.d scripts, so not sure if that is "the right" solution. Also, if you have several mount points, I am guessing you can combine them in your condition, but there may be more elegant solutions.
I would also be happy to hear if/how it works for you.
RE: Delay TVHeadend Start Until After fstab mount? - Added by Dave H almost 5 years ago
C H wrote:
I am running tvheadend v4.2.8-36 from the repository (https://tvheadend.org/projects/tvheadend/wiki/AptRepositories) on Linux Mint 19.3.
The recording & timeshift directories are on a NFS share mounted via /etc/fstab.
Do the entries in /etc/fstab have the _netdev attribute? If not, they should have.
Tvheadend ran fine for about 6 months on this system. I'm not a Linux expert, but it seems like a kernel update changed the timing of startup actions. First the NFS shares stopped mounting properly. I fixed that by adding "bg" to the entry options in fstab so it keeps retrying.
Now it seems tvheadend is looking for the mounts too soon and can't find the files. So is there a way to have tvheadend wait until fstab is finished mounting everything? I know there are some functions like this for systemd, but it looks like tvheadend runs from init.d? That is a bit beyond my skill level so far.
I don't use mint but I believe that 19.3 uses systemd. So any init scripts are actually translated by systemd and run as systemd facilities anyway. I haven't done it myself but I believe you should be able to add a drop-in file to add a systemd dependency to tvheadend. I think you'd want to make it depend on remote-fs.target
Now I have to remember to type "service tvheadend restart" after every reboot.
I saw another thread about delaying tvheadend start, but waiting for fstab to finish seems more robust, if possible.
Any info appreciated. Thanks
RE: Delay TVHeadend Start Until After fstab mount? - Added by Anonymous almost 5 years ago
Teddy, thank you for the reply. That worked!
Dave H, yes _netdev was the only option I had before. With both options, it is now _netdev,bg
To add the "remote-fs.target" thing, I need to find a tutorial or guide. Or if you could provide some more details. Thanks for the suggestion.
RE: Delay TVHeadend Start Until After fstab mount? - Added by Dave H almost 5 years ago
If you're still interested in experimenting, I suggest the first step would be to find the tvheadend.service file, which you should be able to do by executing:
systemctl status tvheadend
and then look to see the full path of the file. You could then look at the file to see what you need to alter. The official doc is at https://www.freedesktop.org/software/systemd/man/systemd.unit.html but https://wiki.archlinux.org/index.php/systemd#Drop-in_files might be easier to use. Or post the tvheadend.service file here and we can suggest what to do.
RE: Delay TVHeadend Start Until After fstab mount? - Added by Mandeep Singh almost 5 years ago
I was able to solve this issue by setting a Delay of 10s in Tvheadend Addon-Settings. ... This makes kodi start after network becomes active [[https://www.checkforpc.com/]]