onsdag den 8. januar 2014

Using a Raspberry Pi as a medium between external server and local NAS, using Bittorrent Sync



So i managed to sell my server build in bits and pieces. And for the money i purchased a 2 bay Zyxel NSA320, despite having an unfortunate name, it is a small form factor standard NAS. 1.2 GHz processor and 512 MB RAM. It is close to official with support for the Fonz Fun Plug, and if using from USB stick it is fairly fool proof as the NAS OS is left untouched, unless you want to kill it. The NAS is pretty loud and as far as i can tell there is no way, system wise, to lower the RPM's. S.M.A.R.T. spins the drives down, but the chassis main fan spins at full speed no matter what. I took it apart and it looks like control of the fan has been disabled by hardware. Next to the fan plug is what looks like a controlled fan mount, but soldering on this device based on a theory is further than i am willing to go at this point. Instead i bought a Fan Mate 2 physical resistance controller, that i have yet to install.

#Update. The Fan Mate can be installed but have no effect what so ever on the fan.





First thing i did was to throw the ARM build of Bittorrent Sync on it to sync it up with my remote server, and it was up and running within 15 minutes. After a reboot, btsync was nowhere to be found. And i had made sure i placed it in the permanent storage. Btsync would run and be forked to the background, but gui was unresponsive no matter what. I cleaned out every bit of btsync from .sync to license.txt but no matter what, a install would work, but gui would not. i then tried a manual install by compiling every bit of btsync to try to change the listening port as some users had reported 100% cpu use and unresponsive gui from using port 8888. In my case it did not work. Btsync still runs, but gui remained unreachable from any browser.



Now btsync is actually fairly easy to set up using the bash command line and since it really only needs to be set up very rarely it would be pretty straight forward. I however choose to utilize a Raspberry Pi, that had been sitting on a shelf since i upgraded my media player. I flashed Raspbian on a 8 GB SD card, and to keep from plugging in a HDMI monitor and controllers i used SSH to login to the RPi using the default "pi" and "raspberry" credentials and then run


# sudo apt-get install tightvncserver

# tightvncserver


That gave me a headless control of the RPi using the tightvnc application. From my Windows 8 computer i then ran the tightvnc viewer and connected to the IP. In a quick and dirty move in the /home/ directory i ran


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

# sudo tar -xzf btsync_arm.tar.gz

# sudo rm btsync_arm.tar.gz

# sudo ./btsync


That worked straight away. All i had to do now was mount the NAS cifs share as a drive for btsync to download to. in /mnt/ i created a directory


# sudo mkdir nas320


the cifs utilities should come with most distros, but if needed run


# Sudo apt-get install cifs-utils


I then navigated to the /etc/ directory and ran a command to edit the fstab file



# sudo nano fstab



Below the proc, boot and main partition i added a referal to my NAS cifs share:

(keep in mind the following is on the same line in the same tabbed formatting that the already existing drives are)



# //192.168.1.88/sync/video

# /mnt/nas320

# cifs

# credentials=username=your_username,password=your_password,iocharset=utf8

# 0

# 0


Now this is a pretty dirty and unsafe way to do things. For a bit more security i would recommend creating a .smbcredentials file using



# sudo touch .smbcredentials


Where you want to keep the file. This would mean you would have to change the credential part of the line you added in the /etc/fstab file.


instead you would now add


# credentials=/path/to/.smbcredentials,iocharset=utf8


This makes makes the mount persistent and will be mounted upon reboot.

I still need to manually start up btsync, but adding the auto run script is fairly easy, but must wait a few days.








Ingen kommentarer:

Send en kommentar