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!

What You’ll Need

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.