netware5
Very Senior Member
[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.
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.
Last edited: