8.1. Recycling of Hardware

The commercial computer market is largely driven by vendors seeking to sell new hardware and software. There is no commercial marketing benefit in promoting reuse.

Hence Linux doesn't require big hardware, it's very useful if you like or need to use old and small hardware.

8.1.1. Supported CPU Families

Linux runs on Intel-compatible processors (starting from the 386) and compatible processors by AMD, Cyrix and others. It also supports a long list of 32 and 64 bit processors. The whole list can be found in the arch directory in the Linux kernel sources.

The ARM architecture is a fast AND low-power alternative, used in a great number of embedded systems (Linux and others). See the ARM Linux Project for a wealth of Linux resources for ARM.

Linux is also supported on small, cheap and low power processors with no Memory Management Unit (MMU), provided they are 32 bit ones. See the uClinux project for details.

Mainstream Linux requires at least a 32 bit processor and doesn't support any 16 bit ones and will never do. However, there are separate efforts from the ELKS project to reuse Linux code for the 286 CPU family.

On platforms supported by Linux, or even on some 16 bit processors, you may also use the eCos operating system. This is another free, POSIX compatible operating system targeting very small devices (possibly with real-time requirements).

If you like, you may use Minix, one of the predecessors of Linux. Minix supports 8088 to 286 with as little as 640K memory.

8.1.2. Linux Applications for Old Computers

8.1.2.1. RULE

Hardware is only as old as the software it runs. RULE wants to make modern Free Software useable even on 5 or more years old machines, on which current Linux distributions won't install or run too slowly.

8.1.2.2. ISDN Router

ISDN Router allows you to convert old hardware into a secure masquerading ISDN router, including caching nameserver, IP Port Forwarding, and on-demand channel bundling. The system fits onto a single disk, and users can change the configuration through a simple menu-based system (on the console or over telnet) and store it permanently on the disk.

8.1.2.3. Linux LiveCD Router

Linux LiveCD Router allows you to share and firewall your broadband connection and use WiFi. It works with DSL, cable modem, T1, and dial-up connections and supports inexpensive hardware such as USB and PCMCIA WiFi and ethernet cards. Hardware requirements: One dedicated computer with the following minimum specifications: 486 Processor, 16 MBytes of RAM, 2X CDRom reader, floppy drive, 1 or 2 ethernet cards. NO hard disk! Optionally a WIFI card.

8.1.2.4. FreeS/WAN

Linux FreeS/WAN provides IPSEC (IP Security, which is both encryption and authentication) kernel extensions and an IKE (Internet Key Exchange, keying and encrypted routing daemon) as well as various rc scripts and documentation. This lets a bright Linux sysadmin build VPN's gateways out of even old 584 and 486 PC Clone boxes. The 1.00 version is known to inter-operate with other IPSEC and IKE system already deployed by other vendors such as OpenBSD.

8.1.2.5. Print Server

A common use for an old computer is running a print server on it.

8.1.3. Small Linux Distributions for Old Computers

See Wikipedia for a longer list of small Linux distributions.

8.1.4. Dealing with Limited Resources or Tuning the System

This chapter is taken from my Linux-Mobile-Guide - A Guide for Laptops, PDAs and Mobile Phones.

8.1.4.1. Related HOWTOs

  • Small-Memory-HOWTO Describes how to run Linux on a system with a small amount of memory.

8.1.4.2. Introduction

To deal with limited space, memory, CPU speed and battery power, I have written this chapter.

8.1.4.3. Small Space

8.1.4.3.1. Introduction

There are different types of techniques to gain more disk space, such as sharing of space, freeing unused or redundant space, filesystem tuning and compression. Note: some of these techniques use memory instead of space. As you will see, there are many small steps necessary to free some space.

8.1.4.3.2. Techniques

  • Stripping: Though many distributions come with stripped binaries today it is useful to check this. For details see man strip. To find every unstripped file you can use the file command or more convenient the tool findstrip (find it in the Debian perforate package) . Attention: don't strip libraries, sometimes the wrong symbols are removed due to a bad programming technique.

    A recommendation from Russell Marks <rus at beeb.net>:

    These days a lot of people compile with -g, which I find a bit annoying (though AFAIK this only loses you disk space, in practice).

    strip has a --strip-debug option which doesn't strip symbols, but does still get rid of the debugging stuff. This is almost as good, in many cases, and it's ok to use it on libraries. As it happens, I recently got SuSE 6.3, so I can give you a live example:
    
bash-2.03# cd /lib
    bash-2.03# ls -l libc.so.6
    -rwxr-xr-x   1 root     root      4223971 Nov  6 16:22 libc.so.6
    bash-2.03# strip --strip-debug libc.so.6
    bash-2.03# ls -l libc.so.6
    -rwxr-xr-x   1 root     root      1200355 Dec  8 00:13 libc.so.6
    

  • Sparse files: in the case when files contain blocks with only null characters, these blocks can be replaced by lseek command calls, saving space. Applications (and not the operating system) are responsible for creating or handling such files in a correct way. For example, both the tar and cp commands have options for handling sparse files in a correct way. See the this page for more details and for a sparse command to create such files. In Debian, you can also use the zum command from the perforate package.

  • Remove Odd Files and Duplicates: Check your system for core files, emacs recovery files <#FILE#> vi recovery files <FILE>.swp, RPM recovery files <FILE>.rpmorig and patch recovery files. Find duplicates, you may try finddup. Choose a system to name your backup, temporary and test files, e.g. with a signature at the end.

  • Clean Temporary Files: , e.g. /tmp, there is even a tool tmpwatch.

  • Shorten the Log Files: usually the files in /var/log. There are some nice helpers for this task around, e.g. savelog .

  • Remove Files: Remove files which are not "necessary" under all circumstances such as man pages, documentation /usr/doc and sources e.g. /usr/src .

  • Unnecessary Libraries: You may use the binstats package to find unused libraries (Thanks to Tom Ed White).

  • Filesystem: Choose a filesystem which treats disk space economically e.g. rsfs aka Reiser Filesystem. Tune your filesystem e.g. tune2fs. Choose an appropriate partition and block size.

  • Reduce Kernel Size: Either by using only the necessary kernel features and/or making a compressed kernel image bzImage.

  • Compressed read-write filesystems:

    - There was a project to add compression support to ext2 filesystems: e2compr. This project has a very limited usefulness as it is currently inactive and only supports very old 2.4 and 2.6 kernel versions. No chance to get a working patch on the latest 2.4 and 2.6 releases.

    - Fortunately, a very serious solution exists in the Reiser4 filesystem which includes a compression plugin. Using compression is even reported to be faster than not using it. Actual results should of course vary with the CPU and disk speed, and results might be disappointing on old machines.

  • Compressed read-only filesystems

    - The idea is store parts of the system (typically executables and libraries through the /bin, /sbin and /usr directories) in a separate, compressed and read-only filesystem. This is great for saving space and for protecting the system from extern attacks. However, the constraint is that software upgrades can no longer be done when the filesystem is mounted. The whole filesystem contents must be rebuilt and replaced at once.

    - CramFS was the first implemented solution, used by many embedded system makers. Though still maintained, it is dramatically outperformed by SquashFS.

    - SquashFS is the solution everyone should use now. Unlike CramFS, it has no limitations on filesystem and file size, and it achieves much better compression and read speed (up to 5 times!). On slow storage (like USB flash drives), replacing ext2 with SquashFS resulting in a 50% reduction on system boot time (observed in a Linux demo developped by Free Electrons).

  • Partition Sharing: You may share swap-space (see Swap-Space-HOWTO) or data partitions between different OS (see mount).

  • C library: use uClibc instead of the default GNU C library aka glibc. It takes approximately 400 KB instead of 1700 (glibc). It used by many embedded Linux projects as well as by several tiny Linux distributions. It should satisfy most needs, as the whole Debian 3.0 was ported to it. Caution: if you replace the C library, all applications also need to be recompiled with a dedicated gcc toolchain.

  • Busybox - A toolbox implementing most Unix commands. It takes at most 500 KB instead of approximately 10-30 MB with GNU implementations! It is used by almost all embedded Linux projects and small Linux distros. Most commands are implemented, even vi, wget, a dhcp server and client, and even a http server sufficient for most needs. Even if some rare command options are not implemented, even an experienced Unix user hardly makes the difference with GNU commands!

  • Kernel: If your needs are fitted with an older kernel version, you can save some space.

    However, with old kernels, you will miss cool features (such as real-time preemption, making your system much more responsive) and support for recent peripherals. It is true that the Linux kernel accumulated bloat over the years: more features, support for more special cases... Now that Linux is taking an increasingly dominant place in embedded systems, work is being done to control the kernel size. The LinuxTiny project releases a set of patches to the Linux kernel sources. In the Configure Standard Kernel Features for Small Systems kernel configuration section, you can unselect features you do not need in a simple computer. The minimum compressed size you can achieve for a Linux 2.6 kernel for a simple PC is approximately 350 KB. Note that more and more LinuxTiny changes are now available in the standard Linux kernel (no patching necessary).

    With the latest kernel releases, you may also try the real-time preemption patches from Ingo Molnar. When full preemption is enabled, it adds unprecedented responsiveness to the Linux kernel. The latency is much reduced, suitable for real real-time systems (less than 100 us!). It is definitely worth trying on old systems to give them a new youth and improve the user experience!

  • GUI: Avoid as much Graphical User Interface (GUI) as possible.

  • Tiny Distributions: There are some distributions available which fit from one 3.5" floppy to 10MB disk space and fit for small memories, too. See Laptop-HOWTO

8.1.4.4. Harddisk Speed

Use the tool hdparm to set up better harddisk performance. Though I have seen laptop disk enabled with stripping, I can't see a reason to do so, because IMHO aka RAID0 stripping needs at least to different disks to increase performance.

8.1.4.5. Small Memory

8.1.4.5.1. Related HOWTOs

8.1.4.5.2. Techniques

Check the memory usage with free and top.

You may also reduce the kernel size as much as possible by removing any feature which is not necessary for your needs and by modularizing the kernel as much as possible.

Also you may shutdown every service or daemon which is not needed, e.g. lpd, mountd, nfsd and close some virtual consoles. Please see the Small-Memory-mini-HOWTO for details.

And of course use swap space, when possible.

If possible you may use the resources of another machine, for instance with X, VNC or even telnet. For more information on Virtual Network Computing (VNC), see VNC .

8.1.4.6. Low CPU Speed

You may want to overdrive the CPU speed but this can damage your hardware and I don't have experience with it. For some examples look at Adorable Toshiba Libretto - Overclocking.

8.1.4.7. Tiny Applications and Distributions

A small collection yet, but I'm looking for more information.

  • BOA - "Lightweight and High Performance WebServer. boa is a single-tasking HTTP server. That means that unlike traditional web servers, it does not fork for each incoming connection, nor does it fork many copies of itself to handle multiple connections. It internally multiplexes all of the ongoing HTTP connections, and forks only for CGI programs (which must be separate processes). Preliminary tests show boa is capable of handling several hundred hits per second on a 100 MHz Pentium."

  • Low Bandwidth X - Alan Cox in LINUX REDUX February 1998: " ... (Differential X Protocol Compressor - Dxpc) is the alternative most people prefer. These systems act as proxy X11 servers and compress datastreams by well over 50 percent for normal requests, often reaching a reduction to 25 percent of the original bandwidth usage. With dxpc, X windows applications are quite usable over a 28.8 modem link or across the Internet."

  • Blackbox - "This is a window manager for X. Ixt is similar in many respects to such popular packages as Window Maker, Enlightenment, and FVWM2. You might be interested in this package if you are tired of window managers that are a heavy drain on your system resources, but you still want an attractive and modern-looking interface."

  • screen - Tiny but powerful console manager. John M. Fisk <fiskjm at ctrvax.vanderbilt.edu> in LINUX GAZETTE : "It's a GUI, GUI, GUI, GUI world! " - or so the major OS manufacturers would have you belief. Truth is, that while this is increasingly the case, there are times when the command line interface (CLI) is still a very good choice for getting things done. It's fast, generally efficient, and is a good choice on memory or CPU constrained machines. And don't forget that there are still a lot of very nifty things that can be done at the console." "screen is a full-screen window manager that multiplexes a physical terminal between several processes, typically interactive shells. Each virtual terminal provides the functions of the DEC VT100 terminal and, in addition, several control functions from the ANSI X3.64 (ISO 6429) and ISO 2022 standards (e.g., insert/delete line and support for multiple character sets). Real multiuser support, split screen support, hardstatus emulation support, configurable window seperator and hardstatus strings, permanent window seperator, many new escapes, logfile timestamps and flush timeout, optional builtin telnet, optional Braille support, support for history compaction."

  • tinyirc - "A tiny, stripped down IRC Client. Doesn't have most of the more advance commands in the ircII family of IRC Clients, nor does it have any color, but it works, and it's tiny."

  • tinyproxy - "is a lightweight HTTP proxy designed to do the job with a minimum of system resource use. It's ideal for small networks where a larger HTTP proxy such as squid might be overkill or a security risk. This simplicity also makes tinyproxy an ideal candidate for customization - it takes very little time to read and understand the tinyproxy source, and thus you can start adding your own desired features on short order."

Actually, with the progress of Linux in embedded systems, countless lightweight applications now exist. A presentation from Free Electrons tries to list the most popular ones.