Our business has been slowly replacing our various storage solutions and migrating to FreeNAS. We had previously used a mix of proprietary solutions including Drobo, Synology and OSX Server. After much investigation and testing, we found that FreeNAS suited our current needs and would be the most likely candidate to satisfy our future expansion.
We manage our own on and off-site backup and have been using Bittorrent Sync with great success. FreeNAS features a BTsync plugin but I have found that the setup is not quite as straightforward as it could be. Especially when you have a number of different datasets and user permission configurations.
I wrote this installation guide for our internal wiki at work and would like to make it available to anyone running into problems with BTsync on FreeNAS.
Installing and configuring BTsync on Freenas
This article is written for FreeNAS firmware version: FreeNAS-18.104.22.168-RELEASE-x64 and BTSync PBI version btsync-1.3.106-amd64. Other versions may behave differently.
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 synchronized. 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 individually manually.
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.
There it is. Any questions or suggestions can be left in the comments area below. Good luck!