Raspberry PI 2 as a NAS device with torrenting

GOAL: Use a Raspberry PI as a NAS Seed Box (Network Attached Storage running torrent software). RPi 2 is perfect for this due to running at very low electrical low power and being faster than a Fast Ethernet bottleneck. I initially bought a RPi version 1B which I returned as it couldn’t send files over a wired LAN at 10MB per second (basically the bottleneck for Fast Ethernet (100mbps)). Also I can use a thin client for torrenting on my PC with Deluge rather than just a webUI.

Setup:

  • RPi version 2B running Ubuntu (yay linux).
  • USB Drive formatted in NTFS.
  • Installed Samba (windows file sharing).
  • Installed Deluge torrent software with a web interface (deluge also supports a remote thin client 🙂 ).

Instructions:

Using a HDMI monitor and keyboard:

  1. Install Ubuntu for RPi v 2B (not Snappy Ubuntu Core which doesn’t support apt-get), instructions for putting a system image on an SD card are here. Note again we aren’t using the image on the RPi site but rather the one on the Ubuntu Wiki.
  2. Follow the first instruction at the above Ubuntu link to resize the SD card partition. The only other instruction on that page I followed was install a SSH server, since I am not installing any GUI stuff on my PI.
  3. I set a Static IP for my RPi since I don’t want a random DHCP address from my internet router and I can’t reserve an IP on my router. At the RPi Ubuntu terminal screen, open the nano text editor to the network settings file with this command:
    sudo nano /etc/network/interfaces

    I commented out the current DHCP settings:

    #iface eth0 inet dhcp

    and put in a static address with openDNS as the DNS:

    iface eth0 inet static
    address 192.168.1.38
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 208.67.222.222

    Then I exited nano with Ctrl X, press Y to save current modifications, enter to confirm file name. I usually reopen the file just to check it looks how I wanted (the up arrow retypes the previous command in the terminal window).

  4. Then I changed the RPi hostname (which is accessible from the windows folder address bar):
    sudo nano /etc/hostname

From here I shutdown the RPi (sudo shutdown -h now) and accessed it over the network using SSH (which I installed in step 2). I use MobaXtem for SSH which also brings up a file browser:

  1. I changed my locale:
    this command

    locale -a

    shows available locales installed, I used:

    sudo update-locale LANG=en_AU.utf8 LC_MESSAGES=POSIX
  2. Now I mounted my USB drive:
    -Use this command to show drive IDs:

    sudo blkid

    -Copy the UUID for the USB Drive (note that Ctrl C isn’t copy in the terminal)
    -Create a mount point for the USB drive:

    sudo mkdir /media/Data

    Before editing /etc/fstab directly, it is a good idea to make a backup. From a terminal:

    sudo cp /etc/fstab /etc/fstab.orig

    Open fstab

    sudo nano /etc/fstab

    and I added a line for my NTFS USB drive:

    UUID=NUMBERSNSTUFF /media/Data ntfs-3g uid=ubuntu,gid=ubuntu,umask=000 0 0
    Those settings didn't work for my next ftp project :/... these worked...
    UUID=NUMBERSNSTUFF  /media/Data ntfs-3g defaults,locale=en_AU.utf8 0 0
    

    I set options uid=ubuntu,gid=ubuntu,umask=000 so that samba could access the drive as well as deluge torrent client.

  3. Install Samba:
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install samba

    Duplicate original samba settings:

    sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old

    Add Samba user:

    useradd getdeep --shell /bin/false

    Add user password:

    smbpasswd -a getdeep

    change samba config file using nano text editor:

    sudo nano /etc/samba/smb.conf

    Added under authentication:

    security = user
    encrypt passwords = yes

    #commented out printer stuff,
    added to bottom:

    [Data]
    path = /media/Data
    available = yes
    valid users = getdeep
    read only = no
    browseable = no
    public = no
    writable = yes
  4. Install Deluge (from here)
    sudo add-apt-repository ppa:deluge-team/ppa
    sudo apt-get update
    sudo apt-get install deluged deluge-webui
    sudo nano

    Enter this in nano:

    start on (filesystem and networking) or runlevel [2345]
    stop on runlevel [016]
    
    env uid=ubuntu
    env gid=ubuntu
    env umask=022
    
    exec start-stop-daemon -S -c $uid:$gid -k $umask -x /usr/bin/deluged -- -d

    Ctrl + X to exit
    Y to save
    /etc/init/deluge.conf as file name

    same again for webUI:

    sudo nano

    enter this:

    start on started deluge
    stop on stopping deluge
    
    env uid=ubuntu
    env gid=ubuntu
    env umask=027
    
    exec start-stop-daemon -S -c $uid:$gid -k $umask -x /usr/bin/deluge-web

    Ctrl + X to exit
    Y to save
    /etc/init/deluge-web.conf as file name

    Start Deluge!

    sudo start deluge-web
  5. Access Deluge from web interface at http://localhost:8112 where localhost is RPI IP. Also Deluge daemon will be running on port 58846, so you can configure a remote computer on the LAN to connect with a thin client.
  6. SSL can be enabled to avoid the login details being man-in-the-middle attacked. For me this was a major pain in the ass. You need A. to enable SSL and B. to import your SSL Certificates…
    A. Edit /etc/init/deluge-web.conf to have ‘–ssl’ at the end, like this

    exec start-stop-daemon -S -c $uid:$gid -k $umask -x /usr/bin/deluge-web --ssl

    This will force SSL for the web ui.
    Possibly you will need to modify the users deluge conf files, for me there are some here: /home/ubuntu/.config/deluge/ specifically web.conf and web_plugin.conf
    I found that the preference settings in the web ui didnt do much.

  7. Now put your public and private keys in the right place. For me that is /home/ubuntu/.config/deluge/ssl/
    I renamed my certs to the existing certs, daemon.cert, deamon.pkey
  8. Holy crap it worked.

USoS (United States of Space) – Chappelle

everything is space.

. .within possibility is an idea, even a constant idea like maths. Maths + idea = physical reality. Idea = dimentionality. dimension change linearly, dimension called time. in spacetime is persistent virtual energy flux called particle, around particle is force relation, you stay near me particle thats how this thing works. You change that and there will be more focused energy here.

afterthought:
We are just trying to prove we are more particle than probability

 

Just saw this on Ram Dass’ FB: Albert Einstein & Rabindranath Tagore on the Nature of Reality

Syncing TrueCrypt Volumes (across a windows network)

I have been looking for a way to synchronize an encrypted Truecrypt  volume. This is a tricky problem, as a truecrypt volume is simply a large (possibly several GB) file, which appears as a disk drive when mounted with truecrypt. I have been looking into this technology lately as a method to have a safe location to store documents which which can’t be accessed by anyone else. Truecrypt is perfect for this, and as I have been listening on security now lately, it is still pretty much a very impressive solution for encryption on windows – and it’s free. I have heard bad things about dropbox being able to access your whole computer and similar things so truecrypt seems a perfect solution. So I’m very satisfied using the various simple to use options truecrypt has, the next problem is backup. I want to be able to backup my encrypted volume. The encrypted truecrypt volume is simply a large file sitting on my computer, each time I modify the contents of the volume, the encrypted volume changes. Herein lies the problem, I need to be able to backup only the part of the volume that has changed – otherwise for example if I change the name of a file in the truecrypt volume, the whole volume would need to be resynchronized with the backup location. This is called Block level synchronization, where only modified parts of a file are synchronized. Dropbox does Block level synchronization, so it is possible to use dropbox with a truecrypt volume – but that still has the problem of using dropbox… The best source of various solutions I found is here. The one I have got to work is Syncovery, there are others on GitHub which were free, but Syncovery seems the best option – even if it does cost ~$35.

This allows me to have a remote backup of a truecrypt volume – where the remote location doesn’t need access to the contents of the volume. With this solution only encrypted noise is sent out of my computer to the backup 🙂

To get this to work:

  1. Create Truecrypt volume (needs to be a volume not a partition so the sync software can access the encrypted data).
  2. Set truecrypt to change modification date when modifications are made. (Settings>Preferences>Windows>Uncheck Preserve modification…)
  3. Create Syncovery Profile (with block level mode).
    – Select Advanced Mode from the start screen
    – Create New profile with Standard Copying mode
    – Select Partial File Updating (in the Special tab sheet)
  4. Since my backup drive is portable, I attached it and synchronized it locally.
  5. After the first synchronization, it will create a database of the files, so the second time should be much faster. I tested this by putting the backup on a remote machine over wifi and making a small change to the contents of the source truecrypt volume. It ran through the whole 12GB volume in no time at all 😀