<?xml version="1.0"?>
<article id="smallmemory"><articleinfo><title>Small Memory mini-HOWTO</title><author><firstname>Todd</firstname><surname>Burgess</surname><affiliation><address format="linespecific"> <email>tburgess@uoguelph.ca</email> </address></affiliation></author><abstract><para>Describes how to run Linux on a system with a small amount of
				memory.</para></abstract><pubdate>2000-12-12</pubdate><revhistory><revision><revnumber>0.1</revnumber><date>2000-12-01</date><authorinitials>tb</authorinitials></revision></revhistory></articleinfo><sect1 id="introduction"><title>Introduction</title><para>Assuming buying more memory is out of the question there are many
			things you can do to tighten up memory usage in Linux. </para><para>Many Linux distributions out of the box are quite bloated from a
			memory perspective. They run more services and offer more features than most of
			us will ever need. By removing many of these services you can free up several
			megabytes of real memory.</para><para> My own system is a 486DX2-66 with 12MB of physical memory and 12MB
			of swap space. It has run Linux for the last 3 years quite happily, and
			hopefully it will run Linux for several more years. :)</para></sect1><sect1 id="linuxkernel"><title>Linux Kernel</title><para>All the Linux kernels which come with distributions are quite
			bloated and contain more features than any of us will ever need or use. If you
			have not re-compiled your own kernel, it is highly recommended that you do so.
			How to re-compile a kernel is beyond the scope of this document, but many
			excellent Linux books and guides cover this subject in intimate detail.</para><para>If you do re-compile your kernel, remember to put in no more
			features than you need. For instance: how many of you include PLIP support in
			your kernel? How many of you who include it actually use it? Smaller kernels
			require less time to load, use less memory, and use less CPU cycles. </para><para>Another thing is modules. I personally do not use them because I
			found them to be a cumbersome. If you use them and like them then they can help
			to relieve "kernel bloat." </para></sect1><sect1 id="vconsoles"><title>Virtual Consoles</title><para>VCs are a great way to free up memory. Most Linux distributions run
			about 6 of them out of the box. On average running 6 VCs requires about 4MB of
			memory. Removing a couple of them can free up a couple MBs of memory. Most
			users can get away with running only 3 or 4 VCs. How many you choose to remove
			is a matter personal preference. Just remember that the fewer you run, the more
			memory your applications will have to run. </para><para>The file which outlines how many VCs get loaded is
			<filename moreinfo="none">/etc/inittab</filename>. In order to remove VCs: </para><orderedlist inheritnum="ignore" continuation="restarts"><listitem><para>Load <filename moreinfo="none">/etc/inittab</filename> in a text
					editor.</para></listitem><listitem><para>Look for a line which looks like the following line (the key
					feature being a line which starts with c1): </para><programlisting format="linespecific">c1:12345:respawn:/sbin/getty tty1 38400
					linux</programlisting><para>Start at the highest number (i.e. c6) and comment it out by
					inserting a '#' in the first row. Repeat this step as many times as needed.
					Remember every line you comment out is one less VC running. </para></listitem><listitem><para>Re-boot the system for your changes to take effect. </para></listitem></orderedlist></sect1><sect1 id="daemons"><title>Daemons</title><para>Many Linux distributions run daemons most of us will never use.
			Most of these daemons are loaded by scripts. Where these scripts are and what
			they are called depends on your Linux distribution. Slackware set-up scripts
			are buried in <filename moreinfo="none">/etc/rc.d/rc.*</filename>. </para><para>Before you proceed, a knowledge of Unix shell script programming
			would be a definite asset. However, if you have no experience writing Unix
			shell scripts, what follows is probably the quickest introduction to shell
			script programming ever written.</para><para>Take the following shell script:</para><programlisting format="linespecific">#!/bin/sh echo "hello world" 
			#echo "good bye cruel world"</programlisting><para>The previous code will echo the string "hello world". Shell scripts
			must contain the the line 
			<programlisting format="linespecific">"#!/bin/sh"</programlisting> at the very top line.
			After that every line is executed as if you had typed it at the keyboard (think
			of shell scripts as nothing more then glorified keyboard macros).</para><para>Lines which begin with a '#' are said to be commented out because
			they do not get executed by the shell. Most start-up scripts when they load
			daemons look like: </para><programlisting format="linespecific">if somecondition 
		        do something 
				  fi</programlisting><para>What you want to do is comment out every line starting with the <programlisting format="linespecific">if</programlisting>
			statement and ending with the <programlisting format="linespecific">fi</programlisting> statement. </para><para>If you want to find where a daemon is loaded,
			search the start-up scripts for the name of the daemon. If I wanted to find
			where <application moreinfo="none">inetd</application> is loaded in Slackware I would do the following: 
			<screen format="linespecific">$ cd /edt/rc/d $grep -n inetd rd.*</screen> </para><sect2><title><application moreinfo="none">inetd</application></title><para><application moreinfo="none">inetd</application> allows people to do things like <command moreinfo="none">telnet</command>, <command moreinfo="none">ftp</command>, and send <command moreinfo="none">talk</command>
				requests to your machine. If you never use your system as a server or need to
				access any of its services remotely you can remove <application moreinfo="none">inetd</application>. </para></sect2><sect2><title><application moreinfo="none">lpd</application></title><para><application moreinfo="none">lpd</application> is used to print files on your printer using the 
				<command moreinfo="none">lpr</command> command. If you never print on your Linux
				box you can remove <application moreinfo="none">lpd</application>. If, however, you own a HP Deskjet ent printer and
				would like to print, I highly recommend the package I put together called
				dj-printcap which is available at:</para><para> 
				<ulink url="ftp://ftp.redhat.com/pub/redhat/redhat-4.2/i386/RedHat/RPMS/dhcpcd-0.6-2.i386.rpm">ftp://sunsite.unc.edu/pub/Linux/system/Printing/dj-printcap.tar.gz</ulink>
				</para></sect2><sect2><title><application moreinfo="none">nfsd</application> and <application moreinfo="none">mountd</application></title><para>These two daemons are used to run an NFS server. If you never use
				your Linux system as an NFS server you can safely remove these two daemons.
				</para></sect2><sect2><title><application moreinfo="none">portmap</application></title><para>The <application moreinfo="none">portmap</application> daemon is used to handle RPC services. If you do not
				run an NFS server or any other RPC programs you can remove <application moreinfo="none">portmap</application>. </para></sect2><sect2><title><application moreinfo="none">sendmail</application></title><para><application moreinfo="none">sendmail</application> is another daemon which requires a fair bit of memory.
				If you never use your Linux box as a relay for sending e-mail or you never
				receive mail on your Linux box, you can probably remove <application moreinfo="none">sendmail</application>. If you do send
				e-mail from your Linux box most e-mail clients can be set-up to send e-mail
				from another mail server.</para></sect2><sect2><title>others</title><para>There may be other daemons your system starts up which you do
				not need. Remove what you feel you have to. Two daemons which you must run are
				<application moreinfo="none">syslogd</application> and <application moreinfo="none">klogd</application>. </para></sect2></sect1><sect1 id="conclusion"><title>Conclusions</title><para>The previous discussion illustrates the steps I took to tighten up
			my memory usage on my Linux box. Hopefully I have provided you with some
			insight into what you can do with your Linux box to conserve memory. Good luck
			and happy hacking!</para></sect1></article>

