How to configure ZM events to be stored on separate HDD?

Forum for questions and support relating to the 1.24.x releases only.
Post Reply
Posts: 1
Joined: Wed Dec 16, 2009 10:51 am

How to configure ZM events to be stored on separate HDD?

Post by formfab » Fri Dec 18, 2009 11:44 am

Hi all, my first post….

Before I ask my question here is some background and system information which may be useful to you?

I have resurrected an old PC from our stores at work for use as a CCTV recorder to replace a failed time lapse tape video recorder.

It’s minimum spec, Pentium 4 3GHz, 2GB Ram, using a 4 Channel Video/ Audio H.264 B 9404A DVR Card.

Being new to Linux and Zoneminder after a long learning curve, I have installed Ubuntu 9.10 Server Edition as a headless system running Zoneminder v1.24.1 and setup a DNS address for remote viewing. It works a treat for monitoring.

Now, my question –

As stated above the PC is of minimum spec with a low capacity HDD. Therefore, I have ordered a 1TB Samsung Spinpoint F3 due to be delivered in the next few days. I would like to keep the 80GB for the operating system and programs and use the 1TB purely for storing the recorded camera footage.

Could someone please post a step by step guide to reconfiguring the ZM events path so that footage will be stored on the new HDD. I have searched for the answer but just haven’t unearthed the answer I’m looking for. It seems I need to reconfigure apache and create links and have no idea where to start :roll: ? Help!

Also would it be advisable to create partitions for storing footage from each of the four cameras? The cameras are required to record in a continuous loop.

Any information, help and advice would be greatly appreciated.

Thanks in advance.

User avatar
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel » Sat Dec 19, 2009 6:35 am

ZM don't understand how to manage multiple partitions for each cam, you best stick with one unless you want to mod the source and teach it too.

The simplest route is to move the directory to the new partition and link to it:
Assuming you were to name you new partition "data" and the events directory is at /var/www/zm/events

Code: Select all

mv /var/www/zm/events /data/events
ln -s /var/www/zm/events /data/events
You just need to be sure that the directive "FollowSymLinks" is configured in apache for the zm folder/site.

Posts: 518
Joined: Wed Jan 30, 2008 5:53 pm
Location: St. Louis, MO, USA

Post by coke » Sat Dec 19, 2009 11:08 pm

Also consider setting up the new drive using LVM. Once setup, you can then add additional drives later and just tack them onto the LVM.

Posts: 10
Joined: Sat Jun 11, 2005 4:37 pm

Post by dasbooter » Mon Dec 21, 2009 3:27 pm

probably just to be debian "and I am better than the rest of you" Ubuntu(the fashionable trendy yet slightly mentally unstable younger brother of debian) does it this way :

Code: Select all

ln -s /path/to/real/file /path/to/non-existant/file
cordel wrote:You just need to be sure that the directive "FollowSymLinks" is configured in apache for the zm folder/site.
I am not sure about doing this part though. I can see that zoneminder still thinks it has only a few gigs left on / but I have symlinked it to a terabyte raid conf mounted under /mnt with 600 or so gigs of free space on it .... and three two one googling now for followsymlinks for apache.

Sooo this is more complicated than I thought but the thought of recompiling makes me a little ill. I have moved the events folder from /usr/share/zoneminder to /mnt and created a symlink to it in /usr/share/zoneminder. I checked in /var/log/apache2 and saw this:

Code: Select all

[Mon Dec 21 07:24:03 2009] [error] [client ::1] array (\n  0 => \n  array (\n    'file' => '/usr/share/zoneminder/ajax/stream.php',\n    'line' => 51,\n    'function' => 'ajaxError',\n    'args' => \n    array (\n      0 => 'socket_sendto( /tmp/zms-457628s.sock ) failed: No such file or directory',\n    ),\n  ),\n  1 => \n  array (\n    'file' => '/usr/share/zoneminder/index.php',\n    'line' => 116,\n    'args' => \n    array (\n      0 => '/usr/share/zoneminder/ajax/stream.php',\n    ),\n    'function' => 'require_once',\n  ),\n), referer: http://localhost/?view=event&eid=9&fid=1&&filter[terms][0][attr]=MonitorId&filter[terms][0][op]=%3D&filter[terms][0][val]=1&filter[terms][1][cnj]=and&filter[terms][1][attr]=DateTime&filter[terms][1][op]=%3E%3D&filter[terms][1][val]=2009-12-21+03%3A05%3A00&filter[terms][2][cnj]=and&filter[terms][2][attr]=DateTime&filter[terms][2][op]=%3C%3D&filter[terms][2][val]=2009-12-21+10%3A04%3A59
df: `events': No such file or directory
df: no file systems processed
df: `events': No such file or directory
df: no file systems processed
df: `events': No such file or directory
df: no file systems processed
df: `events': No such file or directory
df: no file systems processed
df: `events': No such file or directory
df: no file systems processed
so I looked around for the file that should designate the FollowSymLinks option and I think I found it under /etc/apache2/sites-enabled/ file is called 000-default and reads:

Code: Select all

<VirtualHost *:80>
	ServerAdmin webmaster@localhost

	DocumentRoot /usr/share/zoneminder
	<Directory />
		Options FollowSymLinks
		AllowOverride None
	<Directory /usr/share/zoneminder/>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Order allow,deny
		allow from all

	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
	<Directory "/usr/lib/cgi-bin">
		AllowOverride None
		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
		Order allow,deny
		Allow from all

	ErrorLog /var/log/apache2/error.log

	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn

	CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from ::1/128
I followed a tutorial and it stated to change the DocumentRoot in the above file.I couldn't access the site at first, when I originally set up, with the original configuration which use http:localhost/zm so I followed the advice of the tutorial and at least I could get to the web page but now I wonder if it might be part of the problem. I also changed the permissions to the target file on /mnt the one originally moved from /usr/share/zoneminder and at some point it started showing as a symlink to /var/cache/zoneminder/events ???? :? so now I am totally confused. This is probably not zoneminder specific but I could use a little help if possible.

Posts: 141
Joined: Sun Oct 07, 2007 5:52 pm
Location: Louisiana

Post by river100 » Wed Dec 23, 2009 3:21 am

i've done this a few times using ubuntu 8.04 and zm 1.23.3 deb.

it does work, just make sure that your permissions are good.
in the deb install they are www-data

my symlink links /usr/share/zoneminder/events to /media/ZMstorage/events.

ZMstorage is mounted it fstab
i get the correct disk percent too.

i had the step by step but lost it do to a fried flash drive.

one has a 1TB drive and gets about 44,000 events on 6 cams which is usually about 8 weeks @ 320x240 per cam motion detect 20 fps.

Posts: 10
Joined: Sat Jun 11, 2005 4:37 pm

Post by dasbooter » Wed Dec 23, 2009 3:05 pm

Thanks for the feedback. I am not sure what happened that caused the folder that I moved from /usr/share/zoneminder to become a symlink to a folder in /var/cache/zoneminder but it seemed to happen when I copied the original folder as root and then decided that I better change the permissions on it so zoneminder could for sure access it...

I am not sure what caused this behavior or if I made an error or what it was. I repeated the procedure and copied the folder from var/cache/zoneminder back to the big drive where I wanted it as a regular user I deleted the symlink that somehow got made there on the big drive that pointed to /var/cache/zoneminder then checked to make sure the symlink in /usr/share/zoneminder was still there and pointed to the folder on the big drive.

I also cleaned out the events. Events seem to be created on the big drive only now and none in /var/cache/zoneminder so thats good. I don't know if the drive percentage is correct b/c both drives (root and big drive) are currently filled about the same but I guess I will soon find out. I saw in another post that there was something you had to sort of hack to get it to read right (point to the right place) but I don't know if this was only in a past version of ZM so I will wait.

Sort of as an aside I noticed that the database still keeps going with the events from the very beginning(very begginning of install of zoneminder) number wise and I wondered if there was away to reset it back to one to start fresh?

Posts: 141
Joined: Sun Oct 07, 2007 5:52 pm
Location: Louisiana

Post by river100 » Sun Dec 27, 2009 9:18 am

i replied to your post 'cause i have done the separate events drive
addition and it worked well for me. i got my info from searching the
forums. i am by far no expert with linux.

the original "events" folder in /usr/share/zoneminder is a simlink
to /var/cache/zoneminder. that's where the actual files were stored.

as far as resetting the event numbering, it is possible, and it would
need to be done in the mysql data base. someone else would have
to tell you how, i haven't a clue.

glad to here you got it working.

it looks as though i will be at it again soon myself, i had to move my ZM
drives from the original PC since it was hit by lightning. i had alot of time in
the install, redirect to ssl and lots of other tweeks so i got lazy and just
swapped the hard drives over.
they're locking up at random in their new home. probably has something to
do with the really crappy via chipset motherboard. the original board was
an intel.


Posts: 10
Joined: Sat Oct 27, 2007 1:36 am
Location: Toronto, CA

Post by sticcino » Tue Dec 29, 2009 4:04 pm

why don't you just go into the config and specify a new directory.
i added a 2nd HD, mounted it, that's it


Posts: 1
Joined: Wed Dec 30, 2009 4:23 am

Post by norcal5150 » Wed Dec 30, 2009 4:42 am

I agree with using LVM but whether you do or do not use LVM why not mount the second drive as the default directory?

For example:

/var/lib/zm/www/events is the actual directory on my Arch Linux box I built yesterday. There are several soft links pointing to it.

1.) Stop ZoneMinder
2.) mv /var/lib/zm/www/events /var/lib/zm/www/events.tmp
3.) mkdir /var/lib/zm/www/events
4.) Edit /etc/fstab (In my case I had a 900 GB partition that I wanted to use, already mounted as /nvr)

/dev/disk/by-uuid/bb3f50b9-ad29-4753-8fdf-6763d9b55726 /nvr ext3 defaults,noatime 0 2

Modified to:

/dev/disk/by-uuid/bb3f50b9-ad29-4753-8fdf-6763d9b55726 /var/lib/zm/www/events ext3 defaults,noatime 0 2

4.) Mount the volume:
mount /var/lib/zm/www/events
5.) chmod http.http /var/lib/zm/www/events

6.) Move the contents on the original "events" directory to the new mount point:

mv /var/lib/zm/www/events.tmp/* /var/lib/zm/www/events/

7.) Delete the old directory:

rm /var/lib/zm/www/events.tmp

8.) Restart ZoneMinder

Post Reply

Who is online

Users browsing this forum: No registered users and 27 guests