mirror of https://github.com/tLDP/LDP
283 lines
9.3 KiB
Plaintext
283 lines
9.3 KiB
Plaintext
<!doctype linuxdoc system>
|
|
|
|
<!-- Saving Space mini-HOWTO, by Guido Gonzato.
|
|
Tested with sgml-tools 1.0.6 -->
|
|
|
|
<article>
|
|
|
|
<title>Saving Space mini-HOWTO
|
|
|
|
<author>By Guido Gonzato, <url url="mailto:guido@ibogeo.df.unibo.it">
|
|
|
|
<date>v1.0.1, 7 April 1999
|
|
|
|
<abstract>
|
|
|
|
This mini-HOWTO gives you directions for squeezing your Linux installation
|
|
into the least possible space. It's particularly aimed at notebook users.
|
|
|
|
</abstract>
|
|
|
|
<toc>
|
|
|
|
|
|
<sect> Introduction
|
|
|
|
<p>
|
|
|
|
I've got a notebook I installed Linux on, beside Windows 95 that was
|
|
pre--installed. I squeezed the Windows partition to 500 Mb, making space for
|
|
a 240 Mb Linux one. Small though the latter may seem, I've managed to
|
|
install a fairly complete Linux system on it, based on Red Hat 4.1 and some
|
|
magic to save as much space as possible.
|
|
|
|
If you're in need for space, the indications you'll find in the following
|
|
sections will free up a considerable chunk of hard disk. The only caveat I'm
|
|
giving you is: don't blame me if something goes wrong! We'll be using a
|
|
couple of programs that worked fine for me, but are inherently dangerous.
|
|
You've been warned.
|
|
|
|
|
|
<sect> Software requirements
|
|
|
|
<p>
|
|
|
|
You need:
|
|
|
|
<itemize>
|
|
|
|
<item> a fully working Linux system (any version should be OK);
|
|
|
|
<item> the common <tt/gzip/ compression utility, or alternatively <tt/bzip2/
|
|
that you find on
|
|
<url url="ftp://sunsite.unc.edu:/pub/Linux/utils/compress">;
|
|
this tool compresses better than <tt/gzip/, but it's also a wee bit slower
|
|
and consumes a lot of memory;
|
|
|
|
<item> the <tt/upx/ executable compressor, whose home page is at
|
|
<url url="http://cdata.tvnet.hu/~ml/upx.html"> and
|
|
<url url="http://wildsau.idv.uni-linz.ac.at/mfx/upx.html">;
|
|
|
|
<item> the <tt/zlibc/ package, available on <url
|
|
url="ftp://sunsite.unc.edu:/pub/Linux/libs/compression">. It's
|
|
called <tt/zlibc-X.X.tar.gz/, where <tt/X.X/ is the latest version.
|
|
|
|
</itemize>
|
|
|
|
There are other executable compressors. One is <tt/gzexe/ (forget it), while
|
|
<tt/tcx/ was probably the best before <tt/upx/ became available; yet another
|
|
is <tt/tzx/, in theory better than <tt/tcx/. The thing is, it screwed
|
|
everything up when I tried it on a spare PC, though I'm not sure if I did
|
|
something wrong. You had better stick with <tt/upx/: it's reliable,
|
|
efficient, and very handy.
|
|
|
|
There are kernel patches that provide transparent file system compression a
|
|
la Stacker, but as of this writing none of them has yet a reputation for
|
|
stability and reliability. For safety's sake, steer clear.
|
|
|
|
|
|
<sect> The procedure
|
|
|
|
<p>
|
|
|
|
|
|
<sect1> Removing the Kernel Sources
|
|
|
|
<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.
|
|
|
|
I <em/don't/ 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!
|
|
|
|
If you do decide so, <em/do not/ remove the <file>include/linux</file> tree
|
|
unless you know you'll never compile applications on your machine.
|
|
|
|
|
|
<sect1> Pruning Out Applications
|
|
|
|
<p>
|
|
|
|
Now, decide which applications you <em/really/ need. Some may prove
|
|
redundant: for instance, are you sure you can't live without <tt/emacs/? You
|
|
could use <tt/jed/ instead.
|
|
|
|
It's up to you to decide what you want to keep. Some general points:
|
|
|
|
<itemize>
|
|
|
|
<item> <tt/gcc/ 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 <tt/f2c/ or <tt/g77/) programs; consider your needs before removing it.
|
|
Other compilers like <tt/lcc/ are fine, but not up to <tt/gcc/ level. I
|
|
suggest that you keep it;
|
|
|
|
<item> 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
|
|
<tt/xterm/, no 100 dpi fonts, and so on;
|
|
|
|
<item> 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 <tt/xdvi/ and <tt/ghostview/ is possible if you use <tt/dvitty/,
|
|
<tt/dvivga/ and some such. Eliminating the need for X11 dviware could even
|
|
make X11 redundant;
|
|
|
|
<item> games are never ``necessary''.
|
|
|
|
</itemize>
|
|
|
|
|
|
<sect1> Stripping Binaries
|
|
|
|
<p>
|
|
|
|
Let's start reducing the size of binaries. Move to <file>/usr/bin</file> and
|
|
issue the command
|
|
|
|
<tscreen><verb>
|
|
machine:/usr/bin# strip *
|
|
</verb></tscreen>
|
|
|
|
which will do away with symbols embedded in binaries. Repeat this
|
|
step in <file>/usr/X11R6/bin/</file> and other directories containing
|
|
executables you may have (don't forget to locate TeX's and <tt/gcc/'s
|
|
binaries), but <em/do not/ run it under <file>/sbin</file>,
|
|
<file>/bin</file>, or <file>/usr/sbin/</file> if you value your installation!
|
|
|
|
|
|
<sect1> Compressing with <tt/upx/
|
|
|
|
<p>
|
|
|
|
First, install <tt/upx/ and read its documentation. Then go to
|
|
<file>/usr/bin</file> and run it with the command <tt>upx *</tt>; it will
|
|
compress all executables, including suid ones (<tt/tcx/ wouldn't). Repeat
|
|
this step in other directories as seen above.
|
|
|
|
Remember to compress the executables whenever you install a new package!
|
|
|
|
|
|
<sect1> Gzipping around
|
|
|
|
<p>
|
|
|
|
There are lots of other files that can be compressed once and for all. Let's
|
|
start with <file>/usr/doc/</file>; move to this directory and issue the
|
|
command
|
|
|
|
<tscreen><verb>
|
|
machine:/usr/doc# find . -type f -exec gzip -9 {} \; 2> /dev/null
|
|
</verb></tscreen>
|
|
|
|
Remember to compress the docs whenever you install a new package!
|
|
|
|
Repeat this step in the directory containing the documentation for TeX (on
|
|
my system, <file>/usr/lib/texmf/texmf/doc/</file>. If you're
|
|
<em/really sure/, remove these directories altogether.
|
|
|
|
Now, install <tt/zlibc/ 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 <tt/uncompress.o/ that is what's
|
|
needed. Move it to <file>/usr/local/lib/</file> and add this line to your
|
|
<file>/etc/profile</file>:
|
|
|
|
<tscreen><verb>
|
|
export LD_ELF_PRELOAD=/usr/local/lib/uncompress.o
|
|
</verb></tscreen>
|
|
|
|
Now, you can compress with <tt/gzip/ 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.
|
|
|
|
|
|
<sect> A Real Life Example
|
|
|
|
<p>
|
|
|
|
This is what I got applying the above procedure to one of my machines.
|
|
Before the treatment, <tt/df/ reported I used 398,798 1024--blocks:
|
|
|
|
<itemize>
|
|
|
|
<item> I didn't remove the kernel sources and the kernel headers;
|
|
|
|
<item> I uninstalled several applications and all of the games, but I left
|
|
X11, X11 development, C and Fortran development, Tcl/Tk, networking tools,
|
|
and a few other standard applications. <tt/df/ reported 244,668 used blocks;
|
|
|
|
<item> I ran <tt/upx/ on <file>/usr/bin</file>,
|
|
<file>/usr/X11R6/bin</file>, <file>/usr/lib/texmf/bin/i586-linux</file>,
|
|
and <file>/usr/lib/gcc-lib/i386-linux/2.7.2.1</file>. 226,270 used blocks;
|
|
|
|
<item> I compressed the documentation under <file>/usr/doc</file> and
|
|
<file>/usr/lib/texmf/texmf/doc</file>: 198,745 used blocks.
|
|
|
|
</itemize>
|
|
|
|
To sum up, I started with 398,798 blocks and finished with 198,745. Think of
|
|
the stuff you can shove in those 200,000 spared blocks! I would have saved
|
|
even more if I had used <tt/bzip2/ instead of <tt/gzip/.
|
|
|
|
On average, if you are careful from the beginning and install only the
|
|
necessary applications, compressing executables and documents will save you
|
|
some 20 Mb. On a notebook, this can be a lifesaver.
|
|
|
|
|
|
<sect> The End
|
|
|
|
<p>
|
|
|
|
<sect1> Copyright
|
|
|
|
<p>
|
|
|
|
Unless otherwise stated, Linux HOWTO documents are copyrighted by their
|
|
respective authors. Linux HOWTO documents may be reproduced and distributed
|
|
in whole or in part, in any medium physical or electronic, as long as this
|
|
copyright notice is retained on all copies. Commercial redistribution is
|
|
allowed and encouraged; however, the author would like to be notified of any
|
|
such distributions.
|
|
|
|
All translations, derivative works, or aggregate works incorporating any
|
|
Linux HOWTO documents must be covered under this copyright notice. That is,
|
|
you may not produce a derivative work from a HOWTO and impose additional
|
|
restrictions on its distribution. Exceptions to these rules may be granted
|
|
under certain conditions; please contact the Linux HOWTO coordinator at the
|
|
address given below.
|
|
|
|
In short, we wish to promote dissemination of this information through as
|
|
many channels as possible. However, we do wish to retain copyright on the
|
|
HOWTO documents, and would like to be notified of any plans to redistribute
|
|
the HOWTOs.
|
|
|
|
If you have questions, please contact Tim Bynum, the Linux HOWTO
|
|
coordinator, at tjbinum@sunsite.unc.edu via email.
|
|
|
|
<sect1> Disclaimer
|
|
|
|
<p>
|
|
|
|
``Saving Space mini-HOWTO''was written by Guido Gonzato,
|
|
<url url="REMOVE_MEguido@ibogeo.df.unibo.it">.
|
|
|
|
This document is provided ``as is''. I put great effort into writing it as
|
|
accurately as I could, but you use the information contained in it at your
|
|
own risk. In no event shall I be liable for any damages resulting from the
|
|
use of this work.
|
|
|
|
Feedback is welcome. For any requests, suggestions, flames, etc., feel free
|
|
to contact me.
|
|
|
|
Enjoy Linux and life,
|
|
|
|
Guido <tt/=8-)/
|
|
|
|
</article>
|
|
|