After some extensive reading and some trial and error, I've succeeded with installing SABnzbd on a NAS4Free embedded machine with a ZFS pool, and thought it would be helpful to post here on how to do it, step by step.
The SABnzbd setup was done on N4F version 9.1.0.1.431, x64-embedded, and is based on these 3 important guides I found - thanks a lot for the guys who wrote them:
Solution for mount_unionfs with ZFS:
viewtopic.php?f=72&t=210#p507
Fantechtic's tutorial for SABnzbd on embedded FreeNAS 0.7.2 (i386):
http://blog.rogee.nl/post/1299063963/tu ... 0-7-2-i386
Updated packages install for FreeBSD 9.x:
http://code.google.com/p/freenas-dashbo ... eExtraInfo
So, let's begin...
ssh into your N4F machine with root user.
UFS container for installation packages
First, we'll create a UFS formatted container inside our ZFS drive/pool for the unionFS mount, in order to store installation packages on our ZFS storage, rather than on our Flash drive (which is not possible because each time the NAS is rebooted, every new file is deleted).
Please note that each occurrence of "zfspool" is your ZFS drive/pool name. You can see it by typing the command zfs list.
Here, a 2GB volume is created, and the new mount directory /mnt/opt will point to your new UFS formatted container:
zfs create -V 2G zfspool/opt
newfs /dev/zvol/zfspool/opt
mkdir /mnt/opt
mount /dev/zvol/zfspool/opt /mnt/opt
Create some directories:
cd /mnt/opt
mkdir sabnzbd
mkdir var
mkdir usr
mkdir tmp
Using N4F Web GUI, go to System|Advanced|Command scripts and add the 2 mount command lines of PostInit type (press + button for each line):
mkdir /mnt/opt
mount /dev/zvol/zfspool/opt /mnt/opt
Now, using the Web GUI, reboot the NAS, and after it finishes restarting, re-ssh with root user and invoke:
cd /mnt/opt
ls -l
in order to make sure that the sabnzbd/var/usr/tmp directories are still there after the reboot.
If you see these directories, you've finished this stage and you can proceed to the installation.
SABnzbd new group and directories
Using N4F Web GUI, go to Access|Users and Groups|Group and create the group: “sabnzbd”.
Then assign some users to the group, which are going to access the folder.
Invoke these commands. Make sure that no errors or failures are displayed:
cd /mnt/zfspool
mkdir downloads
chgrp sabnzbd downloads
chmod 770 downloads
cd downloads
mkdir blackhole
mkdir complete
mkdir incomplete
mkdir scripts
chgrp -R sabnzbd blackhole
chgrp -R sabnzbd complete
chgrp -R sabnzbd incomplete
chgrp -R sabnzbd scripts
chmod 770 blackhole
chmod 770 complete
chmod 770 incomplete
chmod 770 scripts
Now, we'll logically combine the default /usr and /var system directories with our external directories.
Again, make sure that there are no errors or failures:
mount_unionfs -o w /mnt/opt/usr/ /usr/
umount -f /var
mount_unionfs -o w /mnt/opt/var/ /var/
FreeBSD packages installation
In order to let the SABnzbd work, we'll need some packages which are not included in the N4F embedded, such as python, unzip, unrar etc...
First, make sure you can connect to the internet and resolve DNS addresses, by pinging Google. Press Ctrl+C to stop pinging:
ping google.com
If it fails resolving the address, go to System|General in the web GUI and make sure the DNS servers are properly configured. If you're not sure what to put there, a good bet will be 8.8.8.8, which is one of the Google's DNS servers. Press Save and retry pinging.
Only when ping is successful, you can continue the installation!
Now, for some download and install fun. A lot of lines will be printed for each package installation.
Make sure that each pkg_add does not display failure error at its end.
If you have an x86-embedded installation (32 bit), invoke:
setenv PACKAGESITE "ftp://ftp.freebsd.org/pub/FreeBSD/ports ... nt/Latest/"
if you have an x64-embedded installation (64 bit), invoke:
setenv PACKAGESITE "ftp://ftp.freebsd.org/pub/FreeBSD/ports ... nt/Latest/"
Also, set this:
setenv PKG_TMPDIR /mnt/opt/tmp/
Packages installation:
pkg_add -rv python27 py27-sqlite3
pkg_add -rv unzip
pkg_add -rv py27-yenc
pkg_add -rv py27-cheetah
pkg_add -rv py27-openssl
pkg_add -rv py27-feedparser
pkg_add -rv py27-utils
pkg_add -rv unrar
pkg_add -rv par2cmdline
SABnzbd installation
Invoke:
cd /mnt/opt/tmp
fetch "http://sourceforge.net/projects/sabnzbd ... src.tar.gz"
tar -xzf SABnzbd-0.7.5-src.tar.gz
rm SABnzbd-0.7.5-src.tar.gz
mv SABnzbd-0.7.5 /usr/local/share/
Now, make a small edit to SABnzbd's script. Invoke the "nano" text editor:
nano /usr/local/share/SABnzbd-0.7.5/SABnzbd.py
and in the beginning of the file (use arrow keys), change line from !/usr/bin/python -OO to !/usr/local/bin/python -OO
Save the file by pressing CTRL+X to exit, Y to overwrite and ENTER to confirm the filename.
Go again in the web GUI to System|Advanced|Command scripts and add these 2 lines of PostInit type.
192.168.1.250 is the NAS IP address. Change it if it is a different one in your NAS.
mount_unionfs -o w /mnt/opt/usr/ /usr/
/usr/local/share/SABnzbd-0.7.5/SABnzbd.py -d -f /mnt/opt/sabnzbd/sabnzbd.ini -s 192.168.1.250:8085
Now, reboot your NAS.
SABnzbd and shutdown configuration
If everything went smoothly, you can now access the SABnzbd's web GUI by browsing to
http://192.168.1.250:8085/sabnzbd
Can you see properly SABnzbd's configuration wizard? Hooray, you've made it!
Now, configure your Usenet server details, download folders (use absolute location such as /mnt/zfspool/downloads/incomplete etc...).
Also, in the Folders configuration, set "Permissions for completed downloads" to 777. Save changes after you've done.
Finally, for proper shutdown of the SABnzbd service while shutting the NAS down, go to the N4F web GUI's System|Advanced|Command scripts and add this line of Shutdown type:
/usr/bin/fetch "http://192.168.1.250:8085/sabnzbd/shutd ... n=myapikey" > /dev/null
where instead of "myapikey", copy the API key from the SABnzbd's Config-General web page.
That's it.
Feel free to comment and ask questions.
I'm far from being a FreeBSD expert but I'll try to help...

