Events not deleted from external hard drive

Discussions related to the 1.36.x series of ZoneMinder
Post Reply
aschouwe
Posts: 6
Joined: Thu Apr 20, 2023 1:28 am

Events not deleted from external hard drive

Post by aschouwe »

I'm experiencing a problem with ZoneMinder where event files are not being properly deleted from my external hard drive. When I delete events, either manually through the web console or automatically using filters, the events disappear from the ZoneMinder interface. However, the corresponding files and folders remain on the external hard drive where they are stored. This is happening despite having the 'Do Deletes' option enabled in ZoneMinder's settings. As a result, the hard drive space is not being freed up when events are deleted."

Any help or guidance would be much appreciated.
dougmccrary
Posts: 1336
Joined: Sat Aug 31, 2019 7:35 am
Location: San Diego

Re: Events not deleted from external hard drive

Post by dougmccrary »

Might need more info on your system and how the drive is mounted.
But try running zmaudit.pl to see if that works, and then if the problem reoccurs.
aschouwe
Posts: 6
Joined: Thu Apr 20, 2023 1:28 am

Re: Events not deleted from external hard drive

Post by aschouwe »

I have tested zmaudit.pl and at first this seemed to be the answer to my issue.
The script was supposed to delete files from the external hard drive that did not exist in the database. However the files were not actually deleted.

So, I deleted all events from the database and the hard drive manually to see what would happen, and I am getting the following error.

Ex:
┌──(kali㉿kali-raspberry-pi)-[~]
└─$ sudo zmaudit.pl
07/14/2024 06:03:37.235805 zmaudit[1214].INF [main:199] [Auditing All Storage Areas]
insecure cwd in find(depth) at /usr/share/perl/5.36/File/Find.pm line 276.

I looked at line 276 in the Find.pm script and found the line that will throw the error, but I am unsure what to do from here.
Any suggestions?
dougmccrary
Posts: 1336
Joined: Sat Aug 31, 2019 7:35 am
Location: San Diego

Re: Events not deleted from external hard drive

Post by dougmccrary »

Again, what is your system OS and how is the drive mounted and formatted?
It sounds like a permissions problem, but that usually affects writing the files in the first place...
aschouwe
Posts: 6
Joined: Thu Apr 20, 2023 1:28 am

Re: Events not deleted from external hard drive

Post by aschouwe »

I am running:
kali-raspberry-pi 5.15.44-Re4son-v8l+ #1 SMP PREEMPT Debian kali-pi (2022-07-03) aarch64 GNU/Linux on a Raspberry-Pi 4.

The drive is mounted with this command:
sudo mount -w /dev/sda1 /media/kali/Seagate\ Basic

Formatted: ext4


To confirm ZoneMinder files are being created at this location without issue.

Here is a look the permissions:
┌──(kali㉿kali-raspberry-pi)-[~]
└─$ ls -l /media/kali/Seagate\ Basic
total 20
drwxr-xr-x 4 www-data www-data 4096 Jul 14 06:19 Zm
dougmccrary
Posts: 1336
Joined: Sat Aug 31, 2019 7:35 am
Location: San Diego

Re: Events not deleted from external hard drive

Post by dougmccrary »

The drive is mounted with this command:
sudo mount -w /dev/sda1 /media/kali/Seagate\ Basic

Formatted: ext4
The only thing I see different from what I'd call "normal". Suggest you auto-mount in /etc/fstab
User avatar
iconnor
Posts: 3273
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Events not deleted from external hard drive

Post by iconnor »

To get around teh Cwd tainted error you can comment out line 641 of zmaudit.pl
mikb
Posts: 675
Joined: Mon Mar 25, 2013 12:34 pm

Re: Events not deleted from external hard drive

Post by mikb »

dougmccrary wrote: Tue Jul 16, 2024 3:41 am
The drive is mounted with this command:
sudo mount -w /dev/sda1 /media/kali/Seagate\ Basic

Formatted: ext4
The only thing I see different from what I'd call "normal". Suggest you auto-mount in /etc/fstab
Could it be that Zoneminder is getting its hands on the mount point, /media/kali/Seagate Basic before you've run that command? i.e. when ZM is started at boot?

This could cause some confusion, as ZM may hold onto a file handle to the underlying mount point (which may have different permissions, no actual CONTENT there), whereas when you look with "ls" you see the mounted file system.

Ensure the filesystem mount is done well before ZM starts.
aschouwe
Posts: 6
Joined: Thu Apr 20, 2023 1:28 am

Re: Events not deleted from external hard drive

Post by aschouwe »

Success! 8)

I added a new line to the /etc/fstab file to auto mount the drive.

zmaudit.pl is now working as expected, and is also no longer throwing any errors :D

I think the plan will be to run this as a cronjob once per hour.

Thanks for the help!!
Post Reply