How To: Convert your Xbox to a NAS – Part 2

Photo of author

Kevin Herring

Introduction

So you now have followed Part 1 of this ‘How To’ and have completed the hardware part of the project. In this part, we’re going to install the open source software that will get your modified ‘box running as a SAMBA fileserver. We’ll also get a complete LAMP-based webserver up and running so that we can install the TorrentFlux client that you’ll be able to use to manage all your BitTorrent downloads.

First, you can now put the top back on your modified Xbox and tuck it away in a cupboard and forget about it. Everything we do from now on will be via SSH. Now it’s time to do a bit of reading. If you’re not familiar with Linux partitioning, formatting and mounting, first take a look at this entire document. To format and mount our new disk you will need to type in the following when logged in as root:

fdisk /dev/hdb

n (new partition)

p (primary partition)

1 (partition 1)

enter ( to select the default first cylinder of 1)

enter ( to create the partition using the entire disk)

w (to write the new partitions to disk)

q ( to quit )

now format it with:

mkfs -t ext2 -j -m 1 /dev/hdb1

Then create a directory in which you will mount the disk:

mkdir /samba_share (or whatever you want to call it)

and then make it readable and writable to everyone:

chmod 777 /samba_share

Now we want to automatically mount the drive every time the Xbox boots. Edit your /etc/fstab file using vim, and add the following line at the bottom:

/dev/hdb1 /samba_share ext3 defaults 2 1

then exit vim and then mount it:

mount /samba share

Installing and removing software

OK, so now when you boot into Linux and SSH to your Xbox you should have a folder called samba_share. Anything you put in here will be available on your NAS.

Now it is time to install some software. Debian has a great command for installing software that checks all the dependencies, so there is no need to worry about that. We’re going to install Samba to enable filesharing, and SWAT so that we have a nice GUI to configure Samba with.

Since we’re also going to install the TorrentFlux BitTorrent client later, we’ll also install the Apache webserver, MySQL database, and PHP4 scripting language. Although it’s optional, we’ll also install the phpmyadmin web-based GUI for administering the MySQL database.

apt-get update
apt-get upgrade

apt-get install samba

apt-get install swat

apt-get install apache

apt-get install mysql-server

apt-get install php4

apt-get install phpmyadmin
(optional)

Also as this is a headless install you might want to consider removing the X-Windows modules to free up some RAM. Type in this:

dpkg --purge xfs

dpkg --purge x-window-system

dpkg --purge xdm

apt-get remove lpr
(if you never intend to use it as a print server)

Now assuming all that went without incidence, you should have a fully working LAMP web server! On your PC’s web browser go to http://ip_address/ (where you obviously put in the IP address of your Xbox) and you should get a screen telling that this page is under development.

Samba and SWAT

The first thing we are going to set up is Samba, as this is what enables us to share the files in our big disk over our Windows network. SWAT (Samba Web Admin Tool) enables us to configure Samba over a nice web interface instead of digging through the samb.conf file that stores all the Samba settings. Have a quick read of the SWAT help files here.

To enable SWAT, we need to add it to our /etc/inetd.conf file, so type:

vi /etc/inetd.conf

At the bottom of the config file, there should be the following line:

swat stream tcp nowait.400 root/usr/sbin/tcpd /usr/sbin/swat

It might be in there, but commented out with ‘#’. Either way, make it’s there and not commented out. Also, check for a lines referring to smbd and nmbd, but probably commented out. At any rate, before you close the file, make sure that you have the following lines at the bottom of your file:

netbios-ssn stream tcp nowait root /usr/sbin/smbd smbd
netbios-ns dgram udp wait root /usr/sbin/nmbd nmbd

Now restart your networking with:

/etc/init.d/inetd restart

This will enable Samba networking and the netbios IP naming. Once this is running, you will be able to refer to your Xbox with its DNS name (that you chose in the installation process, probably ‘xbox’) as well as its IP.

Now with your PC’s web browser, go to http://ipaddress:901/ (again, using your own Xbox’s IP address) and if all goes well, you should see an admin web page. Click on the Status button at the top and you should see that smbd and nmbd are running. If not, you probably did something wrong earlier, so go back and recheck the edits to the /etc/inetd.conf file.

Now click on Shares, type in a name (e.g ‘samba_share’), and click Create Share. You will then be presented with a list of options about your new share. Change ‘path’ to the name of the directory that you mounted your hard drive into earlier, e.g. ‘/samba_share’. Now turn off read only, turn on guest ok and click Commit Changes. The result of all this created a share that is available as read and write for everyone. If you want to add specific privileges for users, then you’ll need to add them to this page.

If you now go to your Windows PC and browse your workgroup, you should see an entry for your Xbox. Expand the icon and you should see your share, plus some other stuff like printers. For convenience, you can map the share to a drive letter (I chose ‘s’) on each of your Windows machines.

Well done! You have completed the second step of your project!

BitTorrent & TorrentFlux

We’re now going to install the TorrentFlux BitTorrent client software. Go to the TorrentFlux webpage and have a good look around and check what the latest version is. TorrentFlux is no Azureus, but it is a lot less demanding and is ideal for our use. These instructions use version 2.0 beta 1, so navigate to your home directory and type in (this all goes on one line):

wget http://prdownloads.sourceforge.net/torrentflux/torrentflux-2.0beta1.tar.gz?download

This will download the gzip to your home directory. Now type in:

tar -zxvf torrentflux-20.beta1.tar.gz

which will extract the file to a directory of the same name (torrentflux-2.0beta1). Now go into your new directory and have a read of the INSTALL document.

Next copy the html directory into the place where your web pages are kept:

mkdir /var/www/torrentflux
cp -r html /var/www/torrentflux

Now we need to create the mysql database for TorrentFlux to use:

mysqladmin create torrentflux

Then using the provided torrentflux.sql script, create all the required tables:

mysql torrentflux < torrentflux.sql

Next, you’ll need to create a mysql user. So go to the mysql command line and enter:

mysql

Then connect to the database you just created with:

connect torrentflux

Now create the user:

grant CREATE,INSERT,DELETE,UPDATE,SELECT on torrentflux.* to tf@localhost;

And set the password:

set password for tf = password('MyPassword');

Now quit out of mysql using ‘exit’.

Copy the two bittorrent python files and make them executable:

cp TF_BitTornado/ /usr/local/

chmod +x /usr/local/TF_BitTornado/btphptornado.py

chmod +x /usr/local/TF_BitTornado/btshowmetainfo.py

Next you need to edit the config.php file:

vi /var/www/torrentflux/config.php

Near the top you will see various settings. They should look a bit like this:

$cfg["db_type"] = "mysql";

$cfg["db_host"] = "localhost";

$cfg["db_name"] = "torrentflux";

$cfg["db_user"] = "tf";

$cfg["db_pass"] = "MyPassword";

$cfg["path"] = "/samba_share/downloads/";

$cfg["btphpbin"] = "/usr/local/TF_BitTornado/btphptornado.py";

$cfg["btshowmetainfo"] = "/usr/local/TF_BitTornado/btshowmetainfo.py";

There are other options here, such as port numbers you might wish to change and they are all fairly obvious. Save and quit the file, then navigate to http://ipaddress/torrentflux with one of your other computers. Hopefully, you will be confronted with the login screen. Note that the username and password you enter here will be saved as the super-user.

If you’ve used BitTorrent, the TorrentFlux client is pretty self-explanatory. But if you need help, jump on over to the TorrentFlux Forum.

That wraps it up for Part 2. In the next and final installment, we’ll add the ability to allocate bandwidth between BitTorrent and other Internet activities, and check out the file serving performance of what we’ve created.

Related posts

Build Your Own Fibre Channel SAN For Less Than $1000 – Part 2

In Part 1, we built a NAS Disk Array. This time we will convert our NAS array into a fibre channel SAN and configure a Windows DAS server.

How We Test: Networked Storage Devices

All you need to know about how we test Networked Storage devices.

Back Up Your Gmail!

Want to have your Gmail safe and secure? Here's how to back it up.