In this guide, we will create from start to finish a seedbox on a c1 server.
There are three steps to spawn a new server
- Spawning a new server
- Adding volumes
- Provisioning the server
There are eight steps to setting up the server
- Log in to the server
- Updating the packages
- Formatting the volumes
- Installing the Software Repository
- Installing rTorrent
- Configuring rTorrent
- Installing ruTorrent (WebUI)
- Installing NGINX / PHP
- Running rTorrent
- Bonuses
Spawning a new server
Before we can start we have to spawn a new C1 Instance that we will be using for our SeedBox. You should be fluent with the following steps but I’ll detail them here anyway.
Step 1- Create a new server
First step is to create new server. Once you are logged into your cloud account click the Create Server button. You should get a screen that looks like the following:
Once you are here simply give your server a name (preferably something obvious like SeedBox) and choose Ubuntu Trusty (14.04 LTS) as the Image. (Whilst Ubuntu Utopic (10.10) and Debian Wheezy should work, I haven’t tested them and thus I can’t provide any support if they don’t work)
Step 2 – Adding Volumes
The next step is to add a volume to your SeedBox. The size of the volume will much depend on how much content you think you will be seeding.
Whilst everyone’s initial reaction will be to create a volume that is the largest possible, please think about your actual use cases before creating a large volume as this impacts other customers in the Cloud Preview.
This is a free trial so be fair and try not to use too many resources.
You server will have an existing volume already added to your server. Click the edit button and change the name.
This will come in handy in the future incase you want to snapshot it or attach it to another server. You can also change the default size from 100GB if you think you need more or less space.
Please take note of what I said above and be fair to other Online Lab’s users. Once you have edited the volume click the Add New Volume button. Heres an example:
Optional Bonus
If the maximum size of a single volume isn’t enough (which would make me wonder what you are seeding) then you can create a second volume at this stage too. If you choose to do this, make sure you make both volumes the same type (either LSSD or LHDD). Later on in the guide I’ll show you how to utilize both the volumes. Please note that due to space issues currently in the cloud, trying to provision a server with more than two volumes will fail. Keep that in mind.
Step 3 – Provisioning the server
Once you have got everything looking how you want it, click the Create Server button at the bottom and give your server some time to provision.
Setting up the server
Now we get to the fun part, readying the server for use as a seedbox.
Step 1 – Log in to the server
The IP used to connect to your server is the public one listed in the control panel:
Step 2 – Updating the packages
Now that we are connected, It’s always a good idea to make sure your system is up to date before you start doing anything else so lets make sure all our packages are up to date.
To update our server we’ll start by fetching the latest list of packages and versions from the repository:
apt-get update
Then upgrade all the packages to their latest version:
apt-get upgrade
If there are packages to update they will be listed on the screen. Press the Y
 key if prompted to accept the upgrade.
Step 3 – Formatting the volumes
Now that everything is ready we are going to format the volume we added in the creation step so it’s ready for use.
Optional Bonus
If you chose to create more than one volume in the creation step please skip to 3B now!
Step 3A – Single Volume
If you added a single volume in the creation stage formatting and mounting your volume is reasonably easy. For this guide I’m going to be using ext4
 as the file system type.
To format the volume carefully enter the following command:
mkfs -t ext4 /dev/nbd1
Give it some time to format the volume. Once its complete we can now mount the drive. Simply enter the following command to mount it at the path /mnt
:
mount /dev/nbd1 /mnt
Congratulations you have just mounted your data volume!
Step 3B – Multiple Volumes
In order to easily utilize both the volumes we added in the creation stage we are going to make use of LVM. LVM is a volume manager that can do all sorts of amazing things with disks in software. To get started we need to install LVM:
apt-get install -y lvm2
Then we are going to create what is called a physical volume (pv) on each of our volumes:
pvcreate /dev/{nbd1,nbd2}
Next we are going to create a volume group (vg) which groups all our physical drives into one big drive:
vgcreate lvm /dev/nbd1 /dev/nbd2
Now we are ready to create a logical volume (lv) which is a chunk of our volume group that we can use as if it was a physical drive. We want to use all the space available so we use the following command:
lvcreate -l 100%FREE -n downloads lvm
The drive will now be available at /dev/lvm/downloads
 (where lvm
 is the volume group and downloads
 is the logical volume). Lets format it and mount it:
mkfs -t ext4 /dev/lvm/downloads
This command can take a while to run as it has to format two separate drives over the network.
mount /dev/lvm/downloads /mnt
Congratulations you have just mounted your data volume on /mnt
!
Step 4 – Installing the Software Repository
Now comes the fun part, installing the SeedBox software. For this we’ll be using rTorrent and the wonderful Web-GUI ruTorrent.
I have compiled and uploaded the latest version of rTorrent and libTorrent to my Cloud Ports repository. To access it we first have to install the verification key for the repository and then add it to our repository list. To install the key enter the following command:
apt-key adv --keyserver hkp://keys.gnupg.net --recv B51AD4BE
This will download and install my GPG key that is used to sign the packages I compile and upload (to make sure you are downloading packages I built!). Run the following to install the repository:
echo "deb http://10.1.22.179/ubuntu cloud main" > /etc/apt/sources.list.d/cloud.list
Now that it is added we have to update our packages list again. To do that:
apt-get update
Note
If you do not wish to use my repository, rTorrent 0.9.2 is available in the Ubuntu repository.
Step 5 – Installing rTorrent
The first step is to install rTorrent. To get the latest version enter the following:
apt-get install -y rtorrent
It will grab rTorrent and its dependencies from my cloud ports repository and install them! Congratulations rTorrent is now installed! Now to configuring it.
Step 6 – Configuring rTorrent
This step is probably one of the most delicate and takes some time to refine. Most of the following configuration options are based on personal preference but some are also tweaked for the Cloud. Lets start by creating the configuration file for rTorrent. I’ll provide my configuration file for you to get started with:
wget -qO ~/.rtorrent.rc http://gist.ptn.re/xeoncore/323fb644f6804671bfce
Now open it up and edit it to you liking:
nano ~/.rtorrent.rc
The first thing you will need to change is the ip = xxx.xxx.xxx.xxx
 line. Replace the xxx.xxx.xxx.xxx
 with your Public server IP! This enables rTorrent to forward the correct external IP to trackers and the DHT. You may also want to change the directory
 and session
 entries but make sure you put them under the /mnt
 path otherwise they won’t end up being put on your second volume. Probably the main part you will want to modify is this section:
min_peers = 20
max_peers = 100
min_peers_seed = 10
max_peers_seed = 100
max_uploads = 40
Change the values to what you need or want. Once you are done press Ctrl+O
 and then Enter
 to save the file, then Ctrl+X
 to close nano
.
The next step is to create the paths we will be storing files in. If you kept the example paths in your rTorrent configuration file the command looks like the following:
mkdir /mnt/{downloads,session,watch}
And thats it for the rTorrent configuration!
Step 7 – Installing ruTorrent (WebUI)
The next step is to install the ruTorrent web interface for rTorrent. First create a folder to store it in:
mkdir /var/www
Then get the latest version of it and install it there:
curl -sN https://codeload.github.com/Novik/ruTorrent/tar.gz/master | tar xzv --strip 1 -C /var/www/
Now we just need to edit the configuration a bit to work in our environment. Run the following commands:
sed -i "s|topDirectory = '/'|topDirectory = '/mnt'|" /var/www/conf/config.php
for cmd in php curl gzip id stat; do sed -i "s|\"$cmd\"\s*=>\s*''|\"$cmd\" => '"`which $cmd`"'|" /var/www/conf/config.php; done
Next we will remove some plugins that don’t play nicely:
rm -fr /var/www/plugins/{httprpc,rpc}
Step 8 – Installing NGINX / PHP
ruTorrent is a Web interface for controlling rTorrent, so our next step in getting it running is installing a web server. If you have a preference of web server and you know how to set it up, skip this step and install/configure your own web server and PHP.
First start by installing nginx and PHP:
apt-get install -y nginx php5-fpm
Next remove the existing default config files:
rm /etc/nginx/conf.d/*
And grab the configuration file from here78:
wget -qO /etc/nginx/conf.d/rtorrent.conf http://gist.ptn.re/xeoncore/6955956701d1a449e3f2
Next we create a username and password to protect our ruTorrent interface from unauthorized people. I’ve provided a script that will ask for a username and a password, will salt and hash it then generate a passwd entry for nginx. The following scripts source can be found here39:
bash <(curl -sSL http://gist.ptn.re/xeoncore/a9238c51921d04c878f2) > /etc/nginx/passwd
Add nginx to the www-data group:
usermod -a -G www-data nginx
Now just restart NGINX:
service nginx restart
9 – Running rTorrent
Congratulations on making it this far! To keep rTorrent running in the background we need to install a program called screen:
apt-get install -y screen
Now we can start rTorrent and hope for the best:
screen -dmS rtorrent rtorrent
Enjoy!
Now simply browse to your public IP address, enter your username and password, and enjoy your seedbox!
Bonuses
Everyone likes bonuses right? Heres a few tips and tricks to making it all work a bit better!
Install extra dependencies for ruTorrent
ruTorrent and some of its plugins require extra dependencies to work. You can install them by doing the following:
sed -i "s/universe/universe multiverse/" /etc/apt/sources.list
apt-get update
apt-get install -y mediainfo unzip unrar
Fix CPU Load plugin
The CPU load plugin works based on the Load Avg. reported by the server. Because the kernel on the Cloud instance has a Load Avg. bug, it will report 30% as the minimum load. To fix this, simply run the following command:
sed -i "s/\$arr\[0\]\*100/(\$arr[0]-1)*100/" /var/www/plugins/cpuload/cpu.php