fbpx

Raspberry Pi Torrentbox With VPN, Samba, HDD & Deluge

In this article, you are going to learn how to create your very own headless Raspberry Pi Torrentbox.

If you really enjoy this article, consider checking out my TechWizTime YouTube Channel.

And for an awesome source of Raspberry Pi Accessories, check out my Raspberry Pi Amazon List.

Let’s get started!

Hardware List

Software List

Configure Raspbian

Log in with the username pi and the password raspberry
Next, we are going to update and upgrade our Raspberry Pi’s Raspbian System.

sudo apt update

sudo apt upgrade

NOTE: You can change your default password for extra security using the following command

sudo passwd

Install OpenVPN

sudo apt-get install openvpn -y

cd /etc/openvpn

sudo wget https://www.privateinternetaccess.com/openvpn/openvpn.zip

sudo unzip openvpn.zip

Configurate OpenVPN To Boot At Start

sudo nano login.conf

On the first line, type in your PIA Username.

On the second line, type in your PIA Password.

To save this file, press Ctrl X then Y then Enter

sudo chmod 400 login.conf

sudo cp *COUNTRYTHATYOUWANTTOCONNECTO*.ovpn *COUNTRYTHATYOUWANTTOCONNECTO*.conf

Now we are going to edit the newly copied CONF file

sudo nano *COUNTRYTHATYOUWANTTOCONNECTO*.conf

Scroll down to the “auth-user-pass” section, press space and add

/etc/openvpn/login.conf

Go down to “crl-verify” and add

/etc/openvpn/

Move down to “ca” and add

/etc/openvpn/

To save this file, press Ctrl X then Y then Enter

Test if the configuration works by typing

sudo openvpn *COUNTRYTHATYOUWANTTOCONNECTO*.conf

If it works, press Ctrl C to finish the connection.

sudo nano /etc/default/openvpn

Create a new line under the last “AUTOSTART” and type in

AUTOSTART=”COUNTRYTHATYOUWANTTOCONNECTTO”

To save this file, press Ctrl X then Y then Enter

Now we just need to reboot the Raspberry Pi

sudo shutdown -r 0

Once we have rebooted and logged back in we can check if the VPN connected.

curl http://ipinfo.io/ip

Compare the IP Address to check if you’re using OpenVPN

Set Up Your HDD

Connect your HDD by USB to the Raspberry Pi.

sudo umount /dev/sda1
sudo parted /dev/sda

You can press P to check the partitions at any time.

Next we need to create the filetable.

mktable msdos

Press Y to continue.

mkpart primary ext4 0% 100%

To check if the partition was created succesfully, input

print

If everything looks good, we can exit the tool

quit

Now we can create the EXT4 filesystem on the partition.

sudo mkfs.ext4 /dev/sda1

Press Y if it asks for confirmation.

Now we will create and mount the hard drive.

sudo mkdir /mnt/torrents
sudo mount /dev/sda1 /mnt/torrents

To check if it worked, use the following command and you should see the mount point at the bottom.

df -h

We want this hard drive to be mounted everytime we reboot. So we need to do the following.

sudo nano /etc/fstab

Create a new line under the last /dev and write

/dev/sda1 /mnt/torrents ext4 defaults 0 0

To save this file, press Ctrl X then Y then Enter

Another reboot.

sudo reboot

After rebooting, we can check to see if the partition was automatically mounted.

df -h

Install Deluge

To install deluged and access it from a web browser, we need to install the following.

sudo apt install deluged -y
sudo apt install deluge-web -y

Now we can create the folder structure for our Torrentbox.

cd /mnt/torrents
sudo mkdir downloading
sudo mkdir completed
sudo mkdir watch
sudo mkdir backups
sudo chown -R pi:pi /mnt/torrents/

Now let’s check that we have all the folders created

ls -la

We need to check what our IP Address is so make sure you write it down.

ifconfig

Start Deluge by typing

sudo service deluged start

And let’s start the web-client too

deluge-web

Configure Deluge

Go to your PC and open up a web browser.

Go to the following address “YOURIPADDRESS:8112”

The login password is “deluge”, after typing it, you should receive a message telling you that you should change it, do it now if you wish.

Look for your Raspberry Pi on the small prompt that will appear (It should be the only one) and click on “Start Daemon” and then hit “Connect”

Go to “Preferences”.

Click on the “Downloads” tab.

In the “Download To” bar, type in “/mnt/torrents/downloading/”

Tick the “Move Completed To” and type in “/mnt/torrents/completed/”

Tick the “Autoadd .torrent files from” box and type in “/mnt/torrents/watch”

Tick the “Copy of .torrent files to” box and type “/mnt/torrents/backups”

Click “Apply”

Click “Ok”

Configure Raspbian

Type “sudo raspi-config” and press “Enter”

Scroll down to “Localization”

Change Your Keyboard Layout: Go down to “Change Keyboard Layout”

Keep it on the “Default English 105 Key”

Go down to “Other”

Choose the language of your keyboard from the list.

Keep the remaining settings on Default.

Change The Timezone: Go down to “Change Timezone”

Choose your continent or region.

Choose your country.

Remove Overscan: Go down to “Advanced Options”

Scroll down to “Overscan”

Choose “No”

Reduce The GPU Memory: Go down to “Advanced Options”

Choose “Memory split”

Change “64” to “16”

Hit “Ok”

Go down to “Finish”

Select “Yes”

Autostart Deluge

sudo nano /etc/rc.local

Create a new line under the last one and type in

# DISPLAY IP ON REBOOT
_IP=$(hostname -I) || true
if [ “$_IP” ]; then
printf “\n*************************************************\n”
printf “Connect to Deluge via http://%s:8112 (Without the space)\n” “$_IP”
printf “*************************************************\n\n”
fi
# DELUGE START ON BOOT

sudo -u pi /usr/bin/python /usr/bin/deluge-web &

exit 0

To save this file, press Ctrl X then Y then Enter

Another quick reboot to seal the deal

sudo reboot

Set Up SAMBA Shares

sudo nano /etc/samba/smb.conf

Scroll down to “win support”

Delete the “#” and change “no” to “yes”

Go to the very bottom and type in

[TORRENTS]

comment = Torrents
path = /mnt/torrents
create mask = 0755
directory mask = 0755
read only = no
browseable = yes
public = yes
force user = pi
only guest = no”

To save this file, press Ctrl X then Y then Enter

Now we need to reboot the Raspberry Pi once again.

sudo reboot

NOTE: If it doesn’t works, try installing samba and doing another reboot.

sudo apt install samba samba-common-bin -y
sudo reboot

To access from a Windows pc, all you have to do is type \\YOURHOSTNAME or \\YOURIPADDRESS

When it asks for a login information, the username will be “pi” and the password is teh same one you use to log into your Raspberry Pi.

Raspberry Pi Torrentbox Completed

Congratulations, you’ve just created your very own Raspberry Pi Torrentbox, added a VPN to it, configured SAMBA Shares and even changed the host name and that’s it for this tutorial.

Could you do everything by yourself? Did you had any problems during the tutorial? Have any suggestion? Then leave a comment below.

93 thoughts on “Raspberry Pi Torrentbox With VPN, Samba, HDD & Deluge”

  1. got an issue, seems as though the deluge-web service isn’t starting. I get the error no such file or directory. what do i do? adding the command to the rc.local doesn’t seem to work. Worked fine until i changed the hostname.

    changed the name back and it didn’t do anything.

        1. last line should not have ( ” )only guest = no”
          Should be only guest = no

          You should be good to go.

          Awesome tutorial btw.

  2. Hey Mate,

    Good tutorial just found aTYPO that caught up myself for a while
    sudo apt install deluged -y
    sudo service deluge-web -y “should be apt install deluge-web -y”

  3. Hey, I followed the steps as listed until I got to “cd /ect/openvpn” and it get the reply no such file or directory. Any ideas on how to solve this?

  4. What speeds is the Raspberry Pi able to maintain (ie 10mbit, 30mbit, 100mbit, 300mbit) and where would you guess the bottlenecks might be? (ie cpu, ram use, data bus, etc.) I’ve heard someone suggest about 10megabytes/second may be about as fast as an R-pi works due to some bus limit, whether this would be the case or be even slower for torrent or have a different bottleneck i’d be very curious.

    Knowledge of bottleneck might suggest alternative single board computers many of which suggest higher performance in some ways.

    1. I find optimally you can get 20mbps. A lot depends on the quality of the VPN, the swarm, the Raspberry Pi edition, etc. A VPN imposes a fair amount of overhead and stress on the resources of the Pi, as the stream has to be encrypted using CPU. However, for light to medium use this project is a great idea.

  5. Hello Thank you for the Tutorial.

    But im facing a problem with the deluge-web to autostart, it just dont auto start.
    I have typed this is in the sudo nano /etc/rc.local

    # DISPLAY IP ON REBOOT
    _IP=$(hostname -I) || true
    if [ “$_IP” ]; then
    printf “\n*************************************************\n”
    printf “Connect to Deluge via http://%s:8112 (Without the space)\n” “$_IP”
    printf “*************************************************\n\n”
    fi
    # DELUGE START ON BOOT

    sudo -u pi /usr/bin/python /usr/bin/deluge-web &

    exit 0

    Now im also facing a problem when i start the web-deluge manually the webserver never start.

  6. Thanks for the video! This has my noggin spinning…can I get NetFlix running in RetroPie? If I win the Pi Kit, I’ll make it happen! Stay tuned!

  7. Hi Jonathan,
    Thanks very much for all your videos and information. I currently have a RaspPie and Pi-Hole running successfully and would like to learn how to setup a SABnzbd/Sonarr/Radarr RaspPi3 box next.
    All the best,
    JStar73.
    Canberra, ACT.

  8. I love coding projects and I was planning to upgrade myself from arduino uno to raspberry pi 3 but I was nt having any money left with me to do. I was planning to make a hacking machine by running Linux on it and also I will try my dream project JARVIS on it. Only because of Jarvis I am going for raspberry pi

  9. Thanks for the tutorial i managed to install all on my pi together with other like sonar and couchpotato maybe on another video.

  10. Just did this on a Pi2 B+ and it’s working like a champ. Excellent tutorial!

    And if I win, I’ll probably build another RetroPie setup for my wife’s son so he can enjoy the awesomeness of the games I grew up on too.

  11. Great tutorial! I have a Pi 2 I would prob’ly make into a torrent box if I ever get a Pi 3 so I could continue playing with Python.

  12. To be honest, I don’t know yet what I would do with a Rasberry pi if I won one. It’s all quite new to me and it seems the possibilities are endless. It all looks very exciting though.

  13. Time to make a useful home media server and IoT automation with RGB (just ordered some LED strips and planning to use the Pi as the primary controller) 😀

  14. Excellent tutorial. Everything worked perfectly and network share connected with a Mac Mini without any issues. The only thing missing for the second version is a kill switch using UFW or similar for the times when the VPN goes down, so your IP is not exposed. Great job!

  15. Hello!

    First of all, thanks for this amazing tutorial.

    I have one doubt. Everytime I boot the RPi and I open the deluge web interface, I’m prompted with the connection manager window.

    If I don’t start deamon, the service is not running. So, even if the devices reboots, the service will not start without enabling it manually.

    Please check the image:

    https://imgur.com/a/7yyZv

    Any tip?

    Thanks

  16. I keep having to re do this every time the power goes out due the sd card corrupting is there a image file with all of this setup? Maybe such that the only variables are the PIA username and password?

    1. You should take a backup image of your SD card once you get it running. You can use the same imaging software you used to setup Raspbian. On Windows, good recommendations are Win32DiskImager or Etcher.io

  17. Great article for going start to finish.

    One other recommendation I would make is adding another user to [/home/pi/.config/deluge/auth]. This will allow you to connect in using a ThinClient (which may work better than the web client).

    To do this:
    1. Backup the current auth file: cp /home/pi/.config/deluge/auth /home/pi/.config/deluge/auth.old
    2. Edit the auth file: nano /home/pi/.config/deluge/auth
    3. Add a line in the bottom in the form of “user:password:level” where level is the permissions allowed. Setting to 10 allows full admin control. Example: pi:raspberry:10
    4. To save this file, press Ctrl X then Y then Enter
    5. Enable remote connections on deluge using: deluge-console config -s allow_remote True
    6. Validate remote connections are allowed: deluge_console config allow_remote

  18. Hello! I apologise for asking questions on an old article, but I am attempting to set one of these up at my university and I’m guessing there is an issue with the university firewall. I managed to get it working at my home, but now when I try to use [sudo openvpn –config ./”US Atlanta.ovpn” and sign in with my account there is a lag time and I am presented with a TLS Error stating that the TLS handshake failed. I apologise again for asking out of a place of ignorance, but is there something I can do to fix this issue?

    1. I would suggest looking on your vpn site for some help with getting past firewalls; I know PIA has a lot of options and settings that can be changed to help get around that kind of thing. I have changed mine a few times from tcp to udp and changed ports as well because some firewalls have them blocked on purpose. Changing those settings within a pi may take a little more effort, but there should be other options in the config file that you can tell it to use.
      Good luck

  19. Great video and tutorial! I am in the process of creating this but I am using qbittorent instead because it has the built in torrent search engine. I will post later tonight when I am done if it all works out; that way you can search, download, and manage your torrents all from one web interface.

  20. for autostart you do insert this line

    sudo -u pi /usr/bin/python /usr/bin/deluged

    sudo -u pi /usr/bin/python /usr/bin/deluge-web

  21. Great video and tutorial; although I am getting the following warning message when I am starting the deluge-deamon:

    /usr/lib/python2.7/dist-packages/deluge/_libtorrent.py:59: RuntimeWarning: to-Python converter for boost::shared_ptr already registered; second conversion method ignored.
    import libtorrent as lt.

    libtorrent version 1.1.1
    deluge version 1.3.15

  22. Great guide! Having a bit of trouble however…
    For some reason Deluge won’t download anything though. Connection is fine, settings are fine, permissions are fine.
    I’m guessing the culprit here is PIA though, since connecting to the VPN also requires to forward a port for traffic.
    Any ideas on how to open a port on PIA’s end to allow traffic to the Pi through Deluge?

  23. I liked your YouTube vid and tried that, but loads of issues with OPENVPN.
    So I came here to try again and again but no luck.
    It seems Pi 4 and Buster are not playing nicely.
    I cant even get a password change to survive a reboot 🙁

    If you wanted to help a fellow ranga out and do an updated for Pi 4 version that would be appreciated a hell of a lot.

    thanks

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.