Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

BTSync Configuration Guide

Cainram

Newbie
Joined
Jan 23, 2014
Messages
31
*NOTE* I have made some edits and corrections to this guide. The most current version can be found at my blog.

I had to jump through some hoops to get my BTSync plugin working the way I wanted. I then wrote an article for our internal wiki here at work and wanted to share it with the community. I don't have the priviledges to post this in the How To Guides section so I'll post it here. Hope it helps someone.

Installing and configuring BTsync on Freenas
This article is written for FreeNAS firmware version: FreeNAS-9.2.1.6-RELEASE-x64 and BTSync PBI version btsync-1.3.106-amd64. Other versions may behave differently.

Configure Storage
You may configure your ZFS datasets however you wish with one exception: You cannot mount a directory to a jail that has the jails installation as a subdirectory. When configuring storage, be sure to create a special dataset for use by all jails in the root of the volume. Also, take care when setting group permissions for the datasets to be syncronized. The group owner of the dataset is what will be used by the BTSync jail for purposes of access permission.

For this example, we have a volume called tcDATAvolume containing four datasets: tcDATAa, tcDATAb, tcDATAc and jails and the group owners of said datasets are tcGROUPa, tcGROUPb and tcGROUPc respectively.

Configure Jail Settings
Expand the Jails entry on the tree menu and select Configuration. For the Jail Root setting, browse to the dataset you created for the jails. Make sure the IPv4 Network setting is correct and in propper xxx.xxx.xxx.xxx/xx notation. The IPv4 Network Start Address and IPv4 Network End Address limits the range of IP addresses that will be automatically assigned to newly created jails. These values can be set to the same address to ensure that the next jail created will use the desired address. IMPORTANT: To avoid IP address conflicts, take care to check these values each time you install a plugin as the plugin installation routine will not offer an opportunity to set the IP address of the automatically created plugin jail.

Install BTSync Plugin
Click the Plugins icon in the horizontal top menu. Click on the BTSync entry in the list of available plugins to enable the Install button at the bottom of the page. Click the Install button. The Install Plugin dialog box will appear. Click the OK button. If no jails have been installed, FreeNAS will download the appropriate jail template, create the jail and install the BTSync PBI into the jail.

Add Storage to the Plugin Jail
Click the Veiw Jails entry in the tree menu on the left side of the page. Be sure the Jails button is hightlighted at the top of the Jails tab and you can see the list of jails. Select the BTSync jail you have just created and click the Shell button on the bottom of the page. We will now create directories for our datasets that we would like synchronized.

In this example, we want three separate datasets and we'll name the directories the same as the datasets that exist in the FreeNAS installation: tcDATAa, tcDATAb and tcDATAc. We will be using the /media directory because it is not typically otherwise used by a BTSync Jail. Enter the following commands into the shell:

cd /media
mkdir tcDATAa tcDATAb tcDATAc
ls

You should see output indicating that your directories have been created. Close the shell by clicking the X at the top right of the window. Return to the Jails tab and select the BTSync jail. Click on the Add Storage button at the bottom of the page. The Source field will contain the dataset we wish to synchronize. Click the Browse button and navigate to the tcDATAa dataset. The Destination field will contain the /media/tcDATAa directory we created earlier. Click the Browse button and navigate to the desired directory. Click the OK button and watch the top of the screen for the notification indicating that the storage was added successfully. Repeat this action for the other two datasets.

IMPORTANT: Mounting a dataset to a jail does NOT automatically mount child datasets. Child datasets must be mounted manually individually.

Configure Permissions
It is now necessary to create permission groups within the jail that match the GIDs of the groups that own the datasets in our FreeNAS machine and then add the btsync user to those groups. Expand the Account and User entries in the menu tree and click on the View Groups entry. For this example, we've created groups called tcGROUPa, tcGROUPb and tcGROUPc. These groups can be found near the top of the list of groups and we have to note the Group ID number. For this example, the values are 1001 for tcGROUPa, 1002 for tcGROUPb and 1003 for tcGROUPc. Return to the Jails tab and select the BTSync plugin jail. Click the Shell button at the bottom of the page. We will now create three groups in the jail and add the already existing btsync user to all three groups so that the jail can have write permissions for the datasets we added earlier. Enter the following commands into the shell, substituting your actual groups and group IDs for the examples given here:

pw groupadd tcGROUPa -g 1001
pw groupadd tcGROUPb -g 1002
pw groupadd tcGROUPc -g 1003
pw usermod btsync -G tcGROUPa,tcGROUPb,tcGROUPc
tail /etc/group

The last command will show a list of all the groups, their GIDs and the members of each group. You may close the shell using the X at the top right of the shell window.

Restart the Plugin and the Jail
Return to the Plugins tab and click the Installed button at the top of the tab to see the list of installed plugins. The BTSync plugin should not be set to ON but if it is click the ON button and wait until the service status indicator changes to OFF. Go to the Jails tab and select the BTSync jail. Click the Stop button at the bottom of the page. In the Stop dialog box, click the OK button and watch the top of the page for the indication that the jail has been stopped. Select the BTSync jail again and click the Start button at the bottom of the page. Click the OK button in the Start dialog box. Return to the Plugins tab and click the Installed button at the top of the tab. Click on the OFF button in the Service status column and the status should change to ON. Expand the Plugins entry in the tree menu and click on the BTSync entry. The first line in the BtSync dialog box reads, "BitTorrent Sync can be found here." Click the link to go to the BTSync configuration web page.
 
Last edited:

Yatti420

FreeNAS Guru
Joined
Aug 12, 2012
Messages
1,436
Good guide.. This should be moved to How-To..
 

diedrichg

FreeNAS Expert
Joined
Dec 4, 2012
Messages
1,239
A Syncthing guide would be awesome. That program is confusing as hell! -Especially all the ports that should or need to be opened.
 
Joined
Nov 30, 2014
Messages
2
Hello Cainram,

first, thank you for this guide. Good work.
But I have a problem. The btsync daemon can't create any directories. Via the web gui I create a new sync folder by navigating to the mounted volume (e.g. "/mnt/media/btsync"), add the new folder name (e.g. "/mnt/media/btsync/my_mbp"), click "generate key" and "add" -> "can't open destination folder". Seems like the btsync user can't write to the directory.
But: when I connect to the jail via ssh using the btsync-user, everything is fine. I can mkdir and everything.
I double-checked the UID of the btsync user inside and outside the jail, they're matching.
I'm a bit confused, maybe you have an idea or a hint?
 

Cainram

Newbie
Joined
Jan 23, 2014
Messages
31
It is the group UUIDs that are an issue. Double check that the BTSync user is a member of a group with the same UUID as the GROUP that owns your dataset. You can also set the owner of the dataset to Nobody, if you wish. Can you generate keys for folders that already have been created in the shell? That is the only way I have done it; I've never created a folder from within the BTSync web GUI.

Are you using the same version of FreeNAS as I detailed in the guide? If not, that may have something to do with it... I don't know. I'm not a FreeNAS or ZFS guru, I just figured out this one thing and put a guide together for it... Maybe start your own thread regarding this topic and refer to this guide. Some of the users here are real wizards, I'm sure you'll get an answer. Who knows, you may have found a bug.
 
Joined
Nov 30, 2014
Messages
2
Hi Cainram,

I found the solution to my problem. If I change the group owner of the btsync-dataset to www,everything works fine.
Logic is helpful. I should listen to my inner Spock more often ;-)
 
Last edited:

CraftyClown

FreeNAS Experienced
Joined
Apr 5, 2014
Messages
214
Hi Cainram,

are you using the new BTSync 2 yet? Damned if I can get it to accept my license key! I'm wondering if it's me, or a problem with the plugin?
 
Top