Redirect Events and Images to NAS

Forum for questions and support relating to the 1.27.x releases only.
Locked
Biggus
Posts: 96
Joined: Mon Nov 18, 2013 9:15 am

Redirect Events and Images to NAS

Post by Biggus »

I've attached my NAS to Ubuntu 14.04 via fstab.

I've put the below in my fstab file.

Code: Select all

//blackbox/network  /mnt/blackbox  cifs  username=(myusername),password=(mypassword),iocharset=utf8,sec=ntlm  0  0
I can browse to the NAS in Ubuntu fine, my next step is to re-direct Zoneminder events.

I followed this guide http://www.zoneminder.com/wiki/index.ph ... Hard_Drive

It stated I needed to update my fstab file with the below

Code: Select all

/mnt/blackbox/Zoneminder/Images /usr/share/zoneminder/images none defaults,bind  0 2
/mnt/blackbox/Zoneminder/Events /usr/share/zoneminder/events none defaults,bind 0 2
/mnt/blackbox/Zoneminder/Images /var/cache/zoneminder/images none defaults,bind  0 2
/mnt/blackbox/Zoneminder/Events /usr/cache/zoneminder/events none defaults,bind 0 2
However this doesn't work, no events are been placed here, no files are generated, when using the ZM GUI I can see the events but nothing will play back (I suspect this is because no files have been generated)

What am I doing wrong?
Biggus
Posts: 96
Joined: Mon Nov 18, 2013 9:15 am

Re: Redirect Events and Images to NAS

Post by Biggus »

OK I managed to get this working.

I figured that connecting via CIFS wasn't the solution and was better using NFS since its more native to Linux. So I connected to my NAS and enabled NFS.

I next had to install NFS support on my Ubuntu 14.04 install.

Code: Select all

apt-get install nfs-kernel-server
Next I had to create a directory on the file system to mount my NAS too.

Code: Select all

mkdir /mnt/blackbox
Great! I now need to set my Ubuntu install to map the NAS to the directory every time it boots up, to do this I needed to edit the FSTAB file.

Code: Select all

nano /etc/fstab
Add the command in to map my NAS to the directory.

Code: Select all

192.168.0.2:/Network /mnt/blackbox nfs _netdev,auto 0 0
Now we have to redirect the ZM events and images folder, so still in the fstab file I added the following.

Code: Select all

/mnt/blackbox/CCTV/Images /usr/share/zoneminder/images none defaults,bind  0 2
/mnt/blackbox/CCTV/Events /usr/share/zoneminder/events none defaults,bind 0 2
/mnt/blackbox/CCTV/Images /var/cache/zoneminder/images none defaults,bind  0 2
/mnt/blackbox/CCTV/Events /usr/cache/zoneminder/events none defaults,bind 0 2
Saved everything and rebooted. It still didn't work, however this was down to permissions. I had to do the following, this will allow ZM to write to the directorys on my NAS.
Please note: I had to enable root access on my NAS to enable the following commands to work.

Code: Select all

sudo chown www-data:www-data /mnt/blackbox/CCTV/Events
sudo chown www-data:www-data /mnt/blackbox/CCTV/Images
Rebooted everything and it all worked spot on.
User avatar
knight-of-ni
Posts: 2406
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Redirect Events and Images to NAS

Post by knight-of-ni »

The document you referenced is intended for a dedicated hard drive, not a network share, as the name of document implies.
Yes, you got it working, but there are some additional items worth noting that the document does not mention:

- Mounting network shares via fstab works as long as the network share is available. If you try to boot the zoneminder machine while the network share is not on the network, for any reason, you'll find that your machine will hang at boot....or take a really, really long time to boot. Instead, you may want to look into the tool called autofs. It is designed to work around this as it will mount your shares on-demand and won't hang up the box if the resource is unavailable.

- For those that only want to install the NFS client on their machine instead of the full blown NFS server, the package you need is called "nfs-common" rather than "nfs-kernel-server".

- With NFS, sometimes you have to create an account on the nfs server with the same name and uid as the account on the client. If not, you may see your files as owned by "nobody" even though you just did a chown www-data on the files. This affects newer versions of NFS such as the version that ships with Ubuntu.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
mikb
Posts: 704
Joined: Mon Mar 25, 2013 12:34 pm

Re: Redirect Events and Images to NAS

Post by mikb »

knnniggett wrote:- Mounting network shares via fstab works as long as the network share is available.
On that thought, what happens when zmaudit discovers a database full of event entries, but the network share didn't mount/fell off?

Won't it start going through the database saying "this event no longer exists on disk, cleaning the database up" ??
User avatar
knight-of-ni
Posts: 2406
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Redirect Events and Images to NAS

Post by knight-of-ni »

mikb wrote:
knnniggett wrote:- Mounting network shares via fstab works as long as the network share is available.
On that thought, what happens when zmaudit discovers a database full of event entries, but the network share didn't mount/fell off?

Won't it start going through the database saying "this event no longer exists on disk, cleaning the database up" ??
Yes, that is the risk of using remote storage. By backing up the database on a regular basis, you have a chance to recover most of the events should this occur.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
Locked