fantini.name

just wasting bandwidth...

My Slug

slug

Slug is the nickname of the Linksys NSLU2, a small and cheap NAS you can get for less than 100 euros. This device runs a modified version of Linux made by Linksys and its original purpose is to make USB hard disks accessible over a LAN using the SMB protocol (i.e. to be a NAS). But its coolest part is the fact that it is possible to tweak it to run a “true” linux distro on it, thus enabling this small box to be much more than just a NAS. Below I will describe what I did with mine and here you can find a blog post with my ramblings about it.

Hardware

At the hardware level, the slug is essentialy a “minimalistic” computer. These are the hardware specs:

  • Intel XScale IXP420 CPU @266 MHz
  • 32 MB of RAM
  • 8 MB of Flash memory
  • 1 10/100 Mb Ethernet port
  • 2 USB 2.0 ports

slug-board

That’s it: no video output, no mouse, no keyboard, no nothing. Even no moving parts: the slug is completely fanless, thus absolutely silent. And another feature I like is that it’s not much bigger than a pack of cigarettes: it fits everywhere.

The processor is an ARM-compatible CPU clocking at 266MHz. The CPU was underclocked by Linksys at 133MHz on earlier models, but it is possible to “upgrade” it at 266MHz with a simple hardware modification. The average power consumption of the CPU should be about 1-1.5 Watt.

But you won’t believe what the slug can do for you even with these skimpy specs!

Firmware

The customized version of linux made by Linksys which resides on the flash memory just offers the few functionalities the NSLU2 comes with and it doesn’t make possible to add your own applications. But what makes the slug a cool device is the huge community of developers who made it easy to flash other standard linux distributions on it, including Unslung, Debian and Gentoo.

Unslung

The first firmware I flashed on my slug was Unslung 6.8. This firmware is based on the original one made by Linksys and is fully compatible with it, but unlike the stock firmware this one enables you to install a lot of additional applications on the device. Unslung comes with the ipkg package management system which tries to resemble Debian’s dpkg and so, in a nutshell, allows you to download install and configure new applications on your slug with a simple shell command. There are more than 1000 packages that have been specifically compiled for the NSLU2.

In my first installation I opted for a WD Passport 160 Gb USB drive as external storage for my applications which, amongst many others, included Apache 2 and Twiki to publish and mantain my own website. Eventually the whole system was working fine but the performance was really poor, mostly due to the lack of RAM: Apache webserver and dynamic page generation through Twiki (which requires Perl and some other stuff to run) were actually too much for the slug. So I finally gave up with this solution.

Debian

Not so long ago, I decided to give my slug another shot. My target was the same: using it as a web and ftp server to be run at my place. But I knew that in order to make things work, I had to change the design. The first change was the decision to install a true Debian linux instead of Unslung. I had had no problems with Unslung itself, but Debian comes with a lot more applications and updates. Furthermore, the NSLU2 is nowadays fully supported by Debian (thanks to the efforts of the nslu2-linux developers).

Unlike Unslung, Debian requires an external hard disk or a big USB stick to be successfully installed on the slug. The internal flash memory is not big enough to fit Debian. So basically the installation process boils down to flashing an installer on the flash memory, booting your slug from the flash and waiting about 3-4 hours while the installer completes the installation of the OS on you external storage. You can find a detailed guide here.

For the external storage I personally opted for a 8Gb USB stick, even if this choice has some drawbacks compared to using a hard disk. I decided to use a stick because on my previous installation I was bored by the noise produced by the HDD, because a USB stick should be less power demanding (and I am going to keep my slug on 24/7) and because anyway I don’t have a great requirement of disk space for my own applications.

So I eventually managed to install Debian Lenny 5.0.3 on my slug. And it runs just great, fast and with a low memory usage at boot. And if you decide to flash your own slug, I would recommend installing Debian. At the moment of this writing my slug has an uptime of 46 days with a memory usage of 13Mb (so it is not swapping), regardless the many services I installed on it (you can see the list below).

How to flash a new firmware

Thanks to the great work of the nslu2-linux community, flashing a custom firmware on your slug is a quite simple and straightforward process.

In order to install a new linux distro on your slug, you’ll need the following:

  • Another machine with an SSH client. Every linux box has one, and on Windows I use PuTTY which is a great SSH client.
  • A USB disk or USB stick.
  • A network connection between your machine and the slug.

Then, in a nutshell, these are the steps you need to follow to perform the flash:

  1. Choose whitch linux distro you want to install
  2. Download the firmware image of your choice from here
  3. Download a firmware update tool (you can use Sercomm Update Utility on Windows and upslug2 on linux)
  4. Restart your slug in upgrade mode
  5. Launch your firmware update tool and use it to flash the firmware image to your slug through the network
  6. Connect to the slug via telnet or SSH and complete the installation process on the external disk

This is only meant to be a general overwiew of the whole process. If you actually decide to flash your slug, I recommend following this guide for Debian or the readme fror Unslung. This is what I did and both my installations were successful.

What my slug is doing for me

my-slug

On the right you can see a picture of my own slug. I am using it mainly as a webserver for this website, but actually it is doing much more for me. Here is a non-comprehensive list of the services it is running:

  • OpenSSH server, which I use to connect to the slug through a secure shell and manage it, and not only for this purpose.
  • Samba server, useful to share the slug’s filesystem within my local network, making it accessible from my Windows machines. Right now the only mass storage attached to my slug is a 8Gb USB stick, thus there is not much to share, but it is useful anyway.
  • vsftpd, a fast and reliable FTP Server. Useful to access the slug disk from the Internet, even if the little disk space remains as a limitation.
  • lighttpd, a light and fast web server I use to publish my website.
  • ddclient, a Perl program I use to keep my dynamic DNS entries up to date (this is a must since I have a cheap DSL connection whith a dynamic IP address). This client is run as a cron job every 5 minutes, checks if my public IP address has changed since the previous check and in this case updates my dynamic DNS entries on a couple of free dynamic DNS services I subscribed to (I still have to decide which one suits best for me)
  • ntpdate, a computer program able synchronize and set system date and time by polling a pool of NTP servers. The slug system clock happens to be very inaccurate, and running this program once a day keeps the drift reasonable

Well, believe it or not, even with all these running services my slug is always up and running and at the moment it is using just 13Mb of RAM. Adopting lighttpd instead of apache web server proved to be a good move in the direction of saving memory usage. And abandoning the idea of a CMS with dynamically generated pages (like TWiki or Wordpress) for Jekyll was crucial in the direction of improving performances. Now I have a fast and light webserver that, thanks to Jekyll, is serving just a bunch of simple, static HTML pages. It works fast enough, and I am happy with this solution.

As already pointed out, the decison of using a USB stick instead of a disk on my system has some drawbacks, mainly related to the fact that the flash memory inside these devices only supports a limited number of writes. Thus, the first problem to face is swap: on a 32Mb RAM device running as a true computer you need some swap space (I have configured a 256Mb swap partition on my slug). Anyway, swapping means writing on the stick and so limiting the swappiness of the system is crucial to reduce the flash memory wear. For this reason, limiting RAM usage under 32Mb should also be a good way to increase the longevity of my slug. Anyway I am well aware that sooner or later my stick will fail, and so one of my next steps will be finding a good, quick and reliable backup system for my slug. If you decide to run your debian slug on a flash key, here you can find a number of other things you might want to do in order to reduce its wear.

What you can do with a slug

This is what I am doing with my slug, but I would like to point out that it can do much more. I read that some people use it as a:

  • mailserver
  • asterix VoIP server
  • torrent or emule downloader
  • iTunes or media server
  • backup server
  • print server
  • carputer

But these are just some of the most common uses. You can find many other examples here. Anyway, the slug is a linux box, then probably the limit to what you can do with it is just your imagination!

Sheeva Plug

sheeva-plug

The SheevaPlug is one of the first plug computers facing the market. This category groups low cost and low power network-attached servers which are fully enclosed in an AC power plug. SheevaPlug features a 1.2 GHz Marvell ARM-compatible CPU and 512 MB of RAM. It comes supplied with Ubuntu 9.04 ARM build, but you can install Debian on it. This device can be a good replacement to the NSLU2 due to its low price and better performance. So if you like the idea of a really low power server and you don’t already own a NSLU2, you could consider buying this device instead.