We all have an old computer at home, that hasn’t been used in years, but because it still works, we hadn’t had the heart to trow it away. Well its time of misery has come to an end, we are going to convert it to a home data server. Using a torrent client to download files from the web, and running a ftp server on the machine, we will make your personal PC’s hard drive love you more, by not filling it with hundreds of gigabytes of data (read: movies, music), and making it available to any PC on your home network.
But why use Ubuntu server? I hear you ask, well I assume you are going to use an old computer and the server edition doesn’t use nearly as much resources as the desktop one or the Windows os, you can install Ubuntu desktop if you have a more powerful computer and follow the steps using the console.
Things you will need:
Computer: any old computer will do, but it has to have at least 128 Mb ram, 300 MHz processor, a graphics card, Lan/Wlan capability, installed Ubuntu 12.04 Server and a USB port (optional).
You will also need: monitor, keyboard, an additional external or internal HDD (>100Gb).
This guide assumes you have already installed Ubuntu server on your computer, for help installing click here!
Table of contents:
- The first steps (installing the software)
- Configuring the software
- Last few steps
The first steps
Once the system installs log in with your username and password and follow the steps.
1.1 SSH server
First you will need to install a SSH server, if you have selected the packages when installing Ubuntu you can skip to the next step.
We need the SSH server to remotely access our server.
Install the SSH server using the comand:
sudo apt-get install openssh-server
Hit “y” and enter when asked if you want to install
Next we have to make sure the SSH server is running. Go to one of your other PC’s connected to the same network the server is connected to and download PuTTY from here. Before we can connect we must get our server’s IP adress.
This can be done with the next command:
“sudo ifconfig -a”
This command will print out the list of the connected ethernet cards and their IPs, the IP will be written after “inet addr:”
Start PuTTY and in the field “host name (or IP address)” write the servers IP address and press “Open”. If you get a console asking you to login everything is working fine. From now on we can do everything from our remote computer, there is no need to jump back and forward from computer to computer. If you can not access the server, check the IP address and/or restart the server using the next command:
1.2 FTP server
Next we will install the FTP server. This will allow us to get files to and from our server.
Install the FTP server using this command:
“sudo apt-get install pure-ftpd”
To test if it works try:
If you get something like “Unable to start a standalone server: address already in use”, it is working.
1.3 Torrent client
The torrent client we will be using is Rtorrent
As before we will be using apt-get to install it. Type the following command:
“sudo apt-get install rtorrent”
This should install Rtorrent.
1.4 Mounting your external drive
You will have to mount your external hard drive before you can continue, mounting means not only to connect it to the server, but instructing ubuntu to connect to it, so it can read/write to it.
1. Connect the drive to your server, I would recommend formatting the drive to ntfs file system and saving a .txt on it, this will make it easy to check if it is connected to our server.
2. Wait a few seconds and input the following command: “sudo fdisk -l”
3. It will output all of the disks connected to the server, we are looking for /dev/sdb (WARNING the drive can have a different letter at the end, so it may be listed as /dev/sdc ), it should be the same size as your external disk. You will be using the partition on said disk which should be listed as /dev/sdb1 , if there are multiple partitions on the drive, they will have different numbers.
4. Next we will make a directory where your external hard drive will be mounted to, I usually put it in” /mnt” and call it disk. Type the following command: “sudo mkdir /mnt/disk “. and check if it is there by typing: “cd /mnt” this will take us to the /mnt directory, next type “ls” to see the folder “disk”.
5. To mount the disk, you must input the following command “sudo mount /dev/sdb1 /mnt/disk” . Where sdb1 is the partition not the entire disk, you will get an error if you try to mount the entire disk not the partition.
6. To check if the disk mounted correctly, type: “ls /mnt/disk” and you should see the file you wrote on it in step 1.
7. To automatically mount the disk, we must do some more work, but the following steps are not necessary, you can use “sudo mount /dev/sdb1 /mnt/disk” when the server is restarted and it will mount just fine (not following the steps below can cause issues for rtorrent as it will start without the required folders loaded). In the next steps I will show you how to make a startup script, which will automatically mount the disk.
Use the following command to open rc.local with a text editor: “sudo nano /etc/rc.local” , under the colored text and above the exit 0, write the following: “sudo mount /dev/sdb1 /mnt/disk” press “ctrl+o” and hit enter, this will save the document, then press “ctrl+x” and you should return to the command line, next we have to make the script executable, to achieve this type: “sudo chmod +x /etc/rc.local”, this will change the file’s permission to be executed . When you reboot your server, the disk should automatically mount. There are other ways to mount an external hard drive, this is the easiest, but can have issues when more than one disk is connected to the computer.
This should be everything regarding the installation of the software and hardware. next we will configure the software we just installed.
2 Configuring the software
2.1 ssh server configuration
The ssh server doesn’t need any additional configuration, although it is recommended that you set up some security measures. In other words it is good to have some kind of safety measure to deny unauthorized users to connect to your server. This is only needed if your server is accessible from the internet. This is done by use of a personal key.
The guide is available here!
2.2 Ftp server configuration
For the FTP server the same goes as for the ssh server, it is a good idea to limit access. Thus keeping our data safe.
Guide will be added soon
2.3 Rtorrent configuration
Here we will configure our torrent client, it will automatically download and sort the files into folders. The process is a bit lengthy but not as hard as it may seem on first glance.
2.3.1 Creating the folders
You will need to create some folders, for Rtorrent to start doing its magic.
1. You will need to create the following folders on your disk:
rtorrent_watch rtorrent_completed rtorrent_loading rtorrent_sessions rtorrent_temp .First we will create a folder named torrent on our disk: “mkdir /mnt/disk/torrent” , navigate to the folder using: “cd /mnt/disk/torrent” . Then create the folders using: “mkdir
rtorrent_watch rtorrent_completed rtorrent_loading rtorrent_sessions rtorrent_temp". The folders are now created, to check it type: ls . If the folders are not there check if you navigated to the correct location and/or try making the folders using sudo.
2.3.2 The rtorrent configuration file
1. Next we will create the rtorrent configuration file named .rtorrent.rc . Go to “/mnt/disk” using: cd /mnt/disk and get the rtorrent.rc by typing: wget http://libtorrent.rakshasa.no/export/1303/trunk/rtorrent/doc/rtorrent.rc . Or download it to your windows desktop from here and upload it to your server’s “/mnt/disk” folder by using a ftp client like filezilla.
2. Now we have to edit the configuration file by typing sudo nano /mnt/disk/rtorrent.rc . For every entry you will change you have to remove the “#” at the beginning of the line.
3 First we will change the default location of where the completed torrents will be saved. In the rtorrent.rc find the line that says “# Default directory to save the downloaded torrents.”. Below this line change the entry so it says “directory = /mnt/disk/torrent/rtorrent_completed”.
4 Next we will configure the watch directory, in this directory we will later put our .torrent files. Rtorrent will automatically check for new torrents and start downloading them and when it finishes it will delete the .torrent files. Find the line that says something like “#schedule = watch_directory,5….” and change the end from “./watch/*.torrent” to “/mnt/disk/torrent/rtorrent_watch/*.torrent”. Also remove the “#” from the line below this entry.
5 You can also change the other parameters, but do it at your own risk. Nothing bad can happen, but it may not work as intended. For more information click here.
6 Next we have to copy the configuration file and make it hidden so that rtorrent will be able to load it, we have to copy it to the root of our user folder in my case it is “/home/tomasys” for you it will be like “/home/your_username_here”. We do this with the following command “sudo cp /mnt/disk/rtorrent.rc /home/tomasys/.rtorrent.rc”
7 Now we will test rtorrent if everything works. Copy a .torrent file to “/mnt/disk/rtorrent_watch” and start rtorrent with the command “rtorrent”. Rtorrent should start to automatically download the torrent. If it doesn’t, retry from step “2” of this subset. To quit rtorrent press “ctrl-q”
3 The last few steps
3.1 making rtorrent start when the machine starts
So now we will configure rtorrent to start with the machine. To achieve this we must again edit “rc.local”. Type “sudo nano /etc/rc.local” and below the text we added a few steps before add another line and type “screen rtorrent -n -o import=/home/UESRNAME/.rtorrent.rc” (where USERNAME is your username) press “ctrl-o” hit enter and “ctrl-x”. Next we must make sure that we have the program named screen. In the console type “sudo apt-get install screen” when asked if you want to download it hit “y”, if it is already downloaded it will state that the package is already the newest version and you don’t have to do anything. Reboot your system by typing “sudo reboot”, when the machine reboots rtorrent should start automatically and continue downloading. If it fails quit it with “ctrl-q” and check rc.local in case you misspelled something.
3.2 connecting via ssh
Now that everything is working you may want to connect to the server via ssh. To do this you will use putty available here. Run it, in the “Host name” field type the server’s ip address (adress can be found via the “ifconfig” command) and hit “open”. you will be presented with the login screen much like what you see on your server. Login with your username and password and type “sudo screen -d -r” this will open your rtorrent client. To close it press “ctrl-a-d”. By not pressing the “ctrl-q” key combination, rtorrent keeps running in the background. To get it back just type “sudo screen -d -r” and rtorrent will reopen.
3.3 Were almost done
So we are almost done, reboot your server using “sudo reboot”. And access its bios (bios is usually accessed by pressing the “del” key during startup). In the bios under the tab “advanced bios options” or “advanced power options”, try to find the option “wake up after power off” or something along those lines. Enable it, this will ensure that the server will automatically start up if the electrical power were to fail.
Now you can unplug everything from your server except for the keyboard, as the bios may halt startup if the keyboard is not detected
Now you have a powerful torrent munching machine that you can put anywhere you like, it will automatically download and upload torrents for you. You can even configure it to start and stop at a specific time of the day, to seed torrents until a ratio is reached and much much more.
If you followed all the steps to the letter you shouldn’t have any problems, but if you run into any problem first check back in the guide if you left something out or did something wrong. If all else fails leave a comment and i will try to answer it as soon as possible.