FreeNAS Jail with Bittorrent Sync

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.

  1. Login to your FreeNAS systems web interface.
  2. Click: Jails
  3. Click: Add Jail
  4. For Jail Name use btsync and click ok.  Let FreeNAS do its thing.
  5. 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.
  6. Run: jls
  7. Make a note of the number to the left of the btsync name used earlier.
  8. Run: jexec # csh
    [where # is the number from item 7. above]
  9. Run: mkdir /usr/local/btsync
  10. Run: cd /usr/local/btsync
  11. Run: fetch
  12. Run: tar zxvf stable
  13. Run: rm stable
  14. Run: ./btsync –dump-sample-config > btsync.conf
  15. Run: pkg_add -rv nano
  16. Run: nano /usr/local/btsync/btsync.conf
  17. Change the following:
    1. Replace: “device_name”: “My Sync Device”, with a friendly name for your BTsync service, e.g. “device_name”: “Fred”,
    2. Replace: “storage_path” : “/home/user/.sync”, with “storage_path” : “/usr/local/btsync/.sync”,
    3. Replace: “password” : “password” with “password” : “XXXXXXXXXX” where XXXXXXXXXX is a password of your choosing.
  18. Close Nano and save the changes: Ctrl +X -> Y -> Enter
  19. Run: nano /etc/rc.d/btsync
  20. Insert the following:
    # PROVIDE: btsync
    # 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
    load_rc_config $name
    : ${btsync_enable="NO"}
    : ${btsync_user="root"}
    : ${btsync_bin="/usr/local/sbin/btsync"}
    : ${btsync_config="/usr/local/btsync/btsync.conf"}
    command_args="--config ${btsync_config}"
    run_rc_command "$1"
  21. Close Nano and save the changes: Ctrl +X -> Y -> Enter
  22. Run:  chmod 555 /etc/rc.d/btsync
  23. Run: nano /etc/rc.conf
  24. Insert the following:
    # BitTorrent Sync
  25. Close Nano and save the changes: Ctrl +X -> Y -> Enter
  26. Run: chown -R nobody:nogroup /usr/local/btsync
  27. Run:  mv /usr/local/btsync/btsync /usr/local/sbin/
  28. Run: chown root:wheel /usr/local/sbin/btsync
  29. Login to your FreeNAS systems web interface.
  30. Click: Jails
  31. Stop the btsync jail and start it again.  Bittorrent Sync should now be running.
  32. Click: Edit Jail
  33. Make a note of IP.
  34. 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.

9 Replies to “FreeNAS Jail with Bittorrent Sync”

  1. Hi,
    Thank you very much for this tuto.
    When I type in the IPadress:8888 in my browser, I got an error message saying Firefox (it’s the same with Chrome) can’t establish a connection with the website (the original message is in French).
    I tested http and https.
    I already have a plug in which works.
    Do you have any idea?
    Thanks in advance

  2. Hi buck442,

    Login to your FreeNAS box and click on “Display System Processes” and check if there a running entry for btsync.

    If there is double check you have the right IP address for your Jail (this is different from your main FreeNAS IP) and if that does not work double check your configuration file has the correct port number.

    Let me know if you get Bittorrent Sync up and running!

  3. Hi,
    Please help me with this problem.
    Thank you

    Can’t accept ‘–dump-sample-config’ as argument
    BitTorrent Sync 1.2.73
    btsync [–config ] [–nodaemon] [–generate-secret] [–dump-sam$
    –config – location and name of configuration file
    –nodaemon – do not use daemon mode
    –generate-secret – generate shared secret
    –get-ro-secret – get read only secret for existing master secret
    –dump-sample-config – dump sample config file
    –help – print this message and exit

  4. I am trying to replace a current backup solution for clients with btsync running on freenas.

    My plan is to run btsync on the clients servers/pc and then read-only subscribe using 2 different servers in different locations using btsync and then make daily/weekly/monthly snapshots using zfs to have revisions to rollback to.

    Do you think I should do it all under one jail, or should I make seperate jails for each client? Will 10-20 jails running btsync cause an issue? I’m interested in your thoughts.


  5. Great tutorial, however similar to buck442, I can’t login. Unable to connect. When I click edit jail to see what the IP is, it does give a valid one

  6. Hi Roman. Not sure why you’re having any issues as the output you posted shows that it is one of the available options in bittorrent sync.

  7. Hi realmrealm, personally I’m not sure if relying on bittorrent sync for backup is a great plan as they could introduce a breaking change at any time. That being said with what you’re proposing I’d personally use one instance in one jail as then you only have to manage one interface and you could separate out the data using ZFS methods that are best suited to that task. Let me know how you get on.

Leave a Reply