Moving the final strip from the last chapter to the end of chapter 6.

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@3258 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
This commit is contained in:
Alex Gronenwoud 2004-02-22 22:32:27 +00:00
parent cd0c92d633
commit b157558174
5 changed files with 122 additions and 61 deletions

View File

@ -2,10 +2,26 @@
<title>Changelog</title> <title>Changelog</title>
<?dbhtml filename="changelog.html" dir="chapter01"?> <?dbhtml filename="changelog.html" dir="chapter01"?>
<para>&version; - &releasedate;</para> <para>This is version &version; of the Linux From Scratch book, dated
&releasedate;. If this book is more than two months old, a newer and better
version is probably already available. To find out, please check one of the
mirrors via <ulink url="&lfs-root;"/>.</para>
<para>Below is a list of changes made since the previous release of the book,
first a summary, then a detailed log.</para>
<itemizedlist> <itemizedlist>
<listitem><para>Upgraded to:</para>
<itemizedlist>
<listitem><para>less-382</para></listitem>
<listitem><para>man-pages-1.66</para></listitem>
<listitem><para>ncurses-5.4</para></listitem>
</itemizedlist></listitem>
<listitem><para>February 22nd, 2004 [alex]: Moved the stripping of the final
system from chapter 9 to the end of chapter 6.</para></listitem>
<listitem><para>February 22nd, 2004 [alex]: Chapter 6 - Coreutils and <listitem><para>February 22nd, 2004 [alex]: Chapter 6 - Coreutils and
E2fsprogs: Clarified the prerequisites for running the tests.</para></listitem> E2fsprogs: Clarified the prerequisites for running the tests.</para></listitem>
@ -13,11 +29,11 @@ E2fsprogs: Clarified the prerequisites for running the tests.</para></listitem>
an unnecessary "{,share/}" from the documentation's <command>rm</command> an unnecessary "{,share/}" from the documentation's <command>rm</command>
command.</para></listitem> command.</para></listitem>
<listitem><para>February 14th, 2004 [jeremy]: Chapter 6 - Upgraded Less <listitem><para>February 14th, 2004 [jeremy]: Chapter 6 - Upgraded to
to 382.</para></listitem> Less-382.</para></listitem>
<listitem><para>February 14th, 2004 [jeremy]: Chapters 5 & 6 - Upgraded <listitem><para>February 14th, 2004 [jeremy]: Chapters 5 + 6 - Upgraded to
ncurses to version 5.4, and removed references to etip patch.</para></listitem> Ncurses-5.4, and removed references to the etip patch.</para></listitem>
<listitem><para>February 12th, 2004 [jeremy]: Chapter 6 - Removed explicit <listitem><para>February 12th, 2004 [jeremy]: Chapter 6 - Removed explicit
paths from the pwconv and grpconv commands, since /usr/sbin is part of paths from the pwconv and grpconv commands, since /usr/sbin is part of
@ -27,7 +43,7 @@ the default path.</para></listitem>
installation section to chapter 7.</para></listitem> installation section to chapter 7.</para></listitem>
<listitem><para>February 8th, 2004 [matt]: Chapter 6 - Updated to <listitem><para>February 8th, 2004 [matt]: Chapter 6 - Updated to
man-pages-1.66.</para></listitem> Man-pages-1.66.</para></listitem>
<listitem><para>February 7th, 2004 [alex]: Chapter 1 - Moved the Conventions <listitem><para>February 7th, 2004 [alex]: Chapter 1 - Moved the Conventions
and Acknowledgements sections to the Preface.</para></listitem> and Acknowledgements sections to the Preface.</para></listitem>

View File

@ -573,15 +573,15 @@ ensuring to cut-and-paste the commands as was recommended.</para>
<title>Stripping</title> <title>Stripping</title>
<?dbhtml filename="stripping.html" dir="chapter05"?> <?dbhtml filename="stripping.html" dir="chapter05"?>
<para>The steps in this section are optional. If your LFS partition is rather <para>The steps in this section are optional, but if your LFS partition is
small, you will be glad to learn that you can throw away some unnecessary rather small, you will be glad to learn that you can remove some unnecessary
things. The executables and libraries you have built so far contain about 130 MB things. The executables and libraries you have built so far contain about 130
of unneeded debugging symbols. Remove those symbols like this:</para> MB of unneeded debugging symbols. Remove those symbols with:</para>
<screen><userinput>strip --strip-unneeded /tools/{,s}bin/* <screen><userinput>strip --strip-debug /tools/lib/*
strip --strip-debug /tools/lib/*</userinput></screen> strip --strip-unneeded /tools/{,s}bin/*</userinput></screen>
<para>The first of the above commands will skip some twenty files, reporting <para>The last of the above commands will skip some twenty files, reporting
that it doesn't recognize their file format. Most of them are scripts instead that it doesn't recognize their file format. Most of them are scripts instead
of binaries.</para> of binaries.</para>

View File

@ -502,11 +502,98 @@ Most likely something went wrong with the specs file amendment above.</para>
&c6-gcc-2953; &c6-gcc-2953;
<sect1 id="ch-system-aboutdebug">
<title>About debugging symbols</title>
<?dbhtml filename="aboutdebug.html" dir="chapter06"?>
<para>Most programs and libraries are, by default, compiled with debugging
symbols included (with <command>gcc</command>'s <emphasis>-g</emphasis>
option). This means that, when debugging a program or library that was compiled
with debugging information included, the debugger can give you not only memory
addresses but also the names of the routines and variables.</para>
<para>The inclusion of these debugging symbols, however, enlarges a program or
library significantly. To get an idea of the amount of space these symbols
occupy, have a look at the following:</para>
<itemizedlist>
<listitem><para>a bash binary
with debugging symbols: 1200 KB</para></listitem>
<listitem><para>a bash binary
without debugging symbols: 480 KB</para></listitem>
<listitem><para>Glibc and GCC files (/lib and /usr/lib)
with debugging symbols: 87 MB</para></listitem>
<listitem><para>Glibc and GCC files
without debugging symbols: 16 MB</para></listitem>
</itemizedlist>
<para>Sizes may vary somewhat, depending on which compiler was used and which C
library, but when comparing programs with and without debugging symbols the
difference will generally be a factor between 2 and 5.</para>
<para>As most people will probably never use a debugger on their system
software, a lot of disk space can be regained by removing these symbols. For
your convenience, the next section shows how to strip all debugging symbols
from all programs and libraries. Information on other ways of optimizing your
system can be found in the hint at <ulink
url="&hints-root;optimization.txt"/>.</para>
</sect1>
<sect1 id="ch-system-strippingagain">
<title>Stripping again</title>
<?dbhtml filename="strippingagain.html" dir="chapter06"?>
<para>If you are not a programmer and don't plan to do any debugging on your
system software, you can shrink your system by about 200 MB by removing the
debugging symbols from binaries and libraries. This causes no inconvenience
other than not being able to debug the software fully any more.</para>
<para>Most people who use the command mentioned below don't experience any
problems. But it is easy to make a typo and render your new system unusable, so
before running the strip command it is probably a good idea to make a backup of
the current situation.</para>
<para>If you are going to perform the stripping, special care is needed to
ensure you're not running any of the binaries that are about to be stripped.
If you're not sure whether you entered chroot with the command given in
<xref linkend="ch-system-chroot"/>, then now exit from chroot and reenter it
with the following commands:</para>
<screen><userinput>logout; chroot $LFS /tools/bin/env -i \
&nbsp;&nbsp;&nbsp;&nbsp;HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
&nbsp;&nbsp;&nbsp;&nbsp;PATH=/bin:/usr/bin:/sbin:/usr/sbin \
&nbsp;&nbsp;&nbsp;&nbsp;/tools/bin/bash --login</userinput></screen>
<para>Now you can safely strip the binaries and libraries:</para>
<screen><userinput>/tools/bin/find /{,usr/}{bin,lib,sbin} -type f \
&nbsp;&nbsp;&nbsp;-exec /tools/bin/strip --strip-debug '{}' ';'</userinput></screen>
<para>A large number of files will be reported as having their file format not
recognized. These warnings can be safely ignored, they just mean that those
files are scripts instead of binaries, no harm is done.</para>
<para>If you are really tight on disk space, you may want to use
<emphasis>--strip-all</emphasis> on the binaries in
<filename>/{,usr/}{bin,sbin}</filename> to gain several more megabytes. But do
<emphasis>not</emphasis> use this option on libraries: they would be
destroyed.</para>
</sect1>
<sect1 id="ch-system-revisedchroot"> <sect1 id="ch-system-revisedchroot">
<title>Revised chroot command</title> <title>Revised chroot command</title>
<?dbhtml filename="revisedchroot.html" dir="chapter06"?> <?dbhtml filename="revisedchroot.html" dir="chapter06"?>
<para>From now on when you exit the chroot environment and wish to re-enter <para>From now on when you exit the chroot environment and wish to reenter
it, you should run the following modified chroot command:</para> it, you should run the following modified chroot command:</para>
<screen><userinput>chroot $LFS /usr/bin/env -i \ <screen><userinput>chroot $LFS /usr/bin/env -i \
@ -521,8 +608,5 @@ just yet. There is still some use for it towards the end of the book.</para>
</sect1> </sect1>
&c6-aboutdebug;
</chapter> </chapter>

View File

@ -74,6 +74,11 @@ interest to you.</para>
<screen><userinput>make CC=/opt/gcc-2.95.3/bin/gcc modules_install</userinput></screen> <screen><userinput>make CC=/opt/gcc-2.95.3/bin/gcc modules_install</userinput></screen>
<para>If you have a lot of modules and very little space, you may want to
consider stripping and compressing the modules. For most people such compression
isn't worth the trouble, but if you're really pressed for space, then have a look at
<ulink url="http://www.linux-mips.org/archives/linux-mips/2002-04/msg00031.html"/>.</para>
<para>As nothing is complete without documentation, build the manual pages <para>As nothing is complete without documentation, build the manual pages
that come with the kernel:</para> that come with the kernel:</para>

View File

@ -6,50 +6,6 @@
been a long process, but we hope it was worth it. We wish you a lot of fun been a long process, but we hope it was worth it. We wish you a lot of fun
with your new shiny custom built Linux system.</para> with your new shiny custom built Linux system.</para>
<para>Now would be a good time to strip all debug symbols from
the binaries on your LFS system. If you are not a programmer and don't plan
on debugging your software, then you will be happy to know that you can
reclaim a few tens of megs by removing debug symbols. This process causes
no inconvenience other than not being able to debug the software fully
anymore, which is not an issue if you don't know how to debug.</para>
<para>Disclaimer: 98% of the people who use the command mentioned below don't
experience any problems. But do make a backup of your LFS system before
you run this command. There's a slight chance it may backfire on you and
render your system unusable (mostly by destroying your kernel modules
and dynamic &amp; shared libraries). This is caused more often by typos
than by a problem with the command used.</para>
<para>Having said that, the --strip-debug option we use to strip is quite
harmless under normal circumstances. It doesn't strip anything vital from
the files. It also is quite safe to use --strip-all on regular programs
(don't use that on libraries - they will be destroyed), but it's not as
safe, and the space you gain is not all that much. But if you're tight on
disk space every little bit helps, so decide for yourself. Please refer to
the strip man page for other strip options you can use. The general idea
is to not run strip on libraries (other than --strip-debug), just to be
on the safe side.</para>
<para>If you are planning to go ahead and perform the strip, special care is
needed to ensure you're not running any binaries that are about to be stripped
-- including the active bash shell. Therefore you'll need to exit the chroot
environment and reenter it using a modified chroot command:</para>
<screen><userinput>logout
chroot $LFS /tools/bin/env -i \
&nbsp;&nbsp;&nbsp;&nbsp;HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
&nbsp;&nbsp;&nbsp;&nbsp;PATH=/bin:/usr/bin:/sbin:/usr/sbin \
&nbsp;&nbsp;&nbsp;&nbsp;/tools/bin/bash --login</userinput></screen>
<para>Now run the following command:</para>
<screen><userinput>/tools/bin/find /{,usr/,usr/local/}{bin,sbin,lib} -type f \
&nbsp;&nbsp;&nbsp;-exec /tools/bin/strip --strip-debug '{}' ';'</userinput></screen>
<para>Quite a number of files will be reported as having their file format not
recognized. Most of these are scripts instead of binaries. These warnings can
be safely ignored.</para>
<para>It may be a good idea to create an <filename>/etc/lfs-release</filename> <para>It may be a good idea to create an <filename>/etc/lfs-release</filename>
file. By having this file it is very easy for you (and for us if you are going file. By having this file it is very easy for you (and for us if you are going
to ask for help with something at some point) to find out which LFS version to ask for help with something at some point) to find out which LFS version