Article

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.

Dereck Frost

I write tech articles and tutorials based around a number of topics.

View Comments

  • 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.

  • 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"

  • 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?

  • 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.

    • 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.

  • 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.

Recent Posts

Top 5 Best FREE Video Players for Windows (2024)

To play the videos stored on your computer, you’ll need a reliable media player. If…

1 day ago

The Best Google Docs Features 2024

🔔 SUBSCRIBE for more Tech Tips: https://www.youtube.com/tasiacustode?Sub_Confirmation=1 Support me here: https://ko-fi.com/tasiacustode Become a Patron: https://www.patreon.com/TasiaCustode…

2 days ago

15 New Gadgets 2024 | You Will Want To Buy

15 New Gadgets 2024 | You Will Want To Buy 🔗 LINKS Artemis - https://artemis.wonderfitter.com/…

3 days ago

NEW Razer Viper V3 Pro Review! 🐍

Razer just released the new Razer Viper V3 Pro mouse, another addition into their Viper…

4 days ago

Free Software That Are Actually Good! (NOT SPONSORED!) 2024

In this edition of our free software series, I have 4 programs to show you,…

5 days ago

11 New Gadgets And Inventions 2024 | You Can Buy Now

11 New Gadgets And Inventions 2024 | You Can Buy Now 🔗 LINKS Apolosign PackGo…

6 days ago