วิธีเปลี่ยน Raspberry Pi ให้เป็น Always-On BitTorrent Box

เหมาะอย่างยิ่งที่จะมีเครื่องเฉพาะสำหรับไคลเอนต์ BitTorrent ของคุณดังนั้นคุณสามารถเริ่มต้นได้ตลอด 24 ชั่วโมงทุกวัน แต่ต้องใช้พลังงานอย่างมากในการปล่อยให้อุปกรณ์ขับเคลื่อนเต็มรูปแบบและออนไลน์บ่อยๆ ป้อน Raspberry Pi

ที่เกี่ยวข้อง: คู่มือ How-To Geek ในการวัดการใช้พลังงานของคุณ

พีซีเดสก์ท็อปส่วนใหญ่ใช้พลังงานในปริมาณพอสมควรตัวอย่างเช่นเซิร์ฟเวอร์สำนักงานในบ้านของเราใช้พลังงานไฟฟ้าเกือบ 200 เหรียญต่อปี ในทางกลับกัน Raspberry Pi สร้างขึ้นจากโปรเซสเซอร์มือถือและจิบพลังงานเหมือนนกฮัมมิงเบิร์ด บอร์ด Raspberry Pi หลักใช้พลังงานน้อยกว่า 3 เหรียญต่อปีและแม้จะเพิ่มฮาร์ดไดรฟ์ภายนอกเพียงไม่กี่ตัวคุณก็ยังคงรักษาต้นทุนการดำเนินงานต่อปีให้น้อยกว่าเบอร์เกอร์และทอด

นอกจากนี้เมื่อพูดถึงการดาวน์โหลดทอร์เรนต์เครื่องที่เปิดตลอดเวลาคือราชา ด้วยทอร์เรนต์ยิ่งคุณตรวจสอบระบบคลาวด์และเพาะเมล็ดมากเท่าไหร่อัตราส่วนของคุณในตัวติดตามของคุณก็จะยิ่งดีขึ้นเท่านั้น (แม้ว่าคุณจะหลบหนีจากตัวติดตามสาธารณะ แต่เครื่องที่เปิดตลอดเวลาจะช่วยให้มั่นใจได้ว่าคุณจะอยู่ที่นั่นเมื่อไฟล์หายากเหล่านั้นปรากฏขึ้น) .

หากฟังดูดีให้อ่านต่อในขณะที่เราแสดงวิธีเปลี่ยน Pi ของคุณให้เป็นเครื่องดาวน์โหลดที่ควบคุมจากระยะไกลทั้งหมด

สิ่งที่คุณต้องการ

สำหรับบทช่วยสอนนี้เราถือว่าคุณมีหน่วย Raspberry Pi ที่ติดตั้ง Raspbian สามารถเข้าถึงอุปกรณ์ได้โดยตรงผ่านจอภาพและแป้นพิมพ์ที่เชื่อมต่อหรือจากระยะไกลผ่าน SSH และ VNC และคุณมีไดรฟ์ USB ภายนอก (หรือไดรฟ์) แนบมากับมัน หากคุณต้องการเร่งความเร็วในพื้นที่เหล่านี้เราขอแนะนำอย่างยิ่งให้อ่านคำแนะนำต่อไปนี้ตามลำดับที่เราระบุไว้ที่นี่:

  1. ทุกสิ่งที่คุณต้องการรู้เกี่ยวกับการเริ่มต้นใช้งาน Raspberry Pi
  2. วิธีกำหนดค่า Raspberry Pi ของคุณสำหรับ Remote Shell, Desktop และ File Transfer
  3. วิธีเปลี่ยน Raspberry Pi ให้เป็นอุปกรณ์จัดเก็บข้อมูลเครือข่ายพลังงานต่ำ

ทุกอย่างในบทช่วยสอนแรกเป็นสิ่งที่จำเป็น บทช่วยสอนที่สองเป็นทางเลือก (แต่การเข้าถึงระยะไกลมีประโยชน์อย่างไม่น่าเชื่อสำหรับโครงการนี้เนื่องจากกล่องดาวน์โหลดเป็นตัวเลือกที่สมบูรณ์แบบสำหรับการสร้างแบบไม่มีหัว) และส่วนที่สำคัญที่สุดของบทช่วยสอนที่สามคือการตั้งค่าฮาร์ดไดรฟ์และกำหนดค่า เพื่อติดตั้งอัตโนมัติเมื่อบูต (ตามที่อธิบายไว้ในคำแนะนำที่สาม)

ที่เกี่ยวข้อง: วิธีการไม่ระบุตัวตนและเข้ารหัสการรับส่งข้อมูล BitTorrent ของคุณ

นอกจากนี้หากคุณไม่คุ้นเคยกับรายละเอียดของการตั้งค่าไคลเอนต์ BitTorrent สำหรับการดาวน์โหลดแบบไม่ระบุตัวตนมากเกินไปคุณควรอ่านมัน คุณอย่างต้องเรียงลำดับของ anonymizing พร็อกซี่หรือระบบ VPN ในสถานที่บางอย่างเพื่อที่จะใช้ BitTorrent ได้อย่างปลอดภัย พร็อกซีที่กล่าวถึงในคู่มือนั้นมีราคาถูกและใช้งานง่าย แต่ VPN ที่ดีมักจะเร็วกว่าและหลากหลายกว่าดังนั้นโปรดอ่านคู่มือนี้หากคุณต้องการใช้ VPN แทน

เมื่อคุณตรวจสอบเนื้อหาทั้งหมดและกำหนดค่า Pi แล้วก็ถึงเวลาลงมือทำธุรกิจเพื่อเปลี่ยน Pi ของคุณให้กลายเป็นสัตว์ดาวน์โหลดที่เงียบและใช้พลังงานต่ำเป็นพิเศษ

ขั้นตอนที่หนึ่ง: ติดตั้ง Deluge บน Raspbian

มีไคลเอนต์ BitTorrent หลายตัวสำหรับ Linux ที่ควรค่าแก่การพิจารณา แต่เราขอแนะนำ Deluge มันเป็นเพียงความสมดุลของคุณสมบัติและรอยเท้าที่เหมาะสมเพื่อที่คุณจะไม่พบว่าตัวเองต้องการอีกหนึ่งเดือนนับจากนี้ที่คุณได้ติดตั้งสิ่งที่มีประสิทธิภาพมากขึ้น

คุณสามารถกำหนดค่า Deluge ได้หลายวิธี แต่การกำหนดค่าบางอย่างอาจไม่เหมาะกับกล่องดาวน์โหลด Pi แบบไร้หัวนี้ ในขณะที่คนส่วนใหญ่ใช้ไคลเอนต์ torrent บนเดสก์ท็อปเหมือนกับแอพอื่น ๆ แต่ก็ไม่ได้ผลดีสำหรับวัตถุประสงค์ของเราเพราะมันหมายความว่าทุกครั้งที่คุณต้องการโต้ตอบกับเพลงของคุณคุณจะต้องเข้าสู่กล่องผ่านทางไกล เดสก์ท็อปและยุ่งกับไคลเอนต์เดสก์ท็อป เสียเวลาและเสียทรัพยากรใน Pi

คุณสามารถเรียกใช้ Deluge WebUI ซึ่งช่วยให้คุณเข้าถึงไคลเอนต์ Deluge จากเบราว์เซอร์บนเครื่องอื่น นี่ยังไม่ใช่ตัวเลือกที่เราต้องการแม้ว่าจะเปิดโอกาสให้คุณใช้แอพสมาร์ทโฟนเพื่อดูและควบคุมน้ำท่วม (เพิ่มเติมในภายหลัง)

เราขอแนะนำให้กำหนดค่า Deluge บนเครื่องระยะไกลเพื่อยอมรับการเชื่อมต่อ ThinClient ในลักษณะนี้เราสามารถใช้ไคลเอนต์เดสก์ท็อป Deluge จริงบนคอมพิวเตอร์เครื่องอื่น (ไม่ว่าจะเป็นกล่อง Windows, Linux หรือ OS X) เพื่อควบคุมการติดตั้ง Raspberry Pi Deluge คุณจะได้รับประโยชน์ทั้งหมดของไคลเอ็นต์เดสก์ท็อปบนเดสก์ท็อปจริงของคุณในขณะที่การดำเนินการทั้งหมดเกิดขึ้นในกล่องระยะไกล

หากคุณไม่สามารถตัดสินใจระหว่างสองตัวเลือกนี้ได้คุณสามารถใช้ทั้งสองอย่างควบคู่กันได้แม้ว่าจะใช้เวลาในการตั้งค่านานกว่าเล็กน้อย เพียงทำตามคำแนะนำในทั้งสองส่วนด้านล่างเพื่อดำเนินการดังกล่าว

ทางเลือกที่หนึ่ง: ตั้งค่า Deluge สำหรับ ThinClient Access

ก่อนที่คุณจะดำเนินการใด ๆ โปรดใช้เวลาสักครู่เพื่ออัปเดตและอัปเกรดที่เก็บของคุณ เปิด Terminal และเรียกใช้คำสั่งสองคำสั่งต่อไปนี้ทีละคำสั่ง:

sudo apt-get updatesudo apt-get upgrade

เมื่อเสร็จแล้วก็ถึงเวลาเริ่มติดตั้งส่วนประกอบที่จำเป็นสำหรับการตั้งค่า ThinClient ป้อนคำสั่งต่อไปนี้:

sudo apt-get install delugedsudo apt-get install deluge-console

สิ่งนี้จะดาวน์โหลด Deluge daemon และแพ็คเกจการติดตั้งคอนโซลและเรียกใช้ เมื่อได้รับแจ้งให้ดำเนินการต่อให้พิมพ์ Y หลังจากติดตั้ง Deluge เสร็จแล้วคุณต้องเรียกใช้ Deluge daemon ป้อนคำสั่งต่อไปนี้:

delugedsudo pkill deluged

สิ่งนี้เริ่มต้น Deluge daemon (ซึ่งสร้างไฟล์คอนฟิกูเรชัน) จากนั้นปิด daemon เราจะแก้ไขไฟล์คอนฟิกนั้นแล้วเริ่มสำรองข้อมูล พิมพ์คำสั่งต่อไปนี้เพื่อทำการสำรองข้อมูลของไฟล์คอนฟิกูเรชันดั้งเดิมก่อนจากนั้นจึงเปิดเพื่อแก้ไข:

cp ~/.config/deluge/auth ~/.config/deluge/auth.oldnano ~/.config/deluge/auth

Once inside the nano text editor, you’ll need to add a line to the bottom of the configuration file with the following convention:

user:password:level

Where user is the username you want for Deluge, password is the password you want, and thelevel is 10 (the full-access/administrative level for the daemon). So for our purposes, we used pi:raspberry:10. When you’re done editing, hit Ctrl+X on your keyboard and save your changes when prompted. Then, start up the daemon and console again:

delugeddeluge-console

If starting the console gives you an error code instead of nice cleanly formatted console interface, type “exit” and then make sure you’ve started up the daemon.

Once inside the console, you’ll need to make a quick configuration change. Enter the following:

config -s allow_remote Trueconfig allow_remoteexit

The commands and corresponding output will look like the screenshot below.

This enables remote connections to your Deluge daemon and double checks that the config variable has been set. Now it’s time to kill the daemon and restart it one more time so that the config changes take effect:

sudo pkill delugeddeluged

At this point, your Deluge daemon is ready for remote access. Head to your normal PC (not the Raspberry Pi) and install the Deluge desktop program. You’ll find the installer for your operating system on the Deluge Downloads page. Once you’ve installed Deluge on your PC, run it for the first time; we need to make some quick changes.

Once launched, navigate to Preferences > Interface. Within the interface submenu, you’ll see a checkbox for “Classic Mode”. By default it is checked. Uncheck it.

Click OK and then restart the Deluge desktop client. This time, when Deluge starts, it will present you with the Connection Manager. Click the “Add” button and then input the IP address of the Raspberry Pi on your network, as well as the username and password you set during the earlier configuration. Leave the port at the default 58846. Click Add.

Back in the Connection Manager, you’ll see the entry for the Raspberry Pi; if all goes well, the indicator light will turn green like so:

Click Connect, and you’ll be kicked into the interface, connected to the remote machine:

It’s a fresh install, nary a .torrent in site, but our connection between the remote machine and the desktop client is a success!

Go ahead and configure the WebUI now (if you wish to do so), or skip down to the next step of this tutorial.

Option Two: Set Up Deluge for WebUI Access

Configuring the WebUI is significantly faster, and allows for using some mobile apps to access Deluge. But as we mentioned before, you’ll have access to fewer features than with the full ThinClient experience. For example, ThinClient can associate .torrent files with the Deluge ThinClient for automatic transfer to the Pi, but you can’t do this with the WebUI.

First, take a moment to update and upgrade your repositories. Open a Terminal and run the following two commands, one after the other:

sudo apt-get updatesudo apt-get upgrade

Then, to install the WebUI, run the following commands. Note: If you already installed the Deluge daemon in the ThinClient section of the tutorial, skip the first command here.

sudo apt-get install delugedsudo apt-get install python-makosudo apt-get install deluge-webdeluge-web

This sequence installs the Deluge daemon (if you didn’t already install it in the last section), Mako (a template gallery for Python that the WebUI needs), the WebUI itself, and then starts the WebUI program.

The default port for the WebUI is 8112. If you wish to change it, run the following commands:

sudo pkill deluge-webnano ~/.config/deluge/web.conf

This stops the WebUI and opens up the configuration file for it. Use nano to edit the line: “port”: 8112, and replace the 8112 with any port number above 1000 (as 1-1000 are reserved by the system).

Once you have the WebUI up and running, it’s time to connect to it using a web browser. You can use a browser on the Pi if you ever need to, but it’s not the most pleasant user experience and best left for emergencies. Open up a browser on your regular desktop machine and point it at the IP address of your Pi with the port you just chose (e.g. //192.168.1.13:8112 ).

You’ll be greeted with a password prompt (the default password is “deluge”) and be immediately encouraged to change it after you enter it for the first time. After that, you’ll be able to interact with Deluge via the lightweight interface.

It’s not quite the same as the ThinClient, but it’s robust enough for light use and has the added benefit of serving as the point of connection for lots of torrent-control mobile apps.

Step Two: Configure Your Proxy or VPN

You might be tempted to start downloading torrents now,but wait! Don’t do that yet. It’s absolutely reckless to use a BitTorrent Client without first shuttling your connection through a proxy server or VPN.

RELATED:How to Choose the Best VPN Service for Your Needs

If you didn’t read over How To Anonymize and Encrypt Your BitTorrent Traffic yet, now is the time to do so. Read over the first section (for a better understanding of why it is important to protect your BitTorrent connection), and then sign up for a proxy service or, better yet, a good VPN before continuing on.

If you’re using a VPN, it’s pretty simple: Just choose a VPN that offers a Linux client. Then, download and install the Linux client on your Pi, start it up, and connect to your desired server. (You may even want to set it to launch when the Raspberry Pi boots, so it’s always connected to the VPN.)

If you’re using a proxy, you can plug its information into Deluge under Preferences > Proxy. You need to fill out the Peer, Web Seed, Tracker, and DHT sections like so, placing your proxy username and password in the appropriate slots. Your proxy service’s Type, Host, and Port may differ, so be sure to check its documentation.

In order for the proxy settings to take effect, you need to restart the Deluge daemon. From the terminal enter the following commands:

sudo pkill delugeddeluged

After that, you should be all set.

The best way to test that you’re actively using the proxy or VPN is to download a torrent file designed expressly to report back its IP address. You can find many of these torrents online, including this one from BTGuard and this one from TorGuard. Load either or both torrents into Deluge and wait a moment.

After the torrents have had a chance to connect to their respective trackers, select the torrents in the Deluge client and check the “Tracker Status” entry as seen above. Both will report the IP address they detect from your client. If that IP address matches your public IP address, then the proxy or VPN is not configured properly and you should return to the previous section to check your configuration. If it is configured properly, you’ll see the proxy or VPN’s IP address and not your own.

Step Three: Configure Your Download Location

Next, you’ll need to configure Deluge to use your external hard drive. If you followed along with the hard drive mounting instructions in this previously mentioned guide, you’re ready with a hard drive set to auto-mount on boot.

From there, all you need to do is change the default locations in Deluge. Navigate to Deluge’s Preferences  and head to the Downloads tab. By default, Deluge directs everything to /home/pi. That little SD card is going to fill up real fast, however, so we need to change it.

First, we’re going to create some new folders in /media/USBHDD1/shares, which is the share folder we already set up in the Low-Power Network Storage tutorial. That way, we can easily access our downloaded torrents over the network and have a network accessible watch folder for auto-loading torrent files. Use the following commands to create the folder set (adjusting the pathnames accordingly for your location if you’re not using the same Pi setup from the previous tutorial like we are):

sudo mkdir /media/USBHDD1/shares/torrents/downloading sudo mkdir /media/USBHDD1/shares/torrents/completed sudo mkdir /media/USBHDD1/shares/torrents/watch sudo mkdir /media/USBHDD1/shares/torrents/torrent-backups

Then, turn right around and plug those four new directories into Deluge.

Click OK to set the directories. There’s no need to restart as you did with the proxy setup.

Step Four: Test Your Connection

Now it’s time to download a large enough torrent that we can really see if the system is running smoothly. For our test we grabbed the .torrent file for the current Linux Mint distribution–it weighs in at solid 1.7GB, perfect for monitoring the connection speeds.

Once you’ve confirmed that your connection is stable and the Linux torrent is humming along nicely, it’s time to move onto the next step: automating the client startup.

Step Five: Configure Deluge to Run on Startup

Before we leave the Deluge setup, there is one final detail to attend to. We need to set up the Deluge daemon and WebUI to run automatically when our Raspberry Pi boots up. To do so simply and without the fuss of editing more complicated init files and settings, we’ll simple annotate the rc.local file. Run the following command in a Terminal to do so.

sudo nano /etc/rc.local

With the rc.local file loaded, add the following lines to the end of the file. Note: you do not need to add the the second command ending in “deluge-web” if you are not using the WebGUI. This may also be a good place to add your VPN program, if you’re using one.

# Start Deluge on boot: sudo -u pi /usr/bin/python /usr/bin/deluged  sudo -u pi /usr/bin/python /usr/bin/deluge-web

Your rc.local file should look something like this when you’re done (possibly with the addition of that VPN):

Press Ctrl+X to exit and save your work.

At this point, we would recommend restarting your Raspberry Pi, so fire off a “sudo reboot” at the command line. Once the Pi has finished rebooting, head to your other PC and try to connect to the Deluge ThinClient and/or WebUI to make sure they both work.

There are two major errors you may encounter here. First, a failure to connect at all means that the initialization scripts didn’t work. Open up the terminal on your Pi and manually start the daemon and WebUI using the commands we learned earlier in the tutorial.  Check to see that it works now. If it does, go back up and fix your rc.local script.

Second, if you can open up the client, but it shows permission errors for your existing torrents (like the Linux torrent we used to test things earlier), that indicates that your external hard drive was not mounted, or mounted incorrectly. Review the sections on installing an external drive and setting it to auto-mount on boot in our Low-Power Network Storage tutorial.

Enhancing Your Torrenting Experience

Now that you have your torrent box configured and ready to rock, there are a few additional tools and modifications you can look into to really enhance your user experience. None of these tips and tricks are necessary, but they do make your Raspberry Pi turned Torrent Box easier to use.

Add Mobile Access: Consider downloading a mobile control app like Transdroid and Transdrone for Android. Unfortunately we don’t have any solid suggestions for iOS users, as Apple has taken a really aggressive stance towards torrent-related apps in the App Store (and has banned any apps that slipped through the submission process).

Deluge doesn’t currently have a mobile-optimized template for the WebUI, but it’s more than functional on tablets like the iPad and Kindle Fire.

Set Up a Shared Drop Folder: Although we mentioned it briefly earlier in the tutorial, ensure that the /torrents/watch/ folder you created is accessible on your network. It’s really convenient to be able to dump a pile of .torrent files into the folder and have Deluge load them up automatically.

Install Browser Plugins: There are several Deluge-centered plugins for Chrome and Firefox that improve the user experience, including:

  • Chrome:
    • DelugeSiphon: Enables .torrent adding from the WebUI
    • Deluge Remote: Simple view of current torrents and their progress
  • Firefox:
    • BitTorrent WebUI+: Enables .torrent adding from the WebUI
    • WebUI Quick Add Torrent: Greasemonkey Script that adds clickable icon on webpages for easy torrent adding

Activate Deluge Plugins: There are a host of great plugins already included in Deluge, and even more third-party plugins. Some of the included plugins you may want to take advantage of include:

  • Notification: You receive email alerts from Deluge on torrent completion and other events
  • Scheduler: Limit bandwidth based on time of day

You can find these in Preferences > Plugins. Check the ones you want and a new entry will appear in the preferences menu (e.g. Preferences > Notifications).

For more information about third party plugins and how to install them, check out the Plugins page in the Deluge Wiki.

After configuring, testing, and tweaking enhancements and plugins, you have a more than capable torrent box that costs mere pennies a day to operate. Find a quiet and out of the way spot to plug it in, load it up with torrents, and leave it to do the heavy lifting of downloading and seeding for you.