Here are my instructions for creating a FreeNAS Jail with Bittorrent Sync (BTsync) running inside it. This uses no FreeNAS plugins whatsoever and takes full advantage of all the power that comes with having a FreeBSD core running at the heart of FreeNAS 9.1. This has been done on FreeNAS-9.1.1-RELEASE-x64.
- Login to your FreeNAS systems web interface.
- Click: Jails
- Click: Add Jail
- For Jail Name use btsync and click ok. Let FreeNAS do its thing.
- The jail will automatically start. You now need to SSH into your FreeNAS box as root. In the alternative SSH in as a regular user and then change to root with su.
- Run: jls
- Make a note of the number to the left of the btsync name used earlier.
- Run: jexec # csh
[where # is the number from item 7. above] - Run: mkdir /usr/local/btsync
- Run: cd /usr/local/btsync
- Run: fetch http://download-lb.utorrent.com/endpoint/btsync/os/FreeBSD-x64/track/stable
- Run: tar zxvf stable
- Run: rm stable
- Run: ./btsync –dump-sample-config > btsync.conf
- Run: pkg_add -rv nano
- Run: nano /usr/local/btsync/btsync.conf
- Change the following:
- Replace: “device_name”: “My Sync Device”, with a friendly name for your BTsync service, e.g. “device_name”: “Fred”,
- Replace: “storage_path” : “/home/user/.sync”, with “storage_path” : “/usr/local/btsync/.sync”,
- Replace: “password” : “password” with “password” : “XXXXXXXXXX” where XXXXXXXXXX is a password of your choosing.
- Close Nano and save the changes: Ctrl +X -> Y -> Enter
- Run: nano /etc/rc.d/btsync
- Insert the following:
#!/bin/sh # # PROVIDE: btsync # REQUIRE: LOGIN DAEMON NETWORKING # KEYWORD: shutdown # # To enable BTSync, add this line to your /etc/rc.conf: # # btsync_enable="YES" # # And optionally these line: # # btsync_user="username" # Default is "root" # btsync_bin="/path/to/btsync" # Default is "/usr/local/sbin/btsync" . /etc/rc.subr name="btsync" rcvar="btsync_enable" load_rc_config $name required_files=$btsync_bin : ${btsync_enable="NO"} : ${btsync_user="root"} : ${btsync_bin="/usr/local/sbin/btsync"} : ${btsync_config="/usr/local/btsync/btsync.conf"} command=$btsync_bin command_args="--config ${btsync_config}" run_rc_command "$1"
- Close Nano and save the changes: Ctrl +X -> Y -> Enter
- Run: chmod 555 /etc/rc.d/btsync
- Run: nano /etc/rc.conf
- Insert the following:
# BitTorrent Sync btsync_enable="YES" btsync_user="nobody"
- Close Nano and save the changes: Ctrl +X -> Y -> Enter
- Run: chown -R nobody:nogroup /usr/local/btsync
- Run: mv /usr/local/btsync/btsync /usr/local/sbin/
- Run: chown root:wheel /usr/local/sbin/btsync
- Login to your FreeNAS systems web interface.
- Click: Jails
- Stop the btsync jail and start it again. Bittorrent Sync should now be running.
- Click: Edit Jail
- Make a note of IP.
- Login to your Bittorrent Sync web interface via: XXX.XXX.XXX.XXX:8888
[Where XXX.XXX.XXX.XXX is the IP from Item 34]
That should about do it.
Some things to remember:
- You can use the FreeNAS admin interface to mount storage into folders that exist outside of the jail into the jail.
- Files and folders should all be set to nobody:nogroup as a user/group combination. This killed off 99.9% of problems I was having.
- Bittorrent Sync does not seem to update itself at the moment, at least it hasn’t thus far in this configuration. This could be because it just doesn’t do it on FreeBSD or because I’ve done something stupidly wrong. Either way you’ll have to watch the version numbers.