使用樹莓派搭建下載機

我自己已經用樹莓派幾年了,從 3B+ 版本到 4B 版本,這樣一個低功耗的 Linux 發行版非常適用於做下載機,來滿足 PT、BT 等一些長時間掛機下載/做種的需求。它還可以搭配 SMB 分享、FTP 內網穿透實現個人 NAS 的一些功能。接下來我將介紹自己使用 Transmission 工具搭建的樹莓派下載機。
Transmission 安裝
Transmission 是一款流行的 BT 下載軟體,比其他客戶端使用更少的資源,守護程序非常適合伺服器,並且可以通過桌面 GUI、Web 界面和終端程序進行遠程控制,支持本地對等發現、完全加密、DHT、µTP、PEX 和 Magnet Link 等。
首先,通過 apt
安裝軟體包,這裡注意安裝的是 transmisson-daemon
:
sudo apt-get update
sudo apt-get install transmisson-daemon
然後在 /etc/transmission-daemon/
目錄下修改配置文件 settings.json
。修改設置前需要先關閉 transmission
服務:
sudo systemctl stop transmission-daemon.service
cd /etc/transmission-daemon/
sudo nano settings.json
settings.json
文件內容如下,#
後為我補充的需要修改欄位的注釋:
{
"alt-speed-down": 50,
"alt-speed-enabled": false,
"alt-speed-time-begin": 540,
"alt-speed-time-day": 127,
"alt-speed-time-enabled": false,
"alt-speed-time-end": 1020,
"alt-speed-up": 50,
"bind-address-ipv4": "0.0.0.0",
"bind-address-ipv6": "::",
"blocklist-enabled": false,
"blocklist-url": "http://www.example.com/blocklist",
"cache-size-mb": 4,
"dht-enabled": true,
"download-dir": "/home/pi/complete", # 下載目錄
"download-limit": 100,
"download-limit-enabled": 0,
"download-queue-enabled": true,
"download-queue-size": 30,
"encryption": 1,
"idle-seeding-limit": 30,
"idle-seeding-limit-enabled": false,
"incomplete-dir": "/home/pi/incomplete", # 下載未完成文件目錄
"incomplete-dir-enabled": true,
"lpd-enabled": false,
"max-peers-global": 200,
"message-level": 1,
"peer-congestion-algorithm": "",
"peer-id-ttl-hours": 6,
"peer-limit-global": 1000,
"peer-limit-per-torrent": 50,
"peer-port": 51413,
"peer-port-random-high": 65535,
"peer-port-random-low": 49152,
"peer-port-random-on-start": false,
"peer-socket-tos": "default",
"pex-enabled": true,
"port-forwarding-enabled": false,
"preallocation": 1,
"prefetch-enabled": true,
"queue-stalled-enabled": true,
"queue-stalled-minutes": 30,
"ratio-limit": 2,
"ratio-limit-enabled": false,
"rename-partial-files": true,
"rpc-authentication-required": true,
"rpc-bind-address": "0.0.0.0",
"rpc-enabled": true,
"rpc-host-whitelist": "",
"rpc-host-whitelist-enabled": true,
"rpc-password": "{525a44ba546f85ef59189a202b8d45357d17589686ReudqW", # 將雙引號內修改為你要設定的密碼,輸入密碼明文,重新啟動程序後會自動加密,再打開看到的就是這樣的密文了。
"rpc-port": 9091, # 默認 Web 訪問埠
"rpc-url": "/transmission/",
"rpc-username": "raspberrypi", # 將雙引號內修改為你要設定的用戶名
"rpc-whitelist": "*.*.*.*",
"rpc-whitelist-enabled": true,
"scrape-paused-torrents-enabled": true,
"script-torrent-done-enabled": false,
"script-torrent-done-filename": "",
"seed-queue-enabled": false,
"seed-queue-size": 10,
"speed-limit-down": 2048,
"speed-limit-down-enabled": false,
"speed-limit-up": 5,
"speed-limit-up-enabled": true,
"start-added-torrents": true,
"trash-original-torrent-files": false,
"umask": 18,
"upload-limit": 100,
"upload-limit-enabled": 0,
"upload-slots-per-torrent": 14,
"utp-enabled": true # 允許 Web 登錄
}
settings.json
修改完成後,保存配置文件,重啟 transmission
服務:
sudo systemctl start transmission-daemon.service
這樣在瀏覽器中登錄樹莓派 ip:9091
就可以訪問 Transmission Web 管理界面了。
如果下載中遇到寫入許可權問題,需要將目錄設置為許可權開放:
sudo chmod -R a+rw /home/pi/complete
在樹莓派上掛載移動硬碟
樹莓派的存儲設備為 SD 卡,存儲容量不會很大,不適合做 BT 的存儲器,最好還是外接移動硬碟。
這裡要注意的是由於樹莓派供電的問題。樹莓派 3B 供電不能直接外接移動硬碟,需要一個可接電源的 USB HUB 對移動硬碟單獨供電。樹莓派 4B 可以直接外接固態硬碟。
可以先在要掛載的目錄下新建一個文件夾,然後將移動硬碟掛載即可。為了能夠在樹莓派重啟的時候自動完成掛載操作,可以將掛載設置為系統服務。
下面是我設置的移動硬碟掛載服務,請參考 home-pi-M_disk.mount
:
[Unit]
Description=Auto mount USB disk
DefaultDependencies=no
ConditionPathExists=/home/pi/M_disk
Before=sysinit.target
[Mount]
What=/dev/sda1
Where=/home/pi/M_disk
Type=ntfs
[Install]
WantedBy=multi-user.target
上述掛載服務會在樹莓派啟動後自動將移動硬碟 /dev/sda1
(設備名稱可以將移動硬碟插入樹莓派後通過 sudo fdisk -l
查看),掛載到 /home/pi/M_disk
(此目錄為新建的掛載目錄)目錄下。
結語
這樣就完成了樹莓派下載機的搭建,搭配之前介紹的 SMB 分享、 FTP 內網穿透,還是能夠滿足個人 NAS 的一些簡單需求。 Enjoy!
本文轉載來自 Linux 中國: https://github.com/Linux-CN/archive
nordvpn promotion 350fairfax
Hey there! I know this is kinda off topic but I was wondering if you knew where I could find a captcha
plugin for my comment form? I’m using the same blog platform as yours and I’m having problems finding one?
Thanks a lot!
Howdy, i read your blog occasionally and i own a similar one and
i was just wondering if you get a lot of spam feedback?
If so how do you prevent it, any plugin or anything you can recommend?
I get so much lately it’s driving me crazy so any assistance is very
much appreciated.
Visit my site :: nordvpn coupons inspiresensation
I’m now not certain where you’re getting your
information, but great topic. I needs to spend some time finding out much more or working
out more. Thanks for excellent info I was in search of this info for my mission.
Feel free to visit my homepage: nordvpn coupons inspiresensation (tinyurl.com)
I think this is among the so much vital information for me.
And i’m glad reading your article. However want to remark on few normal issues, The website taste is
ideal, the articles is in reality excellent : D.
Just right process, cheers
Here is my web site – nordvpn coupons inspiresensation
Wow that was unusual. I just wrote an extremely long
comment but after I clicked submit my comment didn’t appear.
Grrrr… well I’m not writing all that over again.
Anyhow, just wanted to say fantastic blog!
my page nordvpn coupons inspiresensation