265 lines
5.5 KiB
HTML
265 lines
5.5 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>Design</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
|
|
REL="HOME"
|
|
TITLE="Pocket Linux Guide"
|
|
HREF="index.html"><LINK
|
|
REL="UP"
|
|
TITLE="Saving Space"
|
|
HREF="phase2.html"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="Analysis"
|
|
HREF="x360.html"><LINK
|
|
REL="NEXT"
|
|
TITLE="Construction"
|
|
HREF="x388.html"></HEAD
|
|
><BODY
|
|
CLASS="sect1"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="NAVHEADER"
|
|
><TABLE
|
|
SUMMARY="Header navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TH
|
|
COLSPAN="3"
|
|
ALIGN="center"
|
|
>Pocket Linux Guide</TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="left"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="x360.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
>Chapter 3. Saving Space</TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="x388.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="sect1"
|
|
><H1
|
|
CLASS="sect1"
|
|
><A
|
|
NAME="AEN367"
|
|
></A
|
|
>3.2. Design</H1
|
|
><P
|
|
>Take another look at the Bootdisk-HOWTO and notice how many
|
|
utilities can be squeezed onto a 1.44M floppy. There are three things that
|
|
make this possible. One is the use of shared libraries. The second is
|
|
stripped binaries. And the third is the use of a compressed filesystem. We
|
|
can use all of these techniques to save space on our root disk.</P
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN370"
|
|
></A
|
|
>3.2.1. Shared Libraries</H2
|
|
><P
|
|
>First, in order to use shared libraries we will need to rebuild
|
|
the BASH shell. This time we will configure it without using the
|
|
<TT
|
|
CLASS="option"
|
|
>--enable-static-link</TT
|
|
> option. Once BASH is rebuilt we
|
|
need to figure out which libraries it is linked with and be sure to
|
|
include them on the root disk. The <B
|
|
CLASS="command"
|
|
>ldd</B
|
|
> command makes
|
|
this job easy. By typing <B
|
|
CLASS="command"
|
|
>ldd bash</B
|
|
> on the command-line
|
|
we can see a list of all the shared libraries that BASH uses. As long as
|
|
all these libraries are copied to the root disk, the new BASH build
|
|
should work fine.</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN376"
|
|
></A
|
|
>3.2.2. Stripped Binaries</H2
|
|
><P
|
|
>Next, we should strip any binaries that get copied to the root
|
|
disk. The manpage for <B
|
|
CLASS="command"
|
|
>strip</B
|
|
> does not give much
|
|
description of what it does other than to say, "strip discards all
|
|
symbols from the object files." It seems like removing pieces of a
|
|
binary would render it useless, but this is not the case. The reason it
|
|
works is because a large number of these discarded symbols are used for
|
|
debugging. While debugging symbols are very helpful to programmers
|
|
working to improve the code, they do not do much for the average
|
|
end-user other than take up more disk space. And since space is at a
|
|
premium, we should definitely remove as many symbols as possible from
|
|
BASH and any other binaries before we copy over them to the
|
|
ramdisk.</P
|
|
><P
|
|
>The process of stripping files to save space also works with
|
|
shared library files. But when stripping libraries it is important to
|
|
use the <TT
|
|
CLASS="option"
|
|
>--strip-unneeded</TT
|
|
> option so as not to break
|
|
them. Using <TT
|
|
CLASS="option"
|
|
>--strip-unneeded</TT
|
|
> shrinks the file size, but
|
|
leaves the symbols needed for relocation intact which is something that
|
|
shared libraries need to function properly.</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN383"
|
|
></A
|
|
>3.2.3. Compressed Root Filesystem</H2
|
|
><P
|
|
>Finally, we can tackle the problem of how to build a compressed
|
|
root filesystem. The Bootdisk-HOWTO suggests three ways of constructing
|
|
a compressed root filesystem using either a ramdisk, a spare hard drive
|
|
partition or a loopback device. This project will concentrate on using
|
|
the ramdisk approach. It seems logical that if the root filesystem is
|
|
going to be run from a ramdisk, it may as well be built on a ramdisk.
|
|
All we have to do is create a second extended filesystem on a ramdisk
|
|
device, mount it and copy files to it. Once the filesystem is populated
|
|
with all the files that the root disk needs, we simply unmount it,
|
|
compress it and write it out to floppy.</P
|
|
><DIV
|
|
CLASS="note"
|
|
><P
|
|
></P
|
|
><TABLE
|
|
CLASS="note"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="25"
|
|
ALIGN="CENTER"
|
|
VALIGN="TOP"
|
|
><IMG
|
|
SRC="../images/note.gif"
|
|
HSPACE="5"
|
|
ALT="Note"></TD
|
|
><TD
|
|
ALIGN="LEFT"
|
|
VALIGN="TOP"
|
|
><P
|
|
>For this to work, we need to make sure the system used for
|
|
building has ramdisk support. If ramdisk is not available it is also
|
|
possible to use a loopback device. See the Bootdisk-HOWTO for more
|
|
information on using loopback devices.</P
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="NAVFOOTER"
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"><TABLE
|
|
SUMMARY="Footer navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="x360.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="index.html"
|
|
ACCESSKEY="H"
|
|
>Home</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="x388.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>Analysis</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="phase2.html"
|
|
ACCESSKEY="U"
|
|
>Up</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>Construction</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |