installing subsonic on freenas (and bonus upgrade instructions)

I can’t recall if I’ve talked about FreeNAS before on this blog, but if I haven’t that may be a topic for another time.  Besides, lots of other folks have written about it in the past.  It’s great network storage for backing up all of our documents, photos, videos and music in one place with built in RAID backup.  It’s amazing.  And now with Subsonic, we have the option of installing software that can stream music (and now video) to any web browser or even smart phone on the internet.  Very cool.

Once again, I’m writing a really, really nerdy post as a public service to those out there who want to do the same and haven’t gotten enough guidance elsewhere on the internet.  Also this will serve as a persistent memory for my inevitable re-install later.  I’m sure most of my regular readers will want to stop reading at this point.

Before starting, it’s really important that you have enough space on your FreeNAS OS partition to hold Subsonic.  In the Subsonic forum it’s suggested that you carve out at least 150MB for all of the files.  I’d suggest allocating at least twice that if possible.  I’ve found that after a fair amount of use, the log file will start to grow pretty large, you may want to add codecs for transcoding, etc.  Personally this was the most painful part of the process since I had an “embedded” installation of FreeNAS on a USB flash drive which was fairly small.  During this process I used the capability within FreeNAS to backup the configuration before I re-installed.  Make sure when you re-install (if you need to) that do not choose the “embedded” option.  I installed from the CD-ROM image and chose the “full” install option onto a Hard Drive w/Data Partition (even though I will not actually use a hard drive or data partition).

The information and steps below are lovingly borrowed from the following two links, however I have mashed them up together, and added steps/made some changes that I found helpful during my experience installing the software.

  • Subsonic Forum: Sindre provided some helpful instructions to get your started on the install with FreeNAS.
  • Ozziks Blog: Huge thanks to this blog for helping with the finer points of the installation process.

Step 1: Prepare your server for the installation.

Before getting started, enable SSH access to your FreeNAS server.  You’ll find this under the web UI:  “Services >SSH”.  Set this to enable, and allow root.  You can log into your FreeNAS server by using any SSH terminal client.  Under Ubuntu (with SSH client installed) type “ssh x.x.x.x@root” (where the x.x.x.x is the IP address of your FreeNAS server).   If you have Windows use Putty.  Just remember that you must login as “root”, and not “admin”.

Setup FreeNAS’s Gateway IP.  This was something that I got hung up on for hours while trying to run the pkg_add command later in the process.  Well, maybe not hours, but it was an ah-ha moment when I finally stumbled upon the answer.  Under the FreeNAS web interface go to Network > LAN Management > Gateway = (set this to your router’s IP address, mine happens to be

Step 2: Download Java JRE (or JDK) package from:

You should choose the JRE package according to your CPU architecture and FreeBSD version (if you have FreeNAS 0.7.x then you will want to download the FreeBSD 7 package, and of course based on your release, either AMD(64-bit) and i386(32-bit)).  I chose diablo-jre-freebsd7.i386., having FreeNas 0.7.2 and i386.  I then put this file onto my FreeNAS share drive so that you can access it directly from the shell (i.e. /mnt/share-name/path-to/file-name) later when you want to add the package.

Step 3: Install dependent packages (included the transcoders here as well, but may not be desired in your config):

$ pkg_add -v -r xtrans
$ pkg_add -v -r xproto
$ pkg_add -v -r xextproto
$ pkg_add -v -r javavmwrapper
$ pkg_add -v -r lame
$ pkg_add -v -r flac
$ pkg_add -v -r ffmpeg

UPDATE 1/10/2012:  If you run into issues with the latest versions of FreeNAS failing the pkg_add command like I did recently, the follow these instructions prior to the pkg_add commands.

Before installing the packages, if you are using FreeNAS 7.2 (based on FreeBSD 7.3), you’ll need to enter the following command:


(substitute amd64 for i386 if 64-bit).

(May also work for other versions – if the version of FreeBSD is no longer considered the current release, the main mirror will no longer contain the package files, therefore the above is necessary to tell pkg_add where to find the .tbz files. You may set it permanently in ~/.cshrc if you wish it to remain sticky.)

If you have issues installing the lame codec you may also try the following.  I can’t recall if I ran into this issue or not.

$ pkg_add -r -v

Step 4: Install the JRE (the .tbz file is the one you downloaded in step 2)

$ pkg_add -v /mnt/share-drive/diablo-jre-freebsd7.i386.

Of course your version of the file and location may be different, so don’t copy/paste this portion.

Step 5: Download Subsonic standalone version and install it in /var/subsonic/standalone on your FreeNAS, as described here.  Just like with the Java package, I put the Subsonic Tarball on the share drive somewhere (i.e. In SSH:

$ mkdir /var/subsonic
$ mkdir /var/subsonic/standalone
$ cd /var/subsonic/standalone
$ tar xvzf /mnt/share-name/path-to/subsonic-x.x-standalone.tar.gz

Some folks suggest changing the permissions of all of the files at this point.  Technically it will probably work just fine untouched.  But if you want:

$ chmod 777 *.*

Step 6: Modify the file.


If you are editing under Windows, do yourself a favor and save the file in ASCII format so as not to cause issues.  The fist time around I made changes in my Windows text editor and it introduced all kinds of invisible line breaks and null characters which caused the script to fail under BSD.   Just… don’t.

I also found an issue with the subsonic.h file, as shipped, under my FreeNAS implementation and am not quite sure why it doesn’t work.  It may work out of the box for you, but for some reason it was broken for me.  If you run into the same issue, you can make the following changes.


cd $(dirname $0)
if [ -L $0 ] && ([ -e /bin/readlink ] || [ -e /usr/bin/readlink ]); then
cd $(dirname $(readlink $0))


cd /var/subsonic/standalone
#if [ -L $0 ] && ([ -e /bin/readlink ] || [ -e /usr/bin/readlink ]); then
#cd $(dirname $(readlink $0))

Step 7: Copy codecs into the Subsonic transcode directory:

mkdir /var/subsonic/transcode
cp /usr/local/bin/lame /var/subsonic/transcode/
cp /usr/local/bin/flac /var/subsonic/transcode/
cp /usr/local/bin/ffmpeg /var/subsonic/transcode/

There is one more step to get codecs to function properly that we’ll cover later.  If you installed some other codecs in step 3, then you’ll want to copy those to the transcode directory as well.

Step 7: In the FreeNAS web interface, go to System > Advanced > Command script and add the following “PostInit” script:


Step 8: Reboot FreeNAS, and go to http://<your-freenas-server>:4040 to start using Subsonic.

Step 9: Configure your transcoder settings.  In the Subsonic web interface go to “Settings > Transcoding”.

In this example, I’ve set up FLAC to transcode to WAV, then to MP3.   On the line reads “flac > mp3” modify the following:

Step 1 = flac -c -s -d %s
Step 2 = lame -b 320 – –

NOTE: This hard-codes the bitrate to 320kbps, which is presumptuous.  But hey, that’s what FLAC is all about right?  High quality.

My FreeNAS server is an under-powered system (mostly because it never needed to be powerful), so transcoding FLAC to MP3 basically consumes 100% of the processor bandwidth.  Listening to FLAC’s is something I will probably do sparingly.  Your mileage may vary.

Summary: It looks hard, but I’ve made all the mistakes for you, so this guide should save you some serious time.  If you run into any issues, Google is always your friend.

And in closing, if you haven’t yet donated to the project, I urge you to do so.  Sindre (the developer of Subsonic) obviously put a lot of hard work into this and it is just flat-out great software.  He deserves a little scratch for bringing this to the masses for free.  So do your part and support the community.  It’s an investment in your personal enjoyment of music and an investment in the future development of this software.

BONUS:  How to UPDATE/UPGRADE your Subsonic to the latest version on FreeNAS

From time to time, Subsonic has bug fixes and/or feature additions that may be compelling enough to make you want to upgrade your installation.  I could not find a single shred of information on the internet about how to update the “standalone” version of Subsonic on FreeNAS without completely re-installing.  I did some experimenting and came up with the below solution.  This is not endorsed and certainly should be done at your own risk.  Back-up your Subsonic installation before you try this.

Step 1: Shutdown Subsonic.  In the FreeNAS web interface go to System > Advanced > Command script and then delete following “PostInit” script:


Reboot the system.  Subsonic will not automatically run on restart and it will be safe to make changes.

Step 2: Back up your Subsonic installation by copying all files under /var/subsonic to another safe location.  If you for some reason run into an issue during the install, you should be able to simply copy all of these files back and be back in business.

Step 3: Download the latest standalone package here.  Put the new tarball on my FreeNAS share drive so that you can access it via the terminal (i.e. under the /mnt/share-name/path-to/ directory)

Step 4: Unpack subsonic-x.x-standalone.tar.gz to “var/subsonic/standalone”.  Using SSH:

$ cd /var/subsonic/standalone
$ tar xvzf /mnt/share-drive/path-to/subsonic-x.x-standalone.tar.gz

This will unpack the new files right over the top of the old files.  Edit permissions on the new files if desired.

Step 5: Edit the file as necessary.  (see step 6 above)

Step 6: In the FreeNAS web interface, go to System > Advanced > Command script and add the following “PostInit” script:

sh /var/subsonic/standalone/

Step 7: Reboot FreeNAS, and go to http://<your-freenas-server>:4040, login and confirm your settings.

Step 8: Enjoy.

I would love to hear your successes or failures to make this tutorial just a bit more useful.  Feedback is always welcome.

11 Replies to “installing subsonic on freenas (and bonus upgrade instructions)”

  1. Great deal! Worked out fine. I however got the following packages “on line” before dispersing them into the designated folders and unpacking them there..

    #BASE packages


    #ENCODER packages
    #dependent application:unpackage first
    #dependent application:unpackage first

    I however did not get the FLAC encoder to work. Playing now and figuring out odds and in. Do not see where I stream movies. Fun! fun!

    Thanks for this awesome contribution: hands down beat Linuxuser magazine who failed to even suggesting modding the .sh file.

  2. Hello!Thanks for the tutorial!

    one problem though.When starting subsonic i get error “Error occurred during initialization of VM
    Unable to load ZIP library: /usr/local/diablo-jre1.6.0/lib/i386/”

    i’ve googled but no luck.any suggestions please?

  3. Or maybe you grabbed the wrong Java package? Check to make sure you’ve got the right one for your build (64-bit or 32-bit, etc.)

  4. Thanks for the answer

    i had only warnings for having installed versions higher than those that JAVA requires.
    I will try the exact versions as shown in the warnings.

  5. Awesome post! I just got my N40L and I’m a bit lazy to work this out myself, haha!

Leave a Reply

Your email address will not be published. Required fields are marked *