Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.
Western Digital Drives - The Preferred Drives of FreeNAS and TrueNAS CORE

Cannot write to content dirs('/var/db/zoneminder/events','/var/db/zoneminder/images')

boggie1688

Junior Member
Joined
Jul 9, 2015
Messages
21
Hi Everyone,

I recently installed the zoneminder plugin. Easy enough. I connected my IP cam, and confirmed it is pulling a live video stream correctly.

Next I created a dataset in my pool, and assigned it to username 'media' and group 'media'.
/mnt/Toshiba5TB/Security

Next I created two mounting points for zoneminder for the iocage:
/var/db/zoneminder/events
/var/db/zoneminder/images

I assume this is were zoneminder wants to save its recorded files. FWIW this camera will record 24/7.

Lastly, in the zoneminder jail I did the following:

  • In the jail, add a user with a matching UID as the owner of the data dataset/folders.
    • Code:
      pw useradd -n media -u 818 -d /nonexistent -s /usr/sbin/nologin
  • In the jail, change the user the plugin runs as, and change ownership of the data-directory.
    • Code:
      service zoneminder onestop
      chown -R media:media /var/db/zoneminder
      sysrc 'zoneminder_user=media'
      service zoneminder start

Unfortunately, inside the zoneminder logs I keep getting this error:
Cannot write to content dirs('/var/db/zoneminder/events','/var/db/zoneminder/images'). Check that these exist and are owned by the web account user

Previously in my other jails, I've change the jail user to media (like above) and had no issues with the plugin writing to the mounting point.

Any help is greatly appreciated.

Thanks!
 

boggie1688

Junior Member
Joined
Jul 9, 2015
Messages
21
Started with a fresh install, and immediately changed the storage to:
/usr/local/zoneminder

Add a mount point for /mnt/Toshiba5TB/Security to /usr/local/zoneminder

Then
  • In the jail, add a user with a matching UID as the owner of the data dataset/folders.
    • Code:
      pw useradd -n media -u 818 -d /nonexistent -s /usr/sbin/nologin
  • In the jail, change the user the plugin runs as, and change ownership of the data-directory.
    • Code:
      service zoneminder onestop
      chown -R media:media /usr/local/zoneminder
      sysrc 'zoneminder_user=media'
      service zoneminder start

In the log I get:
2019-12-02 05:25:01zma_m1101798ERRCan't mkdir /usr/local/zoneminder/1: Permission deniedzm_event.cpp128
2019-12-02 05:25:01zma_m1101798ERRCan't mkdir /usr/local/zoneminder/1/2019-12-01: Permission deniedzm_event.cpp169
2019-12-02 05:25:01zma_m1101798ERRCan't mkdir /usr/local/zoneminder/1/2019-12-01/9: Permission deniedzm_event.cpp174
2019-12-02 05:25:01zma_m1101798ERRFailed creating mp4 file: /usr/local/zoneminder/1/2019-12-01/9/9-video.mp4zm_video.cpp179
2019-12-02 05:25:01zma_m1101798ERRFailed opening video streamzm_event.cpp215
2019-12-02 05:25:01zma_m1101798INFGarage: 001 - Opening new event 9, section startzm_monitor.cpp1482
2019-12-02 05:25:01zma_m1101798ERRCan't open /usr/local/zoneminder/1/2019-12-01/9/snapshot.jpg: Permission denied

For the life of me I can't figure out why the jail cannot write to the dataset. My sabnzbd jail follow this exactly, and it can write perfectly fine.
 

boggie1688

Junior Member
Joined
Jul 9, 2015
Messages
21
I should note, under the storage section of zoneminder, it is clearly seeing my mount point. I can see the remaining storage left on the Pool.

For whatever reason I just cannot write to the dataset, even though this is exactly the user I am using in my other jails. What gives?!
 

sretalla

Dedicated Sage
Joined
Jan 1, 2016
Messages
2,709
From inside the jail (iocage console jailname), what does an ls -l look like for either of those directories?

It may be that you need to also add the sysrc for zoneminder_group and have that match up to something that has the rights. (I agree that the user should be enough, so let's look at the ls -l first)
 

boggie1688

Junior Member
Joined
Jul 9, 2015
Messages
21
So I'll be the first to admit I'm an absolute newbie when it comes to all of this. I learn as I go along, and if I'm honest, I've used freenas for a years now. However, I just know enough to get what I need going and stop.

I never new about the ls -l command, which is awesome!!!

So before you posted this, by sheer luck I read that someone changed their user:group to www:www. I so I simply changed my dataset permission to media:www instead of media:media. This worked. But I read our post, and I got curious.

ls -l /var/db/zoneminder shows:
www:www

Why that is the user:group that owns that folder right out of the box is beyond me.

So then for the sake of experimenting, I went back and
ls -l /usr/local/zoneminder
which showed:
media:www

I stopped the service then
sysrc 'zoneminder_group=media'
chown -R media:media /usr/local/zoneminder.
Then one last time I
ls -l /usr/local/zoneminder
which showed:
media:media

Changed my dataset back to media:media, instead of media:www. And.....failed to write. If I go back and change everything to the media:www, everything works again. So no idea whats going on here, maybe it has something to do with the www:www right out of the box? But everything is working as it should.


All in all, I appreciate the help! I learned something. Curious, do you know why changing the group to media doesn't seem to work? I'm more curious to understand whats going vs get it all working...now that it is all working.
 

sretalla

Dedicated Sage
Joined
Jan 1, 2016
Messages
2,709
I imagine that this is a PHP-based web application is probably part of the story, meaning that the user is sometimes the service and hence the user you set with sysrc and sometimes the PHP code, so perhaps then the www user.

Great to hear it's working and that you're on your way to figuring it all out.
 
Top