Install BitTorrent Sync on Debian (Raspbian)

BitTorrent Sync

BitTorrent Sync was released last month and I’ve been playing around with it for the last couple of days. I currently have it syncing data between OwnCloud and my personal machine, effectively creating my own fully fledged DropBox replacement (more on that in another post!).

Today I am going to cover installing BitTorrent Sync into your copy of Debian (I am using Raspbian on my RasPi), so that when you restart the machine, it starts up with you. Hit the jump for the detailed instructions!

Update 18/5/13 – Thanks to BitTorrent forum user tuxpoldo for adding the Debian ARM packages so they can be installed through apt-get. Click here to go down that route, or do it manually below!

Update 1/09/2013 – Thanks for everyone who has posted a comment / asked for assistance on this post. This was really my first technical guide blog post, and has had an awful lot of hits over the last 3 months, so thanks again. I have updated the post to fix an issue with setting the init.d script to executable, rookie mistake!!

1. Download BitTorrent Sync

Get into your home directory on your OS and execute the command (this is the ARM version for the Raspberry Pi, use the correct architecture for your machine, go here), and take a look at the User Guide first, trust me!.

(EDIT: GreatMarko over at the BitTorrent Sync Forums just informed me of this link which has package installers for AMD / Intel based machines, will make this a lot easier for you guys but if you have a Raspberry Pi, stick around!)

wget http://btsync.s3-website-us-east-1.amazonaws.com/btsync_arm.tar.gz

Then run:

tar -zxf btsync_arm.tar.gz

2. Move the application and set permissions

You should now have a file called btsync. Now your going to need root access to your machine (we are installing this into the OS away from your home directory). I use the command sudo bash for this.

Now we need to create the directory to contain the application and its files. Run the below commands.

mkdir /etc/btsync
mv btsync /etc/btsync/
cd /etc/btsync/
chown root:root btsync
chmod 755 btsync

This makes the directory to contain the app, moves the program, sets the owner of the program to root and sets it to be executable.

3. Setup the btsync config

Bundled within the application is a config file, to get this out to change settings (this is the easiest way), run:

./btsync --dump-sample-config > sync.conf

This will have dumped a file called sync.conf in the same directory. Use your desired text editor to access and change some file settings (I use nano, which would be nano sync.conf).

Settings to change:

  • “device_name” – anything you want
  • “storage_path” – add // at the start of the line to comment out this line
  • “login” – set a username OTHER THAN ADMIN
  • “password” – choose a password – this is being stored in plain text so ensure you choose something you don’t usually use.

If you’re using nano hit Ctrl+O, Ctrl+X (save and quit) and then your good to go.

4. Create the init.d script

This is the script that you can use to start / stop the BitTorrent Sync application, and use it to boot up on start.

While still with root access, run the following:

nano /etc/init.d/btsync

This will open up a new file where you can write your script. You are going to need to copy the below EXACTLY into the window and save and quit.

#! /bin/sh
# /etc/init.d/btsync
#

# Start or Stop BT Sync
case "$1" in
  start)
        /etc/btsync/./btsync --config /etc/btsync/sync.conf
    ;;
  stop)
        pkill btsync
    ;;
  *)
    echo "Usage: /etc/init.d/btsync {start|stop}"
    exit 1
    ;;
esac

exit 0

Next, set the script to executable. Run

chmod +x /etc/init.d/btsync

Once this has been done we need to set the the program to start on boot, using the following command:

update-rc.d btsync defaults

Once you have run the above you may see the below warnings, don’t worry about them!

update-rc.d: using dependency based boot sequencing
insserv: warning: script 'btsync' missing LSB tags and overrides

You can start BitTorrent Sync by calling the following command:

/etc/init.d/btsync start

You are now done! To access your installation of BitTorrent Sync, point your browser at http://yourip:8888/gui. Enter the login details you saved in the config file and you are good to go. To use the features refer to the user guide!

If you have any comments, updates, annoyances with this please leave me a message below and I will try my best to help!

 

Comments

  • Bergt

    When you try to start the service and it gives the following message:

    # /etc/init.d/btsync start
    bash: /etc/init.d/btsync: Permission denied

    Make the file executable by doing this, now it should start fine

    chmod +x btsync

    • chmod 755 btsync should have taken care of that but thanks for the tip for other users!

  • peter pradel

    thanks for your guide, but:

    update-rc.d: using dependency based boot sequencing
    insserv: script btsync is not an executable regular file, skipped!

    Can you tell me why he is telling this? 🙁

    • could you cd to /etc/btsync and run ls -la and reply with the output?
      It should look something like..

      drwxr-xr-x 3 root root 4096 May 7 14:26 .
      drwxr-xr-x 106 root root 4096 May 18 06:33 ..
      -rwxr-xr-x 1 root root 3424480 Apr 18 12:19 btsync
      drwxr-xr-x 3 root root 4096 May 18 16:43 .sync
      -rw-r–r– 1 root root 1861 May 7 14:17 sync.conf

    • # chmod +x /etc/init.d/btsync

      Run this and that will solve the issue!! Very late reply, had to rebuild by raspberry pi and came across this issue when reinstalling BTSync. I have amended the post to include this.

      Thanks for pointing this out Peter!

  • peter pradel

    ok, here we go:

    drwxr-xr-x 2 root root 4096 May 18 17:02 .
    drwxr-xr-x 96 root root 4096 May 18 17:01 ..
    -rwxr-xr-x 1 root root 3412684 May 15 15:41 btsync
    -rw-r–r– 1 root root 1829 May 18 17:08 sync.conf

  • Pingback: ownCloud + Bit Torrent Sync = Dropbox Clone! | adam matthews

  • João Moura

    Thanks for your guide.
    I have a problem regarding permissions. If I’ve understand correctly, the btsync process is run as “root”. All the folders and files created trough this process are only available to the root user. How can I change this behavior in order to give access to the synced files to everyone?
    Also, could you tell me what are the advantages of running btsync as “root”?
    Sorry if I’ve asked anything too basic.

  • Michael

    Thanks for the description.
    For security reasons I suggest not to run as root … whenever possible. Remember the software is still alpha.

    My working plan with the latest version1.1.15 – be careful, it its not compatible with 1.0.x-versions:
    1) create user btsync

    adduser btsync
    su btsync
    wget http://syncapp.bittorrent.com/1.1.15/btsync_arm-1.1.15.tar.gz
    mkdir btsync
    cd btsync
    tar -zxvf ../btsync_arm-1.1.15.tar.gz

    # the program runs now in /home/btsync/bin/btsync

    2) create /etc/init.d.btsync as user root
    nano /etc/init.d/btsync

    ##### begin /etc/init.d/btsync #####
    #! /bin/sh
    # /etc/init.d/btsync
    #

    # Start or Stop BT Sync

    BTSYNC_USER=”btsync”

    DAEMON=/home/btsync/bin/btsync

    case “$1” in
    start)
    echo “Starting btsync…”
    start-stop-daemon -b -o -c $BTSYNC_USER -S -u $BTSYNC_USER -x $DAEMON
    ;;
    stop)
    echo “Stopping btsync…”
    start-stop-daemon -o -c $BTSYNC_USER -K -u $BTSYNC_USER -x $DAEMON
    # pkill btsync
    ;;
    *)
    echo “Usage: /etc/init.d/btsync {start|stop}”
    exit 1
    ;;
    esac

    exit 0
    ##### end /etc/init.d/btsync #####

    # change users rights
    chmod 755 /etc/init.d/btsync
    update-rc.d btsync defaults

    # reboot by
    reboot
    # or start by
    /etc/init.d/btsync start

    # once you check:
    ps -aux | grep btsync

    you will see btsync running as user btsync

    remark: be sure to set the right rights for the directory user btsync and its process btsync accesses.

    best regards and many thanks for the good raspberry info!!!

    Michael

  • Hello,

    “You can start BitTorrent Sync by calling the following command:

    /etc/init.d/btsync start”

    doesn’ works for me.

    At the reboot of the system, btsync doesn’t run.

    Chris

  • mglenn

    Christophe MARTIN.
    here’s what i did to get it to work. a couple of errors in michaels script…

    change:
    BTSYNC_USER=”btsync”
    to
    BTSYNC_USER=btsync

    change:
    case “$1″ in
    to
    case “$1″ in

    its hard to tell, but one of the parenthases is not *really* a parenthases”. It looks more like a double-backtick character. This bites me from time-to-time when I do a copy & paste from a internet page into my text editor (vi). Perhaps it doesn’t affect you. Anyway, hope this helps.

  • Michael

    Christophe MARTIN.

    sorry, I made a mistake regarding the location of the binary, which actually came from my old setup.

    of course:

    adduser btsync
    su btsync
    cd ~/
    wget http://syncapp.bittorrent.com/1.1.15/btsync_arm-1.1.15.tar.gz
    mkdir bin
    cd bin
    tar -zxvf ../btsync_arm-1.1.15.tar.gz

    now, the binary resides in /home/btsync/bin

    logged on as user btsync, you can try to start and stop btsync on the raspberry:
    service btsync start
    Starting btsync…

    check for running process:
    ps -aux | grep \/bin\/btsync
    should show something like this

    btsync 14812 1.0 0.6 57504 3068 ? Ssl 15:47 0:00 /home/btsync/bin/btsync

    or try to stop it
    service btsync stop
    Stopping btsync…

    Just in case the parentheses are a problem:
    check out the the full script here:
    http://pastebin.com/4DQphR2L

    would like to hear, whether it works, let me know, man thanks

  • Thankful Goat

    Great article. Thank you for taking the time to write it up.

    Everything worked first time except for one minor thing (I believe it was mentioned above). The following file needs to be given executable permissions after you’ve created it: /etc/init.d/btsync

    Excellent stuff – just wanted to show my appreciation!

    • Cheers! I have updated the article to include this now, as I had the same issue when reinstalling!

  • Robin

    I know very little about what I’m doing – but I’m muddling along! I have followed the instructions to get BTSync running in the /home/btsync/bin folder. I have also dumped a sync.conf file to this folder to try to include a login password when using the web browser, but I don’t think the script ##### begin /etc/init.d/btsync ##### calls that configuration file when it runs. What do I need to add? Thanks, Robin.

    • Post any errors you get and we can take a look. Are you gettig the login box when you go to :8888? There might be a firewall issue or something else!

  • Tobi

    Hi Adam,

    I have just been trying to set up Bittorrent Sync on my laptop and my PC, but despite entering the secrets properly, I can’t see any connected devices on both machines. Given that you are studying at the University of Kent as well (my PC is connected via LAN and the laptop via WLAN there), do you have any ideas if this could be a firewall issue in the University?

    Best,
    Tobi

    • Hi Tobi,

      There is a big possibility that the BitTorrent protocol is being blocked / throttled somehow within the UKC Network. I think the LAN (depending on if you are on the SBS or main staff network) will be OK, but Eduroam may lock it down somehow. Might be worth speaking to the Helpdesk about (I used to be one of the ‘blue shirts!’) or email helpdesk[at]kent.ac.uk, which is probably a better route as that goes straight to the service desk.

      It might also be worth checking firewall settings on your PC and Laptop, make sure they are both allowing the ports you are using (I’m using 9876 and 8888).

      Nice to see a local on here! I’m no longer studying at the Uni (graduated :D) but the network specifics picked up won’t leave me for a while!

      Cheers,
      Adam

  • name

    /bin/mkdir: /bin/mkdir: cannot execute binary file

  • Zoli

    Hi,

    Where do I find the sync.conf that I need to edit? I think I created some of it in different places… 🙂

    Thanks

  • Pingback: Et si on faisait un vrai cloud personnel ? | PowerJPM

  • runejustesen

    Hi

    Thanks for the guide! I have installed btsync, and it works, though I would like to uninstall it again. How do I do that considering how it has been installed following the guide above?

    Thanks!

  • Pingback: Informatica gestionale | InformaticaGestionale.it

  • jeykey

    THanks a lot ! Works fine from my Pi 😉

  • Pingback: Installer BitTorrent Syncro sur le CubieBoard | ... Mon bloc-notes ...… Mon bloc-notes …

Leave a Comment