old-www/HOWTO/Saving-Space-3.html

137 lines
4.9 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
<TITLE>Saving Space mini-HOWTO : The procedure</TITLE>
<LINK HREF="Saving-Space-4.html" REL=next>
<LINK HREF="Saving-Space-2.html" REL=previous>
<LINK HREF="Saving-Space.html#toc3" REL=contents>
</HEAD>
<BODY>
<A HREF="Saving-Space-4.html">Next</A>
<A HREF="Saving-Space-2.html">Previous</A>
<A HREF="Saving-Space.html#toc3">Contents</A>
<HR>
<H2><A NAME="s3">3. The procedure</A></H2>
<P>
<P>
<P>
<H2><A NAME="ss3.1">3.1 Removing the Kernel Sources</A>
</H2>
<P>
<P>The kernel sources take up more than 20 Mb, and you may want to remove them.
If so, I suggest that you compile a new kernel that is tailored to your
machine once and for all, then get rid of the sources. Take care, though.
<P>I <EM>don't</EM> recommend that you remove the kernel sources unless you are
sure that your machine is properly configured. Besides, you need the kernel
#includes to compile C programs. Think twice!
<P>If you do decide so, <EM>do not</EM> remove the include/linux tree
unless you know you'll never compile applications on your machine.
<P>
<P>
<H2><A NAME="ss3.2">3.2 Pruning Out Applications</A>
</H2>
<P>
<P>Now, decide which applications you <EM>really</EM> need. Some may prove
redundant: for instance, are you sure you can't live without <CODE>emacs</CODE>? You
could use <CODE>jed</CODE> instead.
<P>It's up to you to decide what you want to keep. Some general points:
<P>
<UL>
<LI> <CODE>gcc</CODE> is a fairly large package. It's needed to recompile the
kernel and all the applications for which there are no pre--built Linux
binaries. It's also needed, of course, if you write your own C or Fortran
(with <CODE>f2c</CODE> or <CODE>g77</CODE>) programs; consider your needs before removing it.
Other compilers like <CODE>lcc</CODE> are fine, but not up to <CODE>gcc</CODE> level. I
suggest that you keep it;
</LI>
<LI> X11 is awfully large, but it's a nice thing to have. If you decide
you can't give it up, at least try to make do with as little as necessary:
only the right X server, one simple window manager, only one
<CODE>xterm</CODE>, no 100 dpi fonts, and so on;
</LI>
<LI> TeX and accompanying packages are very large indeed. Giving up LaTeX
and sticking to plain TeX saves a lot of space; giving up X11 previewers
like <CODE>xdvi</CODE> and <CODE>ghostview</CODE> is possible if you use <CODE>dvitty</CODE>,
<CODE>dvivga</CODE> and some such. Eliminating the need for X11 dviware could even
make X11 redundant;
</LI>
<LI> games are never ``necessary''.
</LI>
</UL>
<P>
<P>
<H2><A NAME="ss3.3">3.3 Stripping Binaries</A>
</H2>
<P>
<P>Let's start reducing the size of binaries. Move to /usr/bin and
issue the command
<P>
<BLOCKQUOTE><CODE>
<PRE>
machine:/usr/bin# strip *
</PRE>
</CODE></BLOCKQUOTE>
<P>which will do away with symbols embedded in binaries. Repeat this
step in /usr/X11R6/bin/ and other directories containing
executables you may have (don't forget to locate TeX's and <CODE>gcc</CODE>'s
binaries), but <EM>do not</EM> run it under /sbin,
/bin, or /usr/sbin/ if you value your installation!
<P>
<P>
<H2><A NAME="ss3.4">3.4 Compressing with <CODE>upx</CODE></A>
</H2>
<P>
<P>First, install <CODE>upx</CODE> and read its documentation. Then go to
/usr/bin and run it with the command <CODE>upx *</CODE>; it will
compress all executables, including suid ones (<CODE>tcx</CODE> wouldn't). Repeat
this step in other directories as seen above.
<P>Remember to compress the executables whenever you install a new package!
<P>
<P>
<H2><A NAME="ss3.5">3.5 Gzipping around</A>
</H2>
<P>
<P>There are lots of other files that can be compressed once and for all. Let's
start with /usr/doc/; move to this directory and issue the
command
<P>
<BLOCKQUOTE><CODE>
<PRE>
machine:/usr/doc# find . -type f -exec gzip -9 {} \; 2> /dev/null
</PRE>
</CODE></BLOCKQUOTE>
<P>Remember to compress the docs whenever you install a new package!
<P>Repeat this step in the directory containing the documentation for TeX (on
my system, /usr/lib/texmf/texmf/doc/. If you're
<EM>really sure</EM>, remove these directories altogether.
<P>Now, install <CODE>zlibc</CODE> and compile it. If your system is like mine, the
compilation process will abort complaining about a missing (static) libc.
Never mind; you'll find a file called <CODE>uncompress.o</CODE> that is what's
needed. Move it to /usr/local/lib/ and add this line to your
/etc/profile:
<P>
<BLOCKQUOTE><CODE>
<PRE>
export LD_ELF_PRELOAD=/usr/local/lib/uncompress.o
</PRE>
</CODE></BLOCKQUOTE>
<P>Now, you can compress with <CODE>gzip</CODE> not only documentation, but also data
files: the applications that use them will be able to use them nonetheless.
In theory, the trick should work with most applications, but in practice
your degree of success may vary. Mine was rather unimpressive.
<P>
<P>
<HR>
<A HREF="Saving-Space-4.html">Next</A>
<A HREF="Saving-Space-2.html">Previous</A>
<A HREF="Saving-Space.html#toc3">Contents</A>
</BODY>
</HTML>