Tuesday, May 18, 2010

Converting ASUS WL-520GU into a Standalone Bitorrent Client, NAS/FTP Server.

A powerful pc + an unlimited broadband internet connection = ultimate recipe for shocking power bills. This is the perfect solution for this nightmare. Consider this: an average pc will consume 150W of power on idle/downloading. The below described download rig solution requires just 3W of power & will double up as a wifi router also. The total cost of setting this up is around 1900rs (price of the router) + 800rs (price of a 8gb pen drive). Plus you need to have a lot of time & patience also.

Before starting, someone would be wondering why i selected the ASUS W-520GU?? Its just a 'G' router, only one USB port & pretty basic hardware specs. The reason is simple: its cheap, easily available & will get the job done pretty easily. Ofcourse you can opt for any other DD-WRT compatible router. Select one according to your budget & purpose. Better routers with more ram & faster memory will allow more simultaneous downloads & better speeds.

I've seen a lot of tutorials available on the internet regarding installing DD-WRT onto the ASUS WL520GU & installing optware to make it a Standalone Bitorrent Client & NAS/FTP Server. But in none of them i've found a detailed step by step instruction of how to get it done. Me being a complete n00b in Linux made things a little more worse for me. After a lot of reading, researching, trial-error, banging ma head on the wall i've finally done it & the initial impresson was "OMG this was so simple if i'd have done it in the proper way the fist time itself". Ofcourse there were a lot of tutorials available on the net to how to get this done, but no single guide to get the job done from the ground up. So iam writing this for all those people who wants to convert the router into a standalone torrent downloader with NAS & FTP using Optware on DD-WRT.

Iam assuming the reader to be having an intermediate computer knowledge & zero linux knowledge..

Before getting started, you need require these:
1) ASUS Firmware Restoration Utility (Can be found on the supplied Utilities disk or downloaded from the internet.
2) DD-WRT Firmware File.
3) Hiren's Boot CD or a Live Linux CD. I prefer Hiren's Boot CD.
4) A thumb drive or external hard disk.
5) A telnet client like putty.
6) FTP Client like FileZilla.

Step1: Installing DD-WRT onto the router.
This is pretty much striaght forward. First of all the "ASUS Firmware Restoration Tool" is required to be installed. I find this method much more easy than using the web interface for flashing. I'd recommend connecting the PC/Laptop via a LAN cable for this.
Follow these steps:
1) Manually set the address of the PC/Laptop's LAN card to 192.168.1.10 and subnet mask 255.255.255.0.
2) Remove the power connector from the back of the router.
3) Using a pointed object press & hold the reset button. Connect the power connector back while holding the reset button.
4) Wait till you see the flashing power light & now release the reset button. The router is now in recovery mode.
5) Open Asus Firmware Resoration tool from Start -> All Programs -> ASUS Utility -> WL-520GU Wireless Router -> Firmware Restoration.
6) Browse for the already downloaded firmware file & click upload.
7) Wait till the process get over. The router will automatically restart.
8) Wait for some 5 minutes & power cycle the router.
9) Change the LAN card's setting to obtain IP address automatically.
10) You should be able to login the to the web interface in the address htpp://192.168.1.1 with username & password as admin.

You will be greeted with a screen asking you to change the username & password to a more secure one. I'd suggest to keep both of those as admin/admin as i will be using those as the username/password for the rest of this guide.

Step2: Preparing the USB Drive.
This step can done either by using a Linux Live CD or Hiren's Boot CD. My personal preference would be Hiren's Boot CD. Run Hiren's Boot CD & launch Acronis Disk Director Suite. Delete the partition(s) on your pen drive/hard disk & create four new partitions with the following specifications:

Partition no: -- Type -- Size -- File System -- Label
  1 Primary --  320MB -- EXT3 -- Optware
  2 Primary -- 256MB -- Swap -- Swapfile
  3 Primary -- 256MB -- EXT3 -- JFFS
  4 Primary -- (rest available space) -- EXT3 -- Data

Apply the changes & close Acronis Disk Director Suite. Reboot the system.

Step3: Initial Configurations to the router before installing Optware.

1) Goto the Services tab -> Services sub tab -> Enable Secure Shell & Telnet.
2) Goto the Services tab -> Usb sub tab -> Under USB Support enable everything except USB 2.0 support & FAT File Syatem Support.
3) Select the Disk Mount Point as /opt
4) Goto the Services tab -> NAS -> ProFTPD -> Enable. Files directory: /mnt. Allow Write: Enable. User password list: admin admin.
5) Goto Administration tab -> Management sub tab -> JFFS2 Support: Enable.

Step4: Installing Optware.

1) Open putty & in the host name files type in 192.168.1.1. Port: 22. Connection type: SSH. Click open.
2) Since connecting for the first time, a putty Security Alert window will pop up. Click on Yes.
3) On the putty login screen, login as: root & password: admin.
4) In the root prompt type: wget -O /tmp/prep_optware http://wd.mirmana.com/prep_optware. press enter.
5) Once the previous instruction finishes & returns back to the root@DD-WRT:~# prompt, type: sh /tmp/prep_optware. Press enter.
6) Downloading & installation of Optware packages will commence. This is a very time consuming process & stresses the router very much. Close the web interface to free up some system resources.

Have a break. Have a coffe, take a quick nap or anything. No user intervention is required till the process get over. It'll sure take some 20min+ to get everything downloaded, insalled & configured.

7) Once everything gets finished & the root prompt is returned, wait for some 2 minutes & reboot the router. This can be done either via the web interface or typing in "reboot" at the root prompt.
8) Once the router reboots, wait for some 2 minutes more & login using putty.
9) Mount the last of the 4 partitions onto /mnt. This can be done by issuing the following command to the root prompt. mount /dev/discs/disc0/part4 /mnt.
10) Check that all partitions are mounted using the command "mount". Check for the available free space using the "df -h" command at the root prompt.
11) Enter the command "service" at the root prompt. It'll show all the installed services. The running ones are shown in green & disabled ones are shown in red.

Any service can be started using the command: service start
Services can be stopped using the command: service stop
Before any service can be started, it whould be on first. Services can be switched on using the command: service on
After stopping the service it should be switched off if not required to be loaded everytime the router reboots. This can be done using the command: service off.

12) Twonky service is enabled by default which is a massive resouce hog & is not required for our purpose of BT downloads. To recommend it enter the following two commands in the root prompt:
service twonky stop
service twonky off
13) The automount service will already be started, if not start it by issuing the following command in the root prompt: service automount start

Optware is sucessfully installed. But we still need to start the transmission service & configure it which is described in the next step.

Step5: Starting & Configuring Transmission

1) Start the transmission service by issuing following commands in the root prompt:
service transmission on
service transmission start
2) Configure the folders for transmission using the command:
/opt/bin/transmission-daemon -g /mnt/data/torrents/.config/transmission-daemon
killall transmission-daemon
This will create all the required folders for the Transmission client to use. Just to double check, check wether the transmission service is running or not once more. If the service is just started, wait for some 1 minute before proceeding to the next step.
3) Starting Transmission Client web interface for the first time. Type in "http://192.168.1.1:9091/" in the browser address bar. This will open up the transmission web interface.
4) Open preferences by clicking the gear icon on the lower left corner. Change the download to field to "/mnt/data/torrents/downloads" if not already the same folder. Change any other required settings & click save.
5) Try adding a test file to the download list by clicking on the open button on the top left & browse for a .torrent file. Tick the start when added option & click upload. The file download will start.

Setp6: Accesing the downloaded files.
Since we already started the FTP service, all we need to do is open FileZilla enter the required details. Hostname: 192.168.1.1 , Username: admin , Password: admin & click quick connect.
The downloaded files can be accessed in the "/mnt/data/torrents/downloads" folder. Once the file is coped to the PC, the file can be removed from the downlaod list by right clicking the particular dowload & selecting the "Trash Data & Remove from List" option.

Notes:
I've noticed the router taking some more time to boot up. May be due to the extra services.
While switching on the PC, the wireless connection seems to be taking some more time to get connected. may be some 5-10 seconds more.
Apert from these everything seems to be normal.

Tips:
Always keep a check on the free space available on the disk by using the command "df -h"
Initally I've got file errors after i try to ftp the file to the PC. This issue is resolved by not logging using the FTP client while the download is on progress. Don't know wether this was the reason, but it fixed up the problem for me.

Happy Downloading!!!