BitTorrent Sync: Turning Your Old Computer into an NAS Drive

DSC00393

So you’ve upgraded to a new computer. Congratulations. Now you have to decide what to do with that old computer. Give it to your parents? Reenact your favorite scene from Office Space? How about you turn that piece of junk into a Network Attached Storage (NAS) device running BitTorrent Sync. It may not play Crysis, but it will provide you with a plethora of options including FTP, redundant storage, and most importantly, BitTorrent Sync.

If you aren’t familiar with BitTorrent Sync, you can read up about it here. In a nutshell, it allows you to sync folders between machines using P2P. No cloud necessary. Sync never stores your data on a stranger’s computer. Only people with access to your “Secret” can store your data. Interested? Lets get started.

Here is what you’ll need for this project:

  • An old computer with a 64 bit processor (recommended)
  • At least one hard drive in the computer
  • 4GB or larger thumb drive
  • At least 4GB of ram (recommended)
  • CAT5 cable

Booting up FreeNAS:

First you need to get FreeNAS up and running on your old machine. This is actually a lot easier than you may think. Download the image from here.

This tutorial was written using FreeNAS-8.3.1-RELEASE-p2. Copy the image to your thumb drive using the instructions on this page.

Make sure you have an ethernet cable running from your computer to your router. Then plug your thumb drive into your computer and turn it on. Set your BIOS to boot to that thumb drive by default and then let your computer boot up. This will take a few minutes.

After FreeNAS is done booting up, you will see a few options and an IP address/URL. For example: 192.168.1.2. Enter that IP address into a browser on a different computer on the same network. This will bring you to the GUI that you see pictured below.

Screen Shot 2013-06-17 at 11.02.43 AM

FreeNAS Initial Setup

You should see an alert in the top right. If you click on it, it will tell you to set your admin password. To do this, navigate to the left column and select: Account > Admin Account > Change password.

Next you need to configure your hard drives. This will wipe all data, so backup anything you want to keep. Go to: Storage > Volumes > Volume Manager. Select your disks, provide a volume name (I’m using the name “NAS” for this tutorial), select ZFS and add the volume. There are other options here that I am skipping, and I’d encourage you to read up if you are interested in more advance options.

Now lets set the proper permissions for this new volume. Go to storage > volumes. Find the volume you just created and click on “change permissions”. Check all the boxes, select “set permissions recursively”, and click “change”.

You’ll need a few new datasets before moving forward. Go to Storage > volumes > view volumes. Create two new datasets for your new volume. Call the first one “data” and the second one “sync”.

The next step is setting up a CIFS share. I chose CIFS because it works with both Mac and PCs. On the left column, navigate to Sharing > CIFS shares > Add Windows CIFS share. Give the CIFS share a name, select the “data” folder for the path and allow guest access.

Your volume should now appear as network storage to any computer on your local network. If all you want is NAS storage, you can stop here. If you want to unlock the real potential of your NAS drive, then read on.

Setting Up BitTorrent Sync

Open up shell from the left column. If you are comfortable with SSH, you can do that instead. Change directories to the sync folder:

cd /mnt/NAS/sync

Download BitTorrent Sync:

fetch "http://btsync.s3-website-us-east-1.amazonaws.com/btsync_freebsd_x64.tar.gz"

Extract the files:

tar -xzf btsync_freebsd_x64.tar.gz

To run Sync, you can simply enter: ./btsync. To make things easier, lets make Sync run on startup.

For the next few steps, you’ll need to make modifications to the file system. To do this, type:

mount -uw /

Next lets add a script to rc.d. This script is slightly modified from forum contributor Dalys.

cd /conf/base/etc/rc.d
touch btsync
nano btsync

After the last command you’ll be able to edit the new btsync file. Copy and paste the text from below:

#!/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"}

command=$btsync_bin

run_rc_command "$1"

ctrl+o and ctrl+x to save and exit

Now make this new file executable:

chmod ug+x /conf/base/etc/rc.d/btsync

Finally, enter:

nano /conf/base/etc/rc.conf

and add the following to the bottom of the file:

# BitTorrent Sync
btsync_enable="YES"

ctrl+o & ctrl+x to save and exit

BitTorrent Sync will now start automatically whenever you reboot FreeNAS. You can access it from any computer on your network by entering your.ip.address:8888/gui into the browser on any computer on your network. For example: 192.168.1.2:8888/gui

Done. That wasn’t so hard, right? This is WAY better than donating your old computer to your parents. There are so many useful and creative ways to use BitTorrent Sync once you have it set up on a local NAS drive.

If you’d like to see what some of our community members are doing with BitTorrent Sync, check out our forums.

Written by: Dan

Dan is the Digital Creative Manager for BitTorrent Inc. He can usually be found writing blog posts, updating BitTorrent Labs, or browsing Reddit when he thinks no one is looking. He likes working at BitTorrent because they let him keep his Star Trek bobble heads on his desk.

 Related Posts:
  • gabor

    I would like to turn my router to BTsync drive. Please support MIPS also.
    Thanks
    gabor

  • charles

    hey can you explain to me why BT sync is being added and what purpose it solves

  • Paul Cornett

    one error that you should fix… you still have btsync in /data.

    you have to do one of the following to fix:

    1. cp /data/btsync /usr/local/bin

    2. edit /conf/base/etc/rc.d/btsync and change
    : ${btsync_bin=”/usr/local/sbin/btsync”}
    to : ${btsync_bin=”/data/btsync”}

    if you do 1, then your .sync will be in /usr/local/bin…. not really what you want.

    • Paul Cornett

      ugh…. messed that up..

      you want to keep ./btsync in /data and edit /conf/base/etc/rc.d/btsync to point to /data/btsync.

  • Tajnymag

    Can I after installing btsync still acces freenas gui(settings,volume manager..?

  • Tajnymag

    Will I be after installing BittorentSync still able to acces FreeBAS gui?

  • Kevin

    Following your instructions, I was able to run btsync manually quite easily, but your scripts for running btsync run on startup don’t work at all.

  • Marek Lukáš

    For me the autorun script doesn’t work.I tried it write exactly how you wrote and even tried to change btsync bin location.Still doesn’t work.BitTorrent works great, but can’t start itself :-(

  • Tim

    I believe the write access no longer being there after reboot is a problem.
    As a note: you need to start btsync at least once to have the .sync dir created.

  • Mike

    BTSync Version 1.1.70 ( up to date ) on FreeNAS 9.1.1 and Windows 8.

    I followed the above guide and BTSync worked until I rebooted FreeNAS – so I manually started btsync and got the following error:

    WARNING pid 2288 (btsync): ioctl sign-extension ioctl ffffffff8004667e

    The btsync gui on FreeNAS opens but no sync between FreeNAS and Windows 8 occurs even though both machines see each other as connected devices.

  • http://www.freenas.org Ben

    There’s now a btsync plugin for FreeNAS, making this process MUCH simpler! I’m a part of the company that develops FreeNAS, iXsystems. Dan, if you’d like, we could help with an update to this post showing how to use the new BTSync plugin for FreeNAS.

  • sfiu

    This dont work!!
    Why not make it simple?
    I just put a line: /path/to/folder_with_btsync_binary/btsync in /conf/base/etc/rc.conf and it works.