Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

Small Linux

Introduction

For di­verse rea­sons I won't both­er ex­plain­ing, in­clud­ing stub­bor­ness wor­thy of a vasque mule, I faced the com­plete­ly un­nece­sary task of turn­ing a P75 with 800MB of disk space and 16MB of RAM in­to a mod­ern work­sta­tion ca­pa­ble of per­form­ing the usu­al tasks:

  • Graph­i­cal web nav­i­ga­tion.
  • E-­mail
  • MP3 au­dio
  • GNUTel­la
  • MPEG video re­pro­duc­tion (yes, re­al­ly ;-)

Plus what­ev­er crossed my mind while us­ing it. Of course I can't ask this tired piece of sil­i­con to be fast, but I won't set­tle for in­ad­e­quate per­for­mance. I am too poor to have a toy com­put­er, I want it to be use­ful, and do re­al work.

The Distribution

Be­cause of di­verse in­stal­la­tion is­sues (this is a note­book with a flop­py disk WITH­OUT lin­ux driver­s, and no op­ti­cal drive), I on­ly man­aged to in­stall De­bian. Since I like ap­t-get, I de­cid­ed to ig­nore oth­er prob­lems (not even a net­work con­fig tool????), and stick with it. I am us­ing test­ing, which is more up­to­date than sta­ble, but not as bro­ken as un­sta­ble.

I could prob­a­bly use much less mem­o­ry and disk us­ing an old dis­tri­bu­tion, like Slack­ware 96. Af­ter al­l, I used that on 16MB 486s, and I re­mem­ber it work­ing ok.

But... the brows­er would be Net­scape 2.0, and there were no mp3 play­er­s, so, fugged­haboutit.

Conclusion: Debian/Testing
Hardware Optimization

Ex­treme­ly im­por­tan­t: hd­parm. This tool con­fig­ures sev­er­al things about the hard disk (D­MA us­age, 32 bit trans­fer­ences, etc.) Since this is a se­nior com­put­er, most op­tions are not sup­port­ed, but with a lit­tle ef­fort I man­aged to in­crease the trans­fer speed from 1.7MBps to 4.7MBp­s, more or less what a semi-­mod­ern desk­top does with­out op­ti­miz­ing.

System startup

Ob­vi­ous­ly, if we are mem­o­ry starved, we should not waste it run­ning un­need­ed stuff. I ap­plied this rule with tal­iban-­wor­thy zeal.

Clean up /etc/inittab.

Why 6 vir­tu­al con­soles? Cut it to 2.

Graph­i­cal login? I am the on­ly user! Adding this line pro­vides a X ses­sion for us­er ralsi­na:

 
        sx:2:res­pawn:/bin/­su - ralsi­na -c ex­ec xinit >/de­v/null 2>&1
         
The use of ex­ec pre­vents the shell from run­ning af­ter X start­s, and use of xinit saves a process (s­tartx calls xinit any­way)

Services

On­ly klogd and ap­md are run­ning by de­fault.

Kernel

Ker­nel 2.2.20, hand built, stat­ic sup­port for all de­vices, no fire­wal­l, no PCI, no noth­ing, low la­ten­cy patched.

X Window System

XFree86 v3.3 us­es less mem­o­ry. But it did­n't work. So, I am us­ing 4.1.

To save mem­o­ry, you can re­move di­verse mod­ules. I avoid­ed xf­s, and made X it­self load the fonts.

Al­so, drop sup­port for Speedo and Type1 fonts, leav­ing on­ly TTF sup­port (I am us­ing the MS core fonts).Those two changes save about 2MB of RAM.

You can al­so re­move ex­ten­sions like XREN­DER, XVideo, etc. but that would in­vove re­com­pil­ing X. There is a tempt­ing op­tion called XTiny, used on PDAs and such, and maybe I will try that some­day.

I con­fig­ured the X serv­er for a 16bpp col­or depth. That saves mem­o­ry when cre­at­ing off­screen pixmap­s, since those are al­ways the depth of the screen. This saves much mem­o­ry when open­ing a web page, for ex­am­ple. It would be bet­ter to use 8bp­p, if on­ly it would­n't look so aw­ful.

You can al­so save disk space re­mov­ing pieces of X, such as xieper­f.

Window Manager

For­get KDE. For­get GNOME. For­get even Win­dow Mak­er. Think smal­l.

Some win­dow man­agers are smal­l, but they achieve their size by shift­ing func­tion­al­i­ty in­to helper app­s. I was look­ing for a WM that was smal­l, but al­lowed me to as­sign short­cut­s, had a menu to launch app­s, and some sort of taskbar. The sup­port for di­verse ap­plets would be a plus.

The an­swer: fluxbox. Us­es less than 500KB of RSS while do­ing all the above.

Applications
Shell

The shell is ac­tu­al­ly a rather large ap­p. bash us­es al­most 2MB of RAM!. So, I made ash the de­fault shel­l, which is 75% small­er.

Ob­vi­ous­ly ash is not a very nice in­ter­ac­tive shel­l, but if you make /bin/sh a sym­link to /bin/ash, the start­up scripts use it, and they be­come much faster.

No­tice that when you start an ap­pli­ca­tion from fluxbox, it starts a shel­l, the shell in turn, starts the ap­p. That shell stays idly in mem­o­ry for the life of the ap­pli­ca­tion!

To save that mem­o­ry, I made ash the us­er shel­l, and made the ter­mi­nal start bash ex­plicite­ly.

You can al­so save that mem­o­ry by con­fig­ur­ing the WM to start "ex­ec rxvt" in­stead of "rxvt", mak­ing rxvt re­place the shell in mem­o­ry, but that does­n't avoid the slow­er start­up time of bash.

In short, us­ing ash saves a lit­tle RAM, but it al­so makes the com­put­er feel a lot faster!

Terminal emulators

Load­ed each one, mea­sured each one, rxvt is by far the small­est.


MP3 player

mp3blaster. Smal­l, pow­er­ful, and us­ing the -2 and -8 op­tion­s, it us­es lit­tle CPU. No oth­er app could play with­out skip­ping.


MPEG Video Player

On­ly one works in this box: MPegTV. Share­ware, and the pret­ty ver­sion (mtv) us­es too much mem­o­ry. But thr CLI ver­sion, mtvp gives me 320x240 at 12f­p­s! As long as it is with­out sound, else it be­comes jerky.


Gnutella client

I tried one, it worked, I liked, it stays: mutel­la


Web browser

No con­test: Graph­i­cal Links un­der X. Fast, sup­ports many pages, a re­al gem. A pre­vi­ous ver­sion said "No con­test: Op­er­a". Well, that was then, this is now ;-)

Con­clu­sion: fluxbox, links, mutel­la, rxvt, MPegTV, ash.

Final Results

I will let my sys­tem do the talk­ing. Here is a reg­u­lar ses­sion, nav­i­gat­ing the we­b, down­load­ing with mutel­la, con­nect­ed to a serv­er via ssh, all with­in X ex­cept for a text ed­i­tor. No­tice how her I am us­ing Oper­a. That is be­cause it is old. Cur­rent­ly I use a cou­ple 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 de­tails on any­thing men­tioned on this ar­ti­cle, just post a com­men­t, or email me us­ing the link in this very page.

Roberto Alsina / 2006-04-04 16:18:

Comments for this story are here:

http://www.haloscan.com/com...


Contents © 2000-2024 Roberto Alsina