ZM causes usb disk to malfunction?

Forum for questions and support relating to the 1.29.x releases only.
Locked
wespe
Posts: 4
Joined: Sat Jul 09, 2016 1:24 pm

ZM causes usb disk to malfunction?

Post by wespe »

Dear ZM Community,

First of all I'd like to thank you for this awesome software, I've been using it for a couple of months now without problems!

Important to mention is that Zoneminder itself is functioning perfectly well since I've installed it.
But this week I've noticed a weird problem:
If I try to attach USB sticks or SD cards to my server, they simply refuse to work if ZM is running. (I've tried 3 different sticks)
Surprisingly, as soon as I stop the ZM service, I can use my USB sticks and SD cards perfectly well.

The server box is an Ubuntu 14.04 32bit Server. Running Zoneminder 1.29.0.
I have 2 cameras attached:
one Logitech QuickCam Fusion USB webcam
one D-LINK DCS-932LB1 IP webcam
Both of them working correctly.

I'm an intermediate linux user. I will post the logs requested, but right now I have no clue which can be relevant.
root@ubuntu:/media/sdcard# service zoneminder stop
Stopping ZoneMinder: success

root@ubuntu:/media/sdcard# mkdir test
root@ubuntu:/media/sdcard# ls -alh
Total 100K
drwxr-xr-x 4 root root 32K júl 9 15:18 .
drwxr-xr-x 15 root root 4,0K júl 9 13:18 ..
drwxr-xr-x 2 root root 32K júl 9 14:49 FOUND.000
drwxr-xr-x 2 root root 32K júl 9 15:18 test
root@ubuntu:/media/sdcard# service zoneminder start
Starting ZoneMinder: success

root@ubuntu:/media/sdcard# mkdir test2
mkdir: cannot create directory: ”test2”: Input/output error
root@ubuntu:/media/sdcard# ls -alh
Total 100K
drwxr-xr-x 4 root root 32K júl 9 15:18 .
drwxr-xr-x 15 root root 4,0K júl 9 13:18 ..
drwxr-xr-x 2 root root 32K júl 9 14:49 FOUND.000
drwxr-xr-x 2 root root 32K júl 9 15:18 test
root@ubuntu:/media/sdcard#
Excerpt from dmesg:
[ 1412.887519] Buffer I/O error on device sdc1, logical block 8961
[ 1412.887669] lost page write due to I/O error on sdc1
Thanks,
Gabor
mikb
Posts: 678
Joined: Mon Mar 25, 2013 12:34 pm

Re: ZM causes usb disk to malfunction?

Post by mikb »

Interesting fault!

That error "lost page write due to I/O error on ..." is not a good sign. It means potential data loss and disk corruption, so experiment with care, or sticks with data you don't care about -- you may need to reformat them later!

Is it ALWAYS the same block number (no matter which stick/SD card)? or ...
Is it ALWAYS the a consistent block number per-device (the "failed block" changes, but is consistent depending on which stick)?
Or does it keep changing with no clear pattern?

"FOUND.000" -- is this indicative of previous FS corruption (a "found" cluster of data?)

What filesystems are you using on the sticks/SD card, in case it matters. And have you tried "fsck" ing the sticks -- maybe while ZM is STOPPED! -- to clear any filesystem problems?

My only thought is that ZoneMinder is sucking up some resources that are causing a failure in you trying to use these USB devices, but really that shouldn't be happening.
User avatar
knight-of-ni
Posts: 2406
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: ZM causes usb disk to malfunction?

Post by knight-of-ni »

I agree with mikb. The fact that you've got "FOUND.000" on your filesystem indicates past filesystem corruption. I know you said you've tried this on three different types of usb drives, but I would recommend you repeat the experiment on a freshly formatted, preferably new, usb drive. Also, make sure you are unmounting the USB drives before you remove them.

We need to know more information about your hardware. You mention sd cards. Are you using a Raspberry Pi or similar device by chance? Those devices have limited hardware. It's not impossible to get them working (it is rather fun), but you definitely have to be aware of their limitations.

Add up the number of devices using the USB bus. Obvisouly, your USB camera is on it. You have not told us the frame rate, but if you are trying to run it at a full 30fps then you can certainly expect it to be stealing a lot of usb bandwidth.

What about the disk containing the root and events filesystems? Is that disk (are those disks) on the USB bus as well? If so, you've just doubled the USB bandwidth consumed.

Do you have a USB Wifi adapter? If your IP camera is streaming through that, then there is even more USB bandwidth consumed.

If all of these are true, then one should be able to see how one can easily run out of USB bandwidth.
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/
wespe
Posts: 4
Joined: Sat Jul 09, 2016 1:24 pm

Re: ZM causes usb disk to malfunction?

Post by wespe »

Thank you for your thoughts! (I have reformatted and rechecked all the drives with dosfsck. They are fat32.)

Your points seem correct, as soon as I disabled the USB webcam (with ZM running), all my USB sticks and SD cards started working without a problem.
It's a 10 fps 1024x576 px rather old webcam (Quickcam Fusion).

My hardware is also quite old (but still perfectly serving :) Gigabyte GA-7NNXP + Athlon XP Barton 3200+ with 2GB DDR400 RAM
The only USB devices attached are: keyboard, mouse, SD card, webcam (<- disabled it now)
All filesystems are on HDDs. I use the USB stick/SD card only to back up my mysql db.

So it seems the webcam is chewing up the USB bandwidth leaving the storage devices unusable.
Is there any chance to make it better? Well if it's because the old hardware then I'll just live with it, but it would be great to solve it :)

Thanks again for taking time to respond.
User avatar
knight-of-ni
Posts: 2406
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: ZM causes usb disk to malfunction?

Post by knight-of-ni »

Oh, since it is normal pc based hardware, you could buy a cheap PCI USB 2.0 expansion card. As you may already know, get a legacy PCI card and not PCI Express. That would give you a second usb bus and solve the issue. Give the USB camera it's own dedicated usb bus, and then put everything else on the other.

Check this out. You can get a pci usb expansion card for, get this, $2.84 shipped from China to the US:
http://www.ebay.com/itm/USB-2-0-480-Mbp ... Sw-ndTnonK
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/
wespe
Posts: 4
Joined: Sat Jul 09, 2016 1:24 pm

Re: ZM causes usb disk to malfunction?

Post by wespe »

It's simpler than I thought :)
Thanks for your help! I'll give it a try.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: ZM causes usb disk to malfunction?

Post by asker »

I learn something new every day. USB bandwidth being eaten up thanks to a webcam! I would have never guessed that.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
knight-of-ni
Posts: 2406
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: ZM causes usb disk to malfunction?

Post by knight-of-ni »

Don't ask me why, but when I woke up this morning, another idea hit me. Go into your PC's BIOS and make sure the motherboard's USB is set to 2.0 and not USB 1.1 speeds.
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/
wespe
Posts: 4
Joined: Sat Jul 09, 2016 1:24 pm

Re: ZM causes usb disk to malfunction?

Post by wespe »

I have three options in the BIOS for the USB controller:
- Disabled
- USB 1.1
- USB 1.1 + 2.0 (<- this is the active setting)

Besides I also have some other USB relevant settings, I don't know if they play a role in this issue:
USB Park Mode:
- Enabled (<- this is the active setting)
- Disabled

USB Perf Mode:
- High
- Optimal
- Compatible (<- this is the active setting)
- Moderate

USB Read Requests From:
- ISO Queue (<- this is the active setting)
- non-ISO Queue
Locked