rTorrent BitTorrent Client on Arch Linux

rTorrent Arch Linux logo

rTorrent is a fast and efficient command-line based BitTorrent client. It can work many front-end interfaces such as ruTorrent. When used with a web interface it is similar to other clients like uTorrent Server or Deluge.

 

Install rTorrent

Install from official repositories.

sudo pacman -S rtorrent

 

Install tmux.

sudo pacman -S tmux

Tmux is only required to run as a daemon with systemd.

 

Configure rTorrent

Create a system account and group.

sudo useradd -r rtorrent

Tmux requires shell access which means -s or --shell option should not be used to set a fake shell.

 

Create system directories.

sudo mkdir -p /mnt/downloads/rtorrent/{.session,watched,seeding}

 

Change the ownership of the download directories.

sudo chown -R rtorrent:rtorrent /mnt/downloads/rtorrent

 

Change the permissions of the system directories.

sudo chmod -R 771 /mnt/downloads/rtorrent

 

Copy a sample configuration file to use as a default configuration.

sudo cp /usr/share/doc/rtorrent/rtorrent.rc /etc/rtorrent.conf

 

Open the configuration file.

sudo nano /etc/rtorrent.conf

Uncomment session = ./ and change the value to the absolute path to the session directory created earlier for example session = /mnt/downloads/rtorrent/.session. Despite the comments and even default values implying otherwise, due to a bug relative paths do not work regardless whether the directory option is set or not. Similarly the directory =  should be changed to the download directory. Other settings cna be configured as needed.

One particularly useful option which is not in the default configuration file is the umask option.  It allows default permission modification of the downloaded files. For example system.umask.set = 002 setting will result in all downloaded files to have 775 permissions.

 

Start rtorrent manually.

rtorrent -n -o import=/etc/rtorrent.conf

By default the configuration file is loaded from ~/.rtorrent.rc. This behaviour can be disabled with -n option. An alternative settings file is specified with -o option.

 

Create the systemd script.

sudo nano /etc/systemd/system/rtorrent.service

 

Copy the script and save.

[Unit]
Description=rTorrent Daemon
After=network.target

[Service]
Type=forking
KillMode=none
User=rtorrent
ExecStart=/usr/bin/tmux new-session -c /mnt/downloads/rtorrent -s rtorrent -n rtorrent -d 'rtorrent -n -o import=/etc/rtorrent.conf'
ExecStop=/usr/bin/bash -c "/usr/bin/tmux send-keys -t rtorrent C-q && while pidof rtorrent > /dev/null; do sleep 0.5; done"
Restart=on-failure

[Install]
WantedBy=multi-user.targetrTorrent Arch Linux logo

 

Backup rTorrent

Copy the download directory to the backup location.

sudo cp /mnt/downloads/rtorrent/ /mnt/backup/rtorrent

 

Backup configuration file.

sudo cp /etc/rtorrent.conf /mnt/backup/rtorrent

 

Restore rTorrent

Stop the systemd service.

sudo systemctl stop rtorrent.service

 

Remove the current data directory if it exists.

sudo rm -Rd /mnt/downloads/rtorrent

 

Move the backup to the download directory.

sudo mv /mnt/backup/rtorrent /mnt/downloads/

 

Set the ownership on the new directory.

sudo chown -R rtorrent:rtorrent /mnt/downloads/rtorrent

 

Move the backup configuration file.

sudo mv /mnt/backup/rtorrent.conf /etc/

 

Run rTorrent

Start the systemd service.

sudo systemctl start rtorrent.service

 

Enable the service to run on boot.

sudo systemctl enable rtorrent.service

 

Use rTorrent

rTorrent is accessed via Command Line however this can be tedious to use as a primary means of access. A good option is to install ruTorrent or another web interface.

dom