Using Linux LVM with ZoneMinder Open Source Security Software

Summary

With Linux LVM, you can dynamically add or remove hard drives from a server as your ZoneMinder storage needs change.
ZoneMinder is a Linux, open sourced software system to record multiple camera streams. Unlike other server services, ZoneMinder (ZM) requires massive amounts of storage. Storage needs differ with various factors such as:

  • Number of cameras
  • Resolution
  • FPS (Frames Per Second)
  • Color or Black and White
    ZM records all the captured video data as individual JPGs. These are all stored in a single folder, "events". In most installs, it's in /var/www/events. What this means is that as your recording needs change, expanding this folder becomes critical. However, with LVM you can create a logical partition solely for recording and expand it as needed with additional physical disks. This article will show you that expanding your Linux server's storage space for ZoneMinder is possible with LVM.
    First, a refresher on what ZoneMinder is:

    ZoneMinder is intended for use in single or multi-camera video security applications, including commercial or home CCTV, theft prevention and child, family member or home monitoring and other domestic care scenarios such as nanny cam installations. It supports capture, analysis, recording, and monitoring of video data coming from one or more video or network cameras attached to a Linux system. It is suitable for use as a DIY home video security system and for commercial or professional video security and surveillance. If you're looking for a low cost CCTV system or a more flexible alternative to cheap DVR systems then why not give ZoneMinder a try?

    The most important advantage LVM provides for ZoneMinder is the ability to expand storage capacity dynamically. You can add or remove disks for recording as needed. Each time a new disk is added, it can be absorbed by the existing logical disk. That way ZoneMinder continues recording events to an increasingly larger "drive".

    The main drawback, however, is that LVM creates multiple points of failure. If any of the disks in the logical volume die, the entire logical volume dies. This will cause you to lose all your recorded events. Depending on your use case, this may or may not matter. It's up to you to decide which is more important: expandable storage or data redundancy. At the cost of LVM's flexibility, you increase the chance of losing your data. LVM uses disk spanning, meaning any given file may be spread across multiple drives. If any of those drives fails, the entire file is inaccessible. This is analogous to RAID 0.

    A single disk failure can wipe out the entire logical volume.
    Rather than duplicate effort, here's a link to a very easy to follow LVM setup guide. Now that you know to use LVM to handle ZoneMinder's "events" storage try it yourself. The step by step guide to setting up LVM in Linux can be found at HowToForge.
    Initially, this "budget" system was going to sit in a cardboard box during testing:

    Because I wanted to do some minor stress testing, I needed more storage than the initial 20 GB IDE drive. The OS and all software was installed on the 20 GB IDE drive. Ddditional spare IDE drives were added to the system through LVM. This allowed me to add drives as needed while utilizing existing old spare hard drives.