Saturday, October 24, 2009

How to transform a broken laptop into a server

I bought my second-hand Toshiba Tecra A3 for about 500 Euros while still in high school, with the earning of my first web projects. During the sebsequent years, it slowly fell into pieces, one step at the time:
  • the first things that failed were the speakers;
  • then, the Combo Dvd reader and Cd writer suddenly was unable to read an entire disk;
  • third, the hard disk began to be unreliable, as files saved on a particular portion of it became corrupted instantly;
  • then the lcd screen suffered a hit and was rendered useless, as only a big stain of color filled (and still now fills) all the screen.
In this situation, I ordered a new ASUS Eee PC from eBay to substitute my former portable working station. This was one of my best purchases, and the Tecra A3 was put in a box and forgotten. However I am glad that I did not throw it away.

Towards the end of 2008, I felt the need for a development/staging server at home, as part of my freelancer work with php applications. The server did not need to run 24/7, but only during my work sessions and with only me and a few other people to work for. I was aware that servers which run Apache and Subversion do not need high-end components and I started to gather ideas on how to recycle my old laptop.
The CD reader was not required for a server, and I could not change it easily anyway. The screen and the speakers were useless for the same reasons, but the hard disk is something a server usually needs. So I bought a cheap 10 gigabytes Eide unit on eBay for less than 30 Euros. Substituting the old drive with this one restored Indy status as a working machine.

The next problem was how to install software on a blank machine like this one, without a CD drive and a screen to complete the graphical or command line installation process.
For the screen problem, I temporarily attached my primary machine monitor and figured out quickly that installing a command-line interfaced system like Ubuntu Server would have given me a system accessible via ssh, without the need for a real screen as I would be able to use the server via other machines like the Eee PC and my primary computer.
The installation was more difficult as I had to find another medium for the Ubuntu iso image. My laptop is not capable of booting via Usb, so I chose an installation with a boot via Ethernet (PXE). This involved setting up a tftp server on my desktop machine to host the installation files, and I suggest you to use a Usb card installation if you want to do the same thing.

Normally, Ubuntu systems run the NetworkManager application in the user bar of Gnome providing a list of wireless network to connect to. I wanted to have a connected system at startup, since without a already existing connection the ssh login is not available. Thus, I configured wpa_supplicant, the daemon used by NetworkManager as a backend, to automatically connect to my home WPA wireless network. Obviously I installed the ssh daemon and after this step I was able to remove the temporary monitor and use my new server remotely.

Once I had a working machine, I installed apache, php, mysql and subversion via the Ubuntu repository, running apt-get over ssh, that is the interface I administer the server still today. Now I had a web and source control server that I periodically backup just in case something goes wrong. Reliability is nor critical as even is the server explodes I can roll out my backups the next day on my desktop machine.

There is an enormous amount of electronics garbage out there to dispose of, and recycling an old pc is by far cheaper than buying full-featured servers just for testing purposes (unless you're doing a stress test): the servers on the market are meant for production sites and php development activities, which do not require compilation, do not stress even a poorly equipped machine as they include only a few http requests per second to satisfy. If you manage to reuse old hardware, you are doing a favor to yourself and to the environment.

5 comments:

Giorgio said...

It is indeed very simple: burn a Ubuntu image on a cd and install it via booting from it. Then you'll have access to an enormous repository of open source server software (Apache, Php, Subversion, Mysql, PostgreSql, ftp daemons, dhcp servers...).

Anonymous said...

For an individual, it make sence to take time to use an old and broken computer as a server.

For an enterprise, it's not possible and useless. When a simple computer without an OS cost something like 400$ and when a basic reliable server cost 1000$...

Just think of the cost of the time needed to repear the computer, and you understand why.

IF you want to, as an enterprise, for as low as something like 30$ per month, you can have a dedicated machine, with 100MB bilateral conection to the net and all.

Giorgio said...

Of course this is a way explored by freelancers like me that have to cut the costs while bootstrapping. :)

CARFIELD said...

How about setting that up in your primary machine?? May be that is just waste of electricity??

Giorgio said...

I have limited Ram so I prefer to keep all server stuff on a separate machine. :)
It gives me also the advantage of being able to try new software and formatting everything whenever I want.

ShareThis