May 18, 2018

Running Transmission as a headless torrent client

Install transmission as a headless/daemon torrent client, inside an LXC container. Some assumptions about setup are made.

Add transmission repo

sudo add-apt-repository ppa:transmissionbt/ppa

Add openvpn repo

wget -O - | apt-key add -
echo "deb xenial main" > /etc/apt/sources.list.d/openvpn-aptrepo.list


sudo apt update && \
sudo apt install openvpn transmission-daemon nfs-common

System tweaks

Add to /etc/sysctl.conf on the container host:

#increase max
net.core.wmem_max = 1048576
net.core.rmem_max = 4194304

Disable IPv6 for this container

To fix issues with IPv6 leaking if you use a IPv4 only VPN with OpenVPN, add this inside the container:

#disable ipv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

Then update sysctl:

sudo sysctl -p

Verify IPv6 is disabled:

cat /proc/sys/net/ipv6/conf/all/disable_ipv6
It should return 1.

Restore config (what does config have? why is it needed?)

service transmission-daemon stop
scp [email protected]:/path/to/server-configs/settings.json /etc/transmission-daemon/settings.json

Storage targets for temp and finished downloads

Completed downloads

Create directory for downloads on container host and fileserver

On container host

Add mount line to /etc/fstab:

/mnt/downloads fileserver:/finished/downloads /mnt/downloads nfs rsize=8192,wsize=8192,timeo=14,intr
Configure container

lxc config device add CONTAINERNAME downloads disk source=/mnt/downloads path=/mnt/downloads

then bind mount on guest

repeat above steps for temp if not inside container

Temp folder on host

mkdir /mnt/tmp

set permissions

check uid/guid of container you want:
sudo ls -l /var/lib/lxd/containers

make permissions allow:

sudo chown 100000:100000 /mnt/tmp

Configure container

lxc config device add blackhole temp disk source=/mnt/tmp path=/mnt/tmp

Start Transmission

sudo service transmission-daemon start

Fix OpenVPN issues

To correct errors when running OpenVPN inside containers on Ubuntu 16.04 with SystemD
sudo nano /lib/systemd/system/[email protected]
Comment out line