--- category: '' date: 2003/03/02 18:13 description: '' link: '' priority: '' slug: '4' tags: linux title: Small Linux type: text updated: 2003/03/02 18:13 url_type: '' --- .. raw:: html

Introduction

For diverse reasons I won't bother explaining, including stubborness worthy of a vasque mule, I faced the completely unnecesary task of turning a P75 with 800MB of disk space and 16MB of RAM into a modern workstation capable of performing the usual tasks:

Plus whatever crossed my mind while using it. Of course I can't ask this tired piece of silicon to be fast, but I won't settle for inadequate performance. I am too poor to have a toy computer, I want it to be useful, and do real work.

The Distribution

Because of diverse installation issues (this is a notebook with a floppy disk WITHOUT linux drivers, and no optical drive), I only managed to install Debian. Since I like apt-get, I decided to ignore other problems (not even a network config tool????), and stick with it. I am using testing, which is more uptodate than stable, but not as broken as unstable.

I could probably use much less memory and disk using an old distribution, like Slackware 96. After all, I used that on 16MB 486s, and I remember it working ok.

But... the browser would be Netscape 2.0, and there were no mp3 players, so, fuggedhaboutit.

Conclusion: Debian/Testing

Hardware Optimization

Extremely important: hdparm. This tool configures several things about the hard disk (DMA usage, 32 bit transferences, etc.) Since this is a senior computer, most options are not supported, but with a little effort I managed to increase the transfer speed from 1.7MBps to 4.7MBps, more or less what a semi-modern desktop does without optimizing.

System startup

Obviously, if we are memory starved, we should not waste it running unneeded stuff. I applied this rule with taliban-worthy zeal.

Clean up /etc/inittab.

Why 6 virtual consoles? Cut it to 2.

Graphical login? I am the only user! Adding this line provides a X session for user ralsina:

            sx:2:respawn:/bin/su - ralsina -c exec xinit >/dev/null 2>&1 
            
The use of exec prevents the shell from running after X starts, and use of xinit saves a process (startx calls xinit anyway)

Services

Only klogd and apmd are running by default.

Kernel

Kernel 2.2.20, hand built, static support for all devices, no firewall, no PCI, no nothing, low latency patched.

X Window System

XFree86 v3.3 uses less memory. But it didn't work. So, I am using 4.1.

To save memory, you can remove diverse modules. I avoided xfs, and made X itself load the fonts.

Also, drop support for Speedo and Type1 fonts, leaving only TTF support (I am using the MS core fonts).Those two changes save about 2MB of RAM.

You can also remove extensions like XRENDER, XVideo, etc. but that would invove recompiling X. There is a tempting option called XTiny, used on PDAs and such, and maybe I will try that someday.

I configured the X server for a 16bpp color depth. That saves memory when creating offscreen pixmaps, since those are always the depth of the screen. This saves much memory when opening a web page, for example. It would be better to use 8bpp, if only it wouldn't look so awful.

You can also save disk space removing pieces of X, such as xieperf.

Window Manager

Forget KDE. Forget GNOME. Forget even Window Maker. Think small.

Some window managers are small, but they achieve their size by shifting functionality into helper apps. I was looking for a WM that was small, but allowed me to assign shortcuts, had a menu to launch apps, and some sort of taskbar. The support for diverse applets would be a plus.

The answer: fluxbox. Uses less than 500KB of RSS while doing all the above.

Applications

Shell

The shell is actually a rather large app. bash uses almost 2MB of RAM!. So, I made ash the default shell, which is 75% smaller.

Obviously ash is not a very nice interactive shell, but if you make /bin/sh a symlink to /bin/ash, the startup scripts use it, and they become much faster.

Notice that when you start an application from fluxbox, it starts a shell, the shell in turn, starts the app. That shell stays idly in memory for the life of the application!

To save that memory, I made ash the user shell, and made the terminal start bash explicitely.

You can also save that memory by configuring the WM to start "exec rxvt" instead of "rxvt", making rxvt replace the shell in memory, but that doesn't avoid the slower startup time of bash.

In short, using ash saves a little RAM, but it also makes the computer feel a lot faster!

Terminal emulators

Loaded each one, measured each one, rxvt is by far the smallest.


MP3 player

mp3blaster. Small, powerful, and using the -2 and -8 options, it uses little CPU. No other app could play without skipping.


MPEG Video Player

Only one works in this box: MPegTV. Shareware, and the pretty version (mtv) uses too much memory. But thr CLI version, mtvp gives me 320x240 at 12fps! As long as it is without sound, else it becomes jerky.


Gnutella client

I tried one, it worked, I liked, it stays: mutella


Web browser

No contest: Graphical Links under X. Fast, supports many pages, a real gem. A previous version said "No contest: Opera". Well, that was then, this is now ;-)

Conclusion: fluxbox, links, mutella, rxvt, MPegTV, ash.

Final Results

I will let my system do the talking. Here is a regular session, navigating the web, downloading with mutella, connected to a server via ssh, all within X except for a text editor. Notice how her I am using Opera. That is because it is old. Currently I use a couple less MB.

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.8 1304 124 ? S 10:06 0:04 init
root 2 0.0 0.0 0 0 ? SW 10:06 0:01 [kflushd]
root 3 0.0 0.0 0 0 ? SW 10:06 0:02 [kupdate]
root 4 0.2 0.0 0 0 ? SW 10:06 0:37 [kswapd]
root 5 0.0 0.0 0 0 ? SW 10:06 0:00 [keventd]
root 133 0.0 0.0 1632 0 ? SW 10:06 0:01 [klogd]
root 136 0.0 0.0 1292 0 ? SW 10:06 0:03 [apmd]
root 181 0.0 0.0 1420 0 ? SW 10:06 0:00 [cardmgr]
root 190 0.0 0.7 1684 112 ? S 10:06 0:00 /usr/sbin/cron
root 425 0.0 0.0 2748 0 ? SW 10:24 0:09 [sshd]
ralsina 611 0.0 0.0 1368 0 tty1 SW 10:47 0:01 [ash]
ralsina 827 0.0 0.0 2220 0 ? SW 11:09 0:00 [xinit]
root 829 2.6 12.1 17556 1780 ? S< 11:09 6:29 X :0
ralsina 832 0.3 2.2 3416 324 ? S 11:09 0:47 /usr/bin/fluxbox
ralsina 834 0.0 1.6 2512 236 ? S 11:09 0:01 wmtuxtime
root 1235 0.0 0.0 1476 0 ? SW 11:50 0:00 [pump]
ralsina 1236 0.0 1.0 2560 148 ? S 11:50 0:09 rxvt -e ash
ralsina 1241 0.0 0.0 1352 0 pts/0 SW 11:50 0:00 [ash]
ralsina 1242 0.0 1.2 2940 180 pts/0 S 11:50 0:11 ssh master.kde.org
ralsina 1413 0.0 0.0 2576 0 ? SW 12:53 0:04 [rxvt]
ralsina 1414 0.0 0.0 1352 0 pts/2 SW 12:53 0:00 [ash]
ralsina 1415 0.0 19.3 16124 2844 pts/2 S 12:53 0:00 mutella
ralsina 1416 0.0 19.3 16124 2844 pts/2 S 12:53 0:00 mutella
ralsina 1417 0.0 19.3 16124 2844 pts/2 S 12:53 0:04 mutella
ralsina 1418 0.0 19.3 16124 2844 pts/2 S 12:53 0:04 mutella
ralsina 1419 4.7 19.3 16124 2844 pts/2 S 12:53 6:26 mutella
ralsina 1420 0.3 19.3 16124 2844 pts/2 S 12:56 0:26 mutella
ralsina 1500 0.0 0.0 1352 0 ? SW 13:21 0:00 [sh]
ralsina 1501 3.2 16.0 16420 2364 ? S 13:21 3:31 /usr/X11R6/bin/opera
ralsina 1503 0.0 16.0 16420 2364 ? S 13:22 0:00 /usr/X11R6/bin/opera
ralsina 1721 0.0 0.0 1352 0 tty1 SW 14:22 0:00 [sfte]
ralsina 1733 1.0 4.1 2816 612 tty1 S 14:22 0:30 /tmp/sfte linux16.txt
ralsina 1742 3.1 3.0 1364 452 tty2 S 15:10 0:00 -ash
ralsina 1744 0.0 7.5 2968 1108 tty2 R 15:10 0:00 ps aux

total used free shared buffers cached
Mem: 14708 14144 564 4644 816 5304
-/+ buffers/cache: 8024 6684
Swap: 47992 18880 29112

I HAVE FREE MEMORY ;-)

If you have tips to share, or want to know details on anything mentioned on this article, just post a comment, or email me using the link in this very page.