However, I did find some problems along the way, and as usual I want to keep it somewhere I can get easy access to in future - this blog. Please also note, this will solve any m4a and flac transcoding issues, and possibly other codecs.
The whole process relies on you setting up a jail in NAS4Free so that the changes are not lost on reboot (since this is an embedded guide).
Lets start of with configuring NAS4Free to complete this task:
Configuring NAS4Free
- Go to this page: http://wiki.nas4free.org/doku.php?id=documentation:setup_and_user_guide:services_ssh
- Check so that ssh is enabled and check the port number and also check that the option “Permit root login”is enabled.(The root password is the same as the WebGUI password but the login name is always “root”)
- Go to the NAS4Free webgui and navigate the menu like this: System->Advanced->sysctl.conf
Add there:
Name: security.jail.chflags_allowed
Value: 1
Comment: can be whatever you want. - Now navigate in the webgui like this: Advanced|File Editor
- In the file path textbox write “/etc/rc.conf”
- Click load
- Add to the file jail_enable=”yes”
- Click the save button next to the textbox where you wrote the path to the file and then restart the NAS4Free server.
Create Folders and Mount Points
SSH into your NAS4Free box using putty or similar. NOTE: Change all reference to /mnt/data to the mountpoint on your NAS where you are going to store the jail.- mkdir /jail
- mkdir /mnt/data/jail
- mkdir /mnt/data/jail/{work,proto,conf}
- mount_nullfs /mnt/data/jail /jail
Download and Extract FreeBSD Base System
The base system has to be downloaded to make sure you get all the necessary binaries, config files and scripts. To download it you can just copy paste the following commands into the ssh shell.- cd /jail/work
- fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/`uname -m`/`uname -m`/`uname -r | cut -d- -f1-2`/base.txz
- fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/`uname -m`/`uname -m`/`uname -r | cut -d- -f1-2`/lib32.txz
- tar xvf /jail/work/base.txz -C /jail/proto/
- tar xvf /jail/work/lib32.txz -C /jail/proto/
Installing the Plugins Jail Binaries
- cd /jail
- mkdir -p conf/root/{etc/rc.d/,usr/bin,usr/sbin}
- cp proto/etc/rc.d/jail conf/root/etc/rc.d/
- cp proto/usr/sbin/{jail,jexec,jls} conf/root/usr/sbin/
- cp proto/usr/bin/mktemp conf/root/usr/bin/
Configuring the Jail
NOTE: Obviously exchange EST for your own time=zone. Next we will configure the mounts that the jail is going to be able to access.- cp /etc/resolv.conf /jail/proto/etc/
- cp /jail/proto/usr/share/zoneinfo/EST /jail/proto/etc/localtime
- touch /jail/conf/fstab.proto
- mkdir /jail/proto/mnt/DataDisk1
- nano /jail/conf/fstab.proto
/mnt/data/DataDisk1 /jail/proto/mnt/DataDisk1 nullfs rw 0 0
The drive is mounted read write for playlist, comments, ratings, podcast access from Subsonic.
The next part of the configuration is to create the rc.conf file.
- touch conf/rc.conf.local
- nano conf/rc.conf.local
jail_enable="YES" # enable jails YES|NO
jail_list="proto" # name of the jails to start “proto www…”
jail_proto_rootdir="/jail/proto" # path to our jail
jail_proto_hostname="proto" # hostname
jail_proto_ip="192.168.0.30" # ip of the jail, replace with a ip in the same subsystem as your NAS
jail_proto_interface="re0" # Network Interface to use, replace with your NAS interface name
jail_proto_devfs_enable="YES" # use devfs
jail_proto_mount_enable="YES" # mount YES|NO
jail_proto_fstab="/jail/conf/fstab.proto" # File with Filesystems to mount
Create the Jail Start-up Script
- nano /jail/conf/jail_start
#!/bin/tcsh -x
#mounting to /jail
mkdir /jail
mount_nullfs /mnt/data/jail /jail
# copy jail binaries to /usr, not needed if N4F is 454 or up
# because Daoyama include needed files, uncomment if you use low .454 version
# cp -r /jail/conf/root/ /
# link config files to /etc
ln -s /jail/conf/rc.conf.local /etc
#start all jails
/etc/rc.d/jail start
Make the start-up script executable with the following command:
- chmod 755 /jail/conf/jail_start
Command: /mnt/data/jail/conf/jail_start
Type: PostInit
Save and apply, and reboot your server. After a successful reboot check your new jail via SSH using the jls command, you should see something like this:
JID IP Address Hostname Path
1 192.168.1.201 proto /jail/proto
1 192.168.1.201 proto /jail/proto
Install Subsonic and Required Packages
Enter the jail with the following command (based on the output of example jls above we use 1):- jexec 1 csh
- setenv PACKAGESITE ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9.1-release/Latest/
- pkg_add -v -r xtrans
- pkg_add -v -r xproto
- pkg_add -v -r xextproto
- pkg_add -v -r javavmwrapper
- pkg_add -v -r http://denieru.no-ip.org/filecache/subext/lame.tbz
- pkg_add -v -r flac
- pkg_add -v -r openjdk7
- pkg_add -r -v wget
- wget http://downloads.sourceforge.net/project/lame/lame/3.98.4/lame-3.98.4.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Flame%2Ffiles%2Flame%2F3.98.4%2F&ts=1366036375&use_mirror=superb-dca2
- tar -xf lame-3.98.4.tar.gz
- cd lame-3.98.4
- ./configure
- make
- make install clean
- portsnap fetch extract
- cd /usr/ports/multimedia/ffmpeg
- make config
- make install clean
Create Folders and Unpack Subsonic
Create the folders and download/extract subsonic standalone.- mkdir -p /var/subsonic/transcode
- mkdir /var/subsonic/standalone
- cp /usr/local/bin/lame /var/subsonic/transcode/
- cp /usr/local/bin/flac /var/subsonic/transcode/
- cp /usr/local/bin/ffmpeg /var/subsonic/transcode/
- cd /tmp/
- fetch http://heanet.dl.sourceforge.net/project/subsonic/subsonic/4.8/subsonic-4.8-standalone.tar.gz
- tar xvzf /tmp/subsonic-4.7-standalone.tar.gz -C /var/subsonic/standalone
- chmod 777 *.*
- sh /var/subsonic/standalone/subsonic.sh
Automated Start-up
To make it run each time the NAS server is started add via the webgui under: System|Advanced|Command Scripts.Command: jexec 1 /var/subsonic/standalone/subsonic.sh
Type: PostInit
Save and apply, and reboot your server. After a successful reboot you can check your Subsonic install via http://Jail-IP:4040
If your Subsonic installation has problems with the audio (the java install couldn’t see your audio dev) install alsa-plugins via the following command:
- pkg_add -v -r alsa-plugins
And if you want to access your new service on your android device, why not try out the official Subsonic Music Streamer
(4/17/2013 Updated for Subsonic 4.8)
(5/10/2013 Updated based on fsbruva's comments http://forums.nas4free.org/viewtopic.php?f=79&t=3166&p=19759#p19759)