Contribute to the global «Linux Distribution Network» by creating a dedicated secure torrent download megalith that consumes as little as 10 watts. It is possible and it will of course be based on the Raspberry Pi.
Loading and sowing (you do sowing, right? Good people baited at least in a ratio of 2.0) is a tough task for any regular computer, and that means you’re using far more power than you need by leaving it on overnight. What if you could offload that task to a low-powered Raspberry Pi, small enough to fit under a floorboard and barely breaking 10W of power to do it all. That’s exactly what I’ll show you how to do today.
Here is the plan:
- Install Raspberry Pi with a USB drive and transfer the system drive to USB to extend the life of our SD card.
- Share it online.
- Configure your VPN so that all traffic is routed through the VPN, securely, and everything stops if that connection fails. We don’t want the provider to know which Linux distribution we prefer.
- Install the remotely controlled Transmission torrent client.
Sounds complicated, doesn’t it? I assure you, no more than a few hundred terminal commands. A lot of this is the same as our Raspberry Pi NAS. tutorial, so if you’re not that interested in torrenting and VPN, you can try this instead.
Flash drive
Start with a fresh install of Raspian, plug in an ethernet interface, and plug in a USB stick (via a powered USB hub, or more likely you’ll run into errors later like me) — it doesn’t need to be formatted yet. Log in remotely using the default pi/raspberry username/password combination and then run the command:
sudo raspi-config
Change the amount of memory allocated to graphics to 16 megabytes — we’ll be using this completely headless, so you won’t need graphics memory. Come out and let’s set up some partitions on USB. We’re going to set up at least two — one for system use to save the life of our SD card, and the other to save downloads. First find out which drive is your USB.
tail /var/log/messages
In my case it was easy to identify as «sda». With that in mind, tweak the following command to run utility fdisk on the respective device.
sudo fdisk /dev/sda
Click p to view a list of current partitions. To remove any existing press d . Create a new primary partition with n then p . When it asks you for a size, enter + 8G . Now go ahead and create another partition for your torrent data (again, the main one) or more partitions if you like. W will write the new partition map to disk when you’re done.
Once the new table is written, use the following commands to format the disks as linux ext4 . Use additional commands if you have partitioned your drive into more than two partitions.
sudo mkfs.ext4 /dev/sda1 sudo mkfs.ext4 /dev/sda2 sudo mkdir /mnt/systemdrive sudo mkdir /mnt/torrents sudo mount /dev/sda1 /mnt/systemdrive sudo mount /dev/sda2 /mnt/torrents df -h
The last command will confirm that you have mounted the partitions correctly. Next, we want to copy the SD card data to disk — this will extend its lifespan by avoiding constant cache reads/writes etc. Install rsync, to do this:
sudo apt-get install rsync sudo rsync -axv / /mnt/systemdrive
This initiates a long series of file copying, so shake your fingers a little.
sudo cp /boot/cmdline.txt /boot/cmdline.orig sudo nano /boot/cmdline.txt
Adjust it like this:
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/sda1 rootfstype=ext4 elevator=deadline rootwait rootdelay=5
Then change fstab, to mount them at startup.
sudo nano /etc/fstab
Add the following lines:
/dev/sda1 / ext4 defaults,noatime 0 1 /dev/sda2 /mnt/torrents ext4 defaults 0 2
Comment out the following line, which refers to the SD card:
#/dev/mmcblk0p2 / ext4 defaults,noatime 0 1
Reboot the pi with
sudo reboot
Sorting! Your Pi will now mount both the root data partition and your torrents partition.
Share The Drive: Samba
First make sure we’re up to date, uninstall the Wolfram Mathematica packages that always gave me problems doing absolutely anything with the Pi (math-kernel related stuff) and then install the necessary packages
sudo apt-get update sudo apt-get dist-upgrade sudo apt-get remove wolfram-engine sudo apt-get install samba samba-common-bin sudo nano /etc/samba/smb.conf
Click CTRL-W and type «security» to find the next line and comment it out.
security = user
Add the following to define our shared torrent folder:
[torrents] comment = torrents path = /mnt/torrents valid users = @users force group = users create mask = 0775 force create mode = 0775 security mask = 0775 force security mode = 0775 directory mask = 2775 force directory mode = 2775 directory security mask = 2775 force directory security mode = 2775 browseable = yes writeable = yes guest ok = no read only = no
Restart the Samba service:
sudo service samba restart
Next, we need to add a user to the system. Replace «jamie» with the username you want to log in with to access the shared folder. The following commands will then ask you to create your passwords, the first at the system level and the second for Samba. Change the last commands if you name your data drive something else (and here’s an example on file ownership in linux).
sudo useradd jamie -m -G users sudo passwd jamie sudo smbpasswd -a jamie sudo chown pi:users /mnt/torrents chmod g+w /mnt/torrents
Test — You should be able to connect from another computer on your network and read/write files to the new share. Check that they also appear on the Pi with ls from a folder /mnt/torrents .
VPN setup
Install required packages