**Flashheart has the best solution for migrating storage to another hard disk issue. It is the best and quickest way to manage your memory without reinstalling everything.
My version is 1.24.2 but this thread is the only one that is directly related that I am aware of.
It is also my opinion not to break off the entire /var root just for this purpose, although that will work to an extent.
I just finished putting in my new hard drive to use for the zm grunt work instead of my system hard drive.
Here is a "little" breakdown in case you could use the help....
I want to encompass what you will be doing before you begin. It is really quite easy. You need to get the new drive formatted and ready to mount and install it. Copy over the specified directories, delete the old ones and sym-link the new ones on the new drive.
First, format your new drive in another computer(or whatever one is handy) using a SATA to USB converter. You can use whatever file system you feel to be best. For a program on Ubuntu, I used "Disk Utility". I stuck to EXT4. Now with a freshly formatted and labeled drive, find the UUID of the drive to configure the fstab in the machine it is going in ahead of time before the restart. To do this, run:
This shows the drives on your system including the UUID of the soon to be installed drive currently plugged in via a SATA to USB device. Deduce what UUID is the drive you are working with and copy the UUID down for editing the fstab on the ZM machine(if its different).
Next, edit the fstab on the ZM machine so that the hard disk will be available right after the first boot and ready to go.
Make a new directory in your /mnt folder by:
Code: Select all
sudo mkdir /mnt/whatever_you_want_to_call_the_directory
I used "/mnt/security" This is only an example.
Next edit your fstab: (example is if you know vi; you can use whatever editor you want.... nano, joe, gedit if you're on the machine locally...)
Next, add these lines to the bottom of the file: (change directory names and UUID to your scenario...)
Code: Select all
#security_cams
UUID=your_harddisk's_uuid_from_earlier /mnt/your_directory_from_earlier your_choosen_file_system relatime,errors=remount-ro 0 2
Here is an example of mine:
Code: Select all
#security_cams
UUID=0adc4b6b-0bb4-44be-bf0f-860b06e28b23 /mnt/security ext4 relatime,errors=remount-ro 0 2
Now, when you shut down your ZM system, plug in the new drive via SATA, and fire it back up, it will be mounted and ready to go at /mnt/whatever_you_called_the_directory
Next you want to shut down ZM. Do this from the web page or from the command line. From the web page you simply click "running" in the top center and click apply in the little window that pops up. From the command line, type:
At least this is how my Linux distro works (Ubuntu 10.04) **see your own Linux distro documentation for details on starting and stopping services if different from mine.**
Next you want to stop any other service that are using mysql on a regular basis. My machine is actually Mythbuntu obviously running mythtv services as well which use mysql very heavily. Stop these other services in the same way. You can even stop apache2 service to be totally sure.
After you have all mysql dependencies stopped, stop mysql itself by:
Now everything is quiet and you are ready to migrate over to the new hard disk for the ZM grunt work.
There are two methods to doing this. Trash all your ZM security camera footage and start fresh (much much much faster) or keep all your existing data by copying everything over (much much much slower.... and the route I will cover because that is what I did).
First, verify your new disk is read and mounted properly where it is supposed to be. You can list your attached hard disks and their mount points by:
Look for your new disk. It should be pointing to the directory you made in /mnt
If all is well so far, copy all your previous camera footage from the current location to the new drive. You want to copy a total of 3 folders and all their contents. Assuming that you haven't moved anything previously, this code should work nicely for you:
then:
Code: Select all
sudo cp -Rvp events/ images/ temp/ /mnt/whatever_you_called_the_directory
Now you can take a break. Have a pizza or maybe even make a pizza.... from scratch. Depending on how many cameras you have, resolution and frames per second, this is going to take some time.
.....
After the copying is all completed, verify the data is all there by:
Code: Select all
ls -l /mnt/whatever_you_called_the_directory
You should see your copied data there, all accounted for. Make sure that the ownership is all correct, which it should be. If "root" user owns the copied directories, do this:
Code: Select all
sudo chown -R www-data:www-data /mnt/whatever_you_called_the_directory
Now everything should be under the correct ownership for ZM to function.
We aren't done yet though. The final things we need to to is delete the old directories we copied with their contents (free up some serious system space) and create symbolic links from /var/cache/zoneminder/* to the new hard drive.
Delete the three directories: (make sure this is correct for your system, an error could be catastrophic...)
Code: Select all
sudo rm -R /var/cache/zoneminder/*
Now create the symbolic links to the new drive. You need to do these one at a time for each folder you copied earlier. Lets do events first.
Code: Select all
sudo ln -s /mnt/whatever_you_called_the_directory/events /var/cache/zoneminder/events
Now the images directory:
Code: Select all
sudo ln -s /mnt/whatever_you_called_the_directory/images /var/cache/zoneminder/images
And finally temp:
Code: Select all
sudo ln -s /mnt/whatever_you_called_the_directory/temp /var/cache/zoneminder/temp
Great job! You're all finished! Now its just a matter of starting up your services in reverse order that you had to stop them.
Lets start mysql first since ZM in dependent on it:
Then start up ZoneMinder:
(or from the zm web console)
Don't forget to start up any other service you had to shut down earlier. Once again, my system is also a MythTV system so I had to start up mythtv-backend as well:
That's it! I know I went into crazy detail on this so I'm sure most of you will skip through it (maybe even pick out a mistake or inefficiency...)
Let me know if you have any more questions or need me to edit my post for some reason.
As a positive note, this also dropped my zma service from 24% down to 12%! Having a separate HDD for ZM grunt work makes systems happy!
I hope this helps!!!
ps... After going back into ZoneMinder, I had an extra event at the beginning with a crazy huge number dating to year 1906 or something. I simply selected the event from the ZM webpage and deleted it. Thankfully that cleared that up!
Happy spying... * cough*... I mean... securing![/code]