Installing ZoneMinder on Ubuntu in Hyper-V

22 Jun

A long time back I wrote an article on installing ZoneMinder inside a Hyper-V VM, well I recently had another go and it was much easier this time around and all the bugs seem to have been fixed too.

Firstly, I added a Gen1 VM, with 2GB RAM, 600GB VHD, 1 Core, Standard network adaptor and then mounted the Ubuntu ISO.

Run the install wizard and select:

  • OpenSSH Server
  • LAMP Server

I followed the guide from here and it was perfect.

For reference:

sudo su

If you used the server install CD

apt-get update
apt-get upgrade
apt-get dist-upgrade

Optional: Set static IP address

nano /etc/network/interfaces

Make changes similar to this:

auto eth0
iface eth0 inet static

Note: for Ubuntu 14.04 the resolv.conf is dynamically assigned. The “dns-servers” entry in the interfaces file will set the DNS Multiple DNS server entries can be used.

Reboot server

Log in and become root

sudo su

Suggested changes to MySQL

For most of you Zoneminder will run just fine with the default MySQL settings. There are a couple of settings that may, in time, provide beneficial especially if you have a number of cameras and many events with a lot of files. One setting I recommend is the “innodb_file_per_table” This will be a default setting in MySQL 5.6 but should be added in MySQL 5.5 which comes with Ubuntu 14.04. A description can be found here:

To add “innodb_file_per_table” edit the my.cnf file:

nano /etc/mysql/my.cnf

Under [mysqld] add


Ctrl+o Enter to save

CTRL+x to exit

Restart MySQL

service mysql restart

As you add cameras to your system and the events build up you may need to increase the size of the “innodb_buffer_pool_size” when this setting runs out of space your system may act like it is out of disk space. One way to check this is to install mysqltuner and run it from the command line. When the results are shown you can edit the my.cnf file and change the buffer size. The default “innodb_buffer_pool_size” is 128M. In the ZM forum I have found a recommended setting of 256M. My production server required a setting greater than 410M. Install and run mysqltuner to determine the recommended size for your system. Be sure to restart MySQL after making changes.

CGI is not enabled in Ubuntu 14.04 by default. Enable it this way:

a2enmod cgi

Restart Apache

/etc/init.d/apache2 force-reload 


service apache2 restart

Add Repository

apt-get install software-properties-common python-software-properties
add-apt-repository ppa:iconnor/zoneminder
apt-get update

Install Zoneminder

apt-get install zoneminder

Note: a couple of package configurations will open up. These are to configure Nullmailer. You can just OK them and come back to configure them later.

You will need to install “extra” VLC components torun Libvlc (verified 20OCT14)

apt-get install libvlc-dev libvlccore-dev vlc

Add delay to allow MySQL to start before Zoneminder

nano /etc/init.d/zoneminder

Add sleep 15 as shown:

start() {
      sleep 15
      echo -n "Starting $prog: "

Ctrl+o Enter to save

CTRL+x to exit

Create a symbolic link to zoneminder’s apache config file. Since Ubuntu includes tools to enable/disable conf files, do so the ‘Ubuntu way’

ln -s /etc/zm/apache.conf /etc/apache2/conf-available/zoneminder.conf

Now, enable the zoneminder apache config file:

a2enconf zoneminder

Create a new user

adduser www-data video

Restart Apache

/etc/init.d/apache2 force-reload 


service apache2 restart

Install Cambozola (needed if you use Internet Explorer)

cd /usr/src && wget
tar -xzvf cambozola-latest.tar.gz

replace 935 in the next line with cambozola version downloaded

cp cambozola-0.935/dist/cambozola.jar /usr/share/zoneminder

You should now be able to access the web server using https://servername

NTP Daily Sync

nano /etc/cron.daily/ntpdate

Copy the following into nano


Ctrl+o Enter to save

CTRL+x to exit

chmod 755 /etc/cron.daily/ntpdate

I also made a few modifications, firstly I changed the default port from 80 to something else. This was done by editing the file /etc/apache2/ports.conf

nano /etc/apache2/ports.conf
service restart apache2

Also, to view the memory usage on the machine, run:

free -m


This box only runs ZM so I also wanted to remove the /zm subdirectory. For this i ran the following to copy over all of the ZM web files to the default web directory:

sudo su
command cp -r /usr/share/zoneminder/* /var/www/

Another issue I found was the WebGUI becoming unresponsive after a few days, restarting the Apache2 service didn’t help, and so I have a daily reboot using:

sudo crontab -e

(Add the following line)

0 2 * * * /sbin/shutdown -r +0

The install was dead easy and I I’ve already added a couple of cameras. I’m also using the pro version of the zmview app for iPhone which works pretty well.


Add ffmpeg (Needed to export videos):

sudo apt-add-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get install ffmpeg

Add Hyper-V Integration Services

  1. The first step is to edit the “modules” file located in /etc/initramfs-tools using the below command:
    • sudo vi /etc/initramfs-tools/modules
  2. In vi Editor, navigate to the last line in the file and use the insert ( I ) command to append and enter the following lines:
    • hv_vmbus
    • hv_storvsc
    • hv_blkvsc
    • hv_netvsc
  3. Save the file by hitting the Esc key and then issuing the “: x” command.
  4. Next, run the following commands to re-initialize the “modules” file:
    • sudo update-initramfs –u
  5. Finally, reboot the virtual machine by executing the below command in Shell:
    • sudo shutdown -r now
  6. Once the guest virtual machine is rebooted, the LIS drivers and services will be registered in the system. After rebooting, you can run the below command to verify the registration of the LIS drivers and services:
    • Lsmod
    • The above command should list the LIS drivers and services. You need to look for hid_hyperv, hv_netvsc, hv_utils, hv_storvc and hv_vmbus for the successful activation of LIS.


To repair the database you can run the following command:

mysqlcheck --all-databases --auto-repair -pPASSWORD - USERNAME