[TUTORIAL] Installing Rtorrent on AsusWrt Merlin routers through Entware, network storage option.
Rtorrent is alternative to Transmission as a torrent client running on routers. It is considered to be “lighter” in terms of CPU usage and RAM. The following tutorial will explain how to install it on Asus routers running Merlin’s firmware. It has been tested on my RT-N66U with 374.41 version of Merlin’s FW.
Note: Torrent applications produce extensive write activity, so it is not recommended to use them on a router without HDD attached or without network storage, as extensive write activity may damage your MicroSD card or USB stick. This tutorial is focused on more difficult option to use network storage for torrent client files and downloaded files, but it could be easily applied for locally attached HDD drive. In that case we don’t need MicroSD card or USB stick and should install Entware and Rtorrent on the HDD and use it as torrent and downloaded files storage.
*** ADDITION, thanks to ryzhov_al ***
Please note that the best solution is to use USB HDD attached. In that case you should focus on steps 3 and 5 below. Torrent clients use memory mapping which is effective only on local drives. The "network solution" is feasible only if you have no USB HDD attached to the router or your network storage itself is unable to run the torrent client.
*** ADDITION ***
Prerequisites
Merlin’s FW with jffs enabled
MicroSD card or USB stick, plugged in the router, formatted as ext2 file system and mounted
Entware installed on the MicroSD card or USB stick
Network storage (PC, NAS, etc.)
Step 1. Preparing network storage.
Create samba share to be used by Rtorrent on your network storage. We can use any existing share, but it is better to create a separate one. Create dedicated user on network storage to be used by Rtorrent and give him a password. These username and password will be used below to mount the network share. We can use any existing user, but because of security reasons it is recommended to create dedicated one. This user should have full access to the share above.
Step 2. Mount the network share.
Ssh to the router as admin
ssh admin@<router IP>
Change dir to the desired folder on the MicroSD card. We assume that it is labeled and mounted by name under /mnt. In this tutorial it is named “Data”. We will create the mount point named “Torrent_Data” there.
cd /mnt/Data
Create a mount point for the network share
mkdir Torrent_Data
Mount the network share using share name, username and password created in Step 1.
mount \\\\<IP address of the network server>\\<share name> /mnt/Data/Torrent_Data -t cifs -o "username=<username>,password=<password>"
Step 3. Installation of Rtorrent.
We are using the easy installation script included in Entware. It will do everything for you. Just answer the questions. You may just press <enter> to accept default proposals as later we will change some settings to allow using of remote share. The script installs rtorrent, rutorrent (front end of rtorrent) and lighttpd. Here you can watch a video of similar installation
opkg install rtorrent-easy-install
Step 4. Configure Rtorrent to use network share
There are 3 directories which are essential for Rtorrent: download dir, watch dir and session dir. The installation script prompts only for download dir. Other two directories are created in /opt/etc/rtorrent where the rtorrent.conf file is created also. Now we should change their location from MicroSD card/USB stick to network share.
cd /mnt/Data/Torrent_Data
mkdir watchdir
mkdir session
Stop rtorrent and lighttpd
/opt/etc/init.d/ S85rtorrent stop
/opt/etc/init.d/ S80lighttpd stop
Edit rtorrent.conf file using vi or nano editors
nano /opt/etc/rtorrent/rtorrent.conf
Edit the relevant lines as follows and save the rtorrent.conf:
session = /mnt/Data/Torrent_Data/session
schedule = watch_directory,5,5,load_start=/mnt/Data/Torrent_Data/watchdir/*.torrent
directory = /mnt/Data/Torrent_Data
Now the rtorrent will download files in network share mount under /mnt/Data/Torrent_Data and will use as session dir and watch dir Torrent_Data/session and Torrent_Data/watchdir
Start the lighttpd and rtorrent
/opt/etc/init.d/ S80lighttpd start
/opt/etc/init.d/ S85rtorrent start
Arrange the network share to be mount after reboot by adding the following lines in the user script named “services-start”, located in /jffs/scripts, BEFORE the line “/opt/etc/init.d/rc.unslung start”
mount \\\\<IP address of the network server>\\<share name> /mnt/Data/Torrent_Data -t cifs -o "username=<username>,password=<password>"
sleep 5
Note 1: If a problem occurs to mount the network share during boot process, the rtorrent will never start!
Note 2: Any changes in rtorrent.conf file should be done only while the rtorrent is stopped. You may start and stop it using the scripts in /opt/etc/init.d as described above.
Step 5. Configure firewall to open ports for rtorrent
Two ports need to be open for better performance of rtorrent - the incoming connections port and the DHT port. The rtorrent may work without opening of these ports but it will work slower and using magnet links will be not possible. In this example we use TCP port 51200 as incoming port and UDP port 51201 as DHT port. You should replace the example ports with the ports listed in rtorrent.conf file - lines "port-range" for incoming port and "dht_port" for DHT port.
Include the following lines in firewall-start user script located in /jffs/scripts:
iptables -I INPUT -p tcp --destination-port 51200 -j ACCEPT
iptables -I INPUT -p udp --destination-port 51201 -j ACCEPT
Note: If the firewall-start user script does not exist, create it.
Caught a relevant headline, had to share:
2 all who has this problem: just replace "rc.func" in /opt/etc/init.d with this one: https://raw.githubusercontent.com/monosoul/rc.func/master/rc.func . Problem is caused by entware's rc.func not able to differenciate firmware's lighttpd from entware's lighttpd.
No, you still need a USB key/drive. I am using a USB enclosure for a SSD drive on the USB 3.0 port, but I also went ahead and:
1) Change to DISABLE the - Reducing USB 3.0 interference - option in professional wireless settings
2) Turn DOWN the signal from Performance to Good on both 2.4 and 5 wireless signals
since I saw this had an impact on USB drive R/W performance and no problems so far, but I just wanted to put in my last 2 cents on rTorrent. Basically, I am giving up on rTorrent, because it is a mess and half the options do not work properly. I could not get:
1) Move completed files once downloaded - to work correctly and kept leaving meta and hash files behind
2) Hack check kept getting errors and I would have to manually recheck which would throw the router into a fit
a) safe_sync does not work and would crash rtorrent on start, so that suggestion does not work
3) I could not turn off pre-allocation of files which does not help when I want to "scan" and see what files actually completed
4) Files kept going into PAUSING mode when they were completed instead of STOP and stop-close options never seemed to work
and the list goes on...
Basically "garbage" and I switched to transmission. HUGE difference and everything working "right out of the box" and I love that you can have files with the .part extension, automatically move completed files, turn off pre-allocation and the list goes on. So I am sticking with transmission now...
Good luck to you guys on rTorrent...
Basically "garbage" and I switched to transmission. HUGE difference and everything working "right out of the box"
htdigest -c /opt/etc/lighttpd/.auth 'YOUR_REALM_NAME' root
# Server Authentication
server.modules += ( "mod_auth" )
auth.debug = 0
auth.backend = "htdigest"
auth.backend.htdigest.userfile = "/opt/etc/lighttpd/.auth"
auth.require = ( "/" => (
"method" => "digest",
"realm" => "YOUR_REALM_NAME",
"require" => "valid-user"
))
Rutorrent has a lot of problems. It took me a while to set it up.The problem is the "rutorrent-plugin-_task" rutorrend don't work after install that plugin but a lot and more important plugin required it. Samebody can tell me how I can fix?
Thanks
Rutorrent has a lot of problems. It took me a while to set it up.
Why not using Transmission client? Works like a charm..
I did. It worked, I stopped it, started, stopped again and....same issue occured. I did have optware, then I installed entware and it was running smoothly with transmission which runs on entware, so I got entware installed. I dont understand what the issue might be, and there is nothing in the logs either. How do I turn on the debug mode?Install entware from scratch after rebooting router
Just to double check.....you can't have both optware and entware. It's one or the other.I did have optware, then I installed entware
Thanks, but how do I check this, other than having entware symlink and working opkg command? entware version of transmission runs fine, rutorrent doesntJust to double check.....you can't have both optware and entware. It's one or the other.
Do you get error when installing rutorrent or after?
opkg install rtorrent-easy-install
Package rtorrent-easy-install (0.2-3a) installed in root is up to date.
Configuring rtorrent-easy-install.
#### Welcome to rtorrent easy installation script!
We assuming no lighttpd/rtorrent/rutorrent was installed before!
Please, answer a few question to configure torrent client.
Default aswers given in [brackets], just hit Enter to accept it.
Type "username:password" if you want to protect Web UI or hit Enter to leave password protection disabled []:
Which port should be used by web interface? [81]:
Enter (maximal) download speed in KB/s [2048]:
Enter (maximal) upload speed in KB/s [2048]:
Enter folder name on USB drive where torrent content should be stored [/opt/torrents]:
Done! You may open 51411-51412 TCP/UDP ports on your router to
facilitate uploading/donwloading. It's not necessary but recommended.
rutorrent web UI will be available at following URL:
http://<ip_address_of_router>:<port>/rutorrent
Do you wish to start torrent client? [y]: y
Starting lighttpd... already running.
Starting rtorrent... failed.
Collected errors:
* pkg_run_script: package "rtorrent-easy-install" postinst script returned status 255.
* opkg_configure: rtorrent-easy-install.postinst returned 255.
/opt/etc/init.d/S85rtorrent start
Starting rtorrent... failed.
Welcome To SNBForums
SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.
If you'd like to post a question, simply register and have at it!
While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!