Best practice for NAS storage with Linux DVR

Been running Channels DVR on a Ubuntu Server VM in KVM and store my files on my NAS, Open Media Vault. I currently use FSTAB to mount the NAS storage on startup. This is not the best option because it fails silently just writing to the OS disk at the same directory if the mount fails until the space is full. Anyone have any better options or is the a Linux OS I can use that handles this better? I would prefer not to use Windows and Mac OS VMs because they use to many server resources.

I would think the best solution would be to determine why the NFS mounts are failing and fix that problem.

I’ve used NFS in a business environment, between multiple flavours of Unix, Xenix and Linux for years and never had a problem with it.

Alternatively, you could do something like

00,05,10,15,20,25,30,35,40,45,50,55 * * * * mount |grep 'mount_point' >/dev/null || mount -t nfs host:exported_thing mount_point

In a root crontab.

No doubt, in this case I did not leave enough time between my NAS VM boot and my Channels DVR VM boot. Still would prefer a solution that did not fail silent.

[quote=“ams123, post:3, topic:7519, full:true”]
No doubt, in this case I did not leave enough time between my NAS VM boot and my Channels DVR VM boot.[/quote]
I’m confused. It shouldn’t be a problem until the DVR tries to write to the space. What does the DVR starting up have to do with it?

Perhaps I’m just dim, this morning, but I do not understand what is the failure mode.

So here is my line in FSTAB.

//192.168.10.7/Media/ChannelsDVR/ /home/dvr/RecordedTV cifs guest,uid=dvr,gid=dvr,rw,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0

If the NAS is not up and running first the directory ChannelsDVR is not mounted to the location RecordedTV and the DVR just writes to the folder on the OS drive.

Well, then, I guess the solution is to make sure the DVR service doesn’t start up until the NFS mount is complete and the NFS mount isn’t attempted unless the NAS is up.

You could run a cron job that looks for the mount and emails you if it doesn’t see it. Something like

00,05,10,15,20,25,30,35,40,45,50,55 * * * * mount |grep 'mount_point' >/dev/null || echo "DVR Mount Failed!" |mail -s "DVR Mount Failed!" [email protected]

You’ve kind of changed the story, though. Originally you said it was a problem with NFS mounts. Now it’s the NAS sometimes isn’t on-line when the server boots.

I don’t know what to tell you. The stuff works the way it works. The NAS has to be up when the NFS mount is attempted and the NFS mount has to be complete when the DVR service starts up. (They must be doing an open on the directory on startup and using that filehandle for subsequent operations, rather than getting new filehandles for new directory objects.)

I know of no better way to do what you’re trying to do.

ETA: Are you running your Linux instance and Open Media Vault on the same bit of hardware, by chance?

As you know from this, the way Linux works the mount point needs to exist, so to Channels (or any app) it’ll write there since the folder exists. What you could do is a systemd script that makes the folder and mounts your share on start and on stop it unmounts the folder and then removes the folder.

[Unit] Description=Mount ChannelsDVR to /mnt/ChannelsDVR After=network.target [Service] Type=simple User=root ExecStartPre=/bin/mkdir /home/dvr/RecordedTV ExecStart=/usr/bin/mount.cifs -o guest,uid=dvr,gid=dvr,rw,iocharset=utf8,file_mode=0777,dir_mode=0777 //192.168.10.7/Media/ChannelsDVR/ /home/dvr/RecordedTV ExecStop=/usr/bin/umount /home/dvr/RecordedTV ExecStop=/bin/rmdir /home/dvr/RecordedTV Restart=always [Install] WantedBy=multi-user.target

Disclaimer: I just made this up so don’t expect it to work with a copy and paste it might need tweaking.

2 Likes

Yes they are both VMs on the same server so the first thing I did was increase the delay between OMV launching and and the channels Linux VM. Will take a look at adding that crown job. Thanks for the feedback, was just making sure I was not missing a better way to do it.

Then why don’t you simply use the storage in the Linux instance? ISTM you’re making this harder than it has to be.

Yes, the mount point needs to exist, but it doesn’t have to be writable.

I usually change the owner to root:root and the permissions to a-rwx for mount points, specifically so I won’t end up with a ‘shadow’ directory tree if a mount fails, particularly since that shadow is hidden when the mount succeeds later.

1 Like

There’s also the mount unit in systemd (https://www.freedesktop.org/software/systemd/man/systemd.mount.html) and a companion automount unit: (https://www.freedesktop.org/software/systemd/man/systemd.automount.html). Between those two, seems like it’d be easy to do it ‘on demand’ when the mount succeeds.

I would suggest you also set up some kind of notification to catch it if it didn’t work. I suggest ‘PushBullet’ (https://www.pushbullet.com/) as a good way to do that - it’s pretty easy to send a notification with a simple curl command. I do that for long builds, so I get notified of success or failure as soon as it happens. Nothing worse than finding something else to do for a couple of hours, only to return and find it failed after 10 minutes.

  • Paul
1 Like

ISTM you’re making this harder than it has to be.

True, but since there is no Channels Mac app I need to share the recorded TV folder for viewing on Mac and copying TV to hard drive for travel.

So put it in a local Linux filesystem and export it from there.

Simpler is nearly always better :slight_smile: