Last week I purchased an Axis wireless IP camera to monitor my home when I’m not there. While I was setting it up I decided that I really needed a central point on my network that I could use to store all of the recorded video footage.
I’ve been meaning to setup a media server for quite a while now but the IP camera gave me a good excuse to do this project. I actually have several devices that I plan on connecting to the media server including my TV, Receiver, Blu-ray player, and the computers on my network.
Several companies are selling NAS solutions that cost anywhere from $200 to $500+ depending on size and features, but you can build your own for next to nothing if you have an old computer lying around. The main thing I like about this type of build it yourself solution is the ability to customize and upgrade it. If you buy a pre-built NAS you have to live with the limitations of the software and can you only install a few drives. By building your own NAS using open source software you have complete control over the system, plus you can add as many hard drives as you can fit in the chassis. Luckily my basement is full of old computers for projects just like this one.
FreeNAS is an open sourced network storage system that supports several different protocols including Samba, FTP, NFS, Rsync, iSCSI, and more. You can manage all of the functions of the NAS using a nice web interface too. The FreeNAS software only requires 128MB of disk space so you can easily install it onto a USB drive which allows for more internal drives to be installed for your data. Check out the minimum hardware requirements before getting started.
I had a spare 1TB western digital drive lying around so I decided to start my NAS with a single drive. I’m planning to order another drive so I can setup a raid 1 mirror for data protection. I installed FreeNAS onto a 2GB usb flash drive (the smallest I had) since there is really no need to install it onto a hard drive.
Even though you can install onto a usb drive you still have run the installation from a CD so I downloaded the ISO for the newest version , 8.0 RC1 and burned it to a CD.
After you have installed the hard drives into the NAS box you will need to boot from the CD you just burned. If you are installing onto a USB drive don’t insert it just yet. Once the CD finishes booting you will see the FreeNAS console setup menu. Once the menu appears plug in your usb drive and select the first option (Install/Upgrade).
Next select where you want FreeNAS to be installed, in this case I selected the flash disk. Be careful because all data on the destination drive will be deleted.
If everything goes well you will see the installation complete page below. Now you can reboot and remove the CD from the drive. At this point make sure your bios is configured properly to boot off of the device you installed FreeNAS to.
After the FreeNAS system boots up you will see the console menu. You need to configure an IP address (option #1) on the network interface before you’ll be able to access the web gui. After you’ve configured the address and connected the NAS to your switch you should be able to access the web gui from your computer by going to http://ip.of.your.nas. The default username and password is admin/freenas. Once your able to access the web gui you can disconnect the monitor and keyboard and hide the NAS in a corner somewhere.
Creating volumes and data sets
After logging into the web gui the first thing you will need to do is create a volume out of your disks, if you only have one drive then its pretty simple. If you have multiple drives you will need to decide how you want to logically separate the data and whether or not your going to use raid. I selected ZFS for the filesystem type which protects helps protect your data from becoming corrupt (bitrot) at the expense of higher memory/cpu usage. If your using a machine that has less than 2GB of ram you should probably use UFS instead.
Once you have created a volume you can create one or more data sets that reside on the volume. The data sets are treated like a volume in the sense that you can apply different permissions to each data set. As you can see below I created several different data sets separated by media type.
Setting up services
Once you finish creating the volumes and data sets you will need to click on the services tab and select all of the services that you would like to be enabled. On my system I enabled CIFS (Windows Networking) for PC access, and FTP for my security camera. If you don’t plan to use a service its best to leave it disabled to conserve resources and increase security.
Finally you will need to user accounts for the people or devices that will be accessing the NAS. To do this click on the account button in the upper right hand corner of the gui. You can set up individual users for each service or have a couple of shared accounts if you want.
If you are creating an FTP user make sure to assign them a valid home directory or the account will not be able to log in. I kept getting a ‘login incorrect’ error when I was testing the FTP service. After looking at the system logs (/var/log/messages) I noticed the error during login was ‘No such file or directory’.
I’ve really only scratched the surface of what you can do using FreeNAS. There are tons of ways you can customize FreeNAS to fit your needs. Most of the options are fairly intuitive in the web gui but if need a reference check out the documentation and setup guide. FreeNAS is flexible enough to be used as a simple file server or an iSCSI NAS with multiple VLANs its really up to you.
Tips and Tricks
Below I’ve included some commands and other tricks that I have found to be useful. As I discover other things I will keep adding to the list.
Mount the root filesystem as read/write
mount -uw /dev/ufs/FreeNASs1a
Remount root as read only
mount -ur /dev/ufs/FreeNASs1a /
Mount root as RW first
tar xjf iperf-2.0.5.tbz
ZFS Raid Commands
Check Raid status – zpool status
Replace a failed drive – zpool replace <failed drive> [new drive]
Attach or detach a drive – zpool attach / zpool detach
If you found this post interesting you might also want to consider setting up a pfSense router . Pfsense is also based on FreeBSD and can provide some useful services on your network.
Thanks for reading!
6 thoughts to “Building a Home Media Server Using FreeNAS”
Hi, I´ve Just Installed Freenas. I Have 4 Axis Cameras But I Dont Know How To Set Them Up So A Can Save And Manage My Recording On The NAS Server.. Can You Help Me? Thanks For The Info!
I configured my cameras to upload images to my NAS via FTP whenever motion is detected.
To do this create a volume on the NAS and turn on the FTP service. You should also create an FTP user account. Then on the web interface of the camera you can create an event server and assign an event to go along with it.
If you want to record full video streams on the NAS you can install axis camera station, or set up Zoneminder on Linux.
Hope this helps!
Great post….you wrote “By building your own using a Linux based system”…FreeNAS is built using FreeBSD, not Linux.
Hi, what if I plan using different ip cams like mobotix, geovision to record footage etc w;what do I do! Great post though.thank you
Most IP cameras should support file storage on a CIFS/SAMBA or FTP share. FreeNAS supports quite a few different protocols so you shouldn’t have a problem finding a way to store data from your IP camera onto the unit. If you want to experiment with compatibility before building a FreeNAS box you can setup a virtual test box using Virtual Box.