source: chapter07/stripping.xml@ 00e8b532

ml-11.0 multilib
Last change on this file since 00e8b532 was 00e8b532, checked in by Thomas Trepl (Moody) <thomas@…>, 2 years ago

Merge upstream changes

  • Property mode set to 100644
File size: 8.2 KB
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "" [
4 <!ENTITY % general-entities SYSTEM "../general.ent">
5 %general-entities;
8<sect1 id="ch-tools-stripping">
9 <?dbhtml filename="stripping.html"?>
11 <title>Cleaning up and Saving the Temporary System</title>
13 <para>The libtool .la files are only useful when linking with static
14 libraries. They are unneeded, and potentially harmful, when using dynamic
15 shared libraries, specially when using non-autotools build systems.
16 While still in chroot, remove those files now:</para>
18<screen arch="default"><userinput>find /usr/{lib,libexec} -name \*.la -delete</userinput></screen>
19<screen arch="ml_32"><userinput>find /usr/{lib{,32},libexec} -name \*.la -delete</userinput></screen>
20<screen arch="ml_x32"><userinput>find /usr/{lib{,x32},libexec} -name \*.la -delete</userinput></screen>
21<screen arch="ml_all"><userinput>find /usr/{lib{,{,x}32},libexec} -name \*.la -delete</userinput></screen>
23 <para>Remove the documentation of the temporary tools, to prevent them
24 from ending up in the final system, and save about 35 MB:</para>
26<screen><userinput>rm -rf /usr/share/{info,man,doc}/*</userinput></screen>
28 <note><para>
29 All the remaining steps in this section are optional. Nevertheless,
30 as soon as you begin installing packages in <xref
31 linkend="chapter-building-system"/>, the temporary tools will be
32 overwritten. So it may be a good idea to do a backup of the temporary
33 tools as described below. The other steps are only needed if you are
34 really short on disk space.
35 </para></note>
37 <para>
38 The following steps are performed from outside the chroot
39 environment. That means, you have to leave the chroot environment
40 first before continuing. The reason for that is to:
41 <itemizedlist>
42 <listitem>
43 <para>
44 make sure that objects are not in use while they are
45 manipulated.
46 </para>
47 </listitem>
48 <listitem>
49 <para>
50 get access to file system locations outside of the chroot
51 environment to store/read the backup archive which should
52 not be placed within the
53 <filename class="directory">$LFS</filename> hierarchy for
54 safety reasons.
55 </para>
56 </listitem>
57 </itemizedlist>
58 </para>
60 <para>
61 Leave the chroot environment and unmount the kernel virtual file
62 systems:
63 </para>
65 <note>
66 <para>All of the following instructions are executed by
67 <systemitem class="username">root</systemitem>. Take extra
68 care about the commands you're going to run as mistakes
69 here can modify your host system. Be aware that the
70 environment variable <envar>LFS</envar> is set for user
71 <systemitem class="username">lfs</systemitem> by default
72 but it might <emphasis>not</emphasis> be set for
73 <systemitem class="username">root</systemitem>. Whenever
74 commands are to be executed by <systemitem class="username">root</systemitem>,
75 make sure you have set <envar>LFS</envar> accordingly.
76 This has been discussed in <xref linkend='ch-partitioning-aboutlfs'/>.
77 </para>
78 </note>
80<screen role="nodump"><userinput>exit
81umount $LFS/dev{/pts,}
82umount $LFS/{sys,proc,run}</userinput></screen>
84 <sect2>
85 <title>Stripping</title>
87 <para>If the LFS partition is rather small, it is good to
88 know that unnecessary items can be removed. The executables and
89 libraries built so far contain a little over 90 MB of unneeded debugging
90 symbols.</para>
92 <para>Strip off debugging symbols from binaries:</para>
93<screen arch="default" role="nodump"><userinput>$LFS_TGT-strip --strip-unneeded $LFS/usr/lib/*
94$LFS_TGT-strip --strip-unneeded $LFS/usr/{,s}bin/*
95$LFS_TGT-strip --strip-unneeded $LFS/tools/bin/*</userinput></screen>
96<screen arch="ml_32" role="nodump"><userinput>$LFS_TGT-strip --strip-unneeded $LFS/usr/lib{,32}/*
97$LFS_TGT-strip --strip-unneeded $LFS/usr/{,s}bin/*
98$LFS_TGT-strip --strip-unneeded $LFS/tools/bin/*</userinput></screen>
99<screen arch="ml_x32" role="nodump"><userinput>$LFS_TGT-strip --strip-unneeded $LFS/usr/lib{,x32}/*
100$LFS_TGT-strip --strip-unneeded $LFS/usr/{,s}bin/*
101$LFS_TGT-strip --strip-unneeded $LFS/tools/bin/*</userinput></screen>
102<screen arch="ml_all" role="nodump"><userinput>$LFS_TGT-strip --strip-unneeded $LFS/usr/lib{,{,x}32}/*
103$LFS_TGT-strip --strip-unneeded $LFS/usr/{,s}bin/*
104$LFS_TGT-strip --strip-unneeded $LFS/tools/bin/*</userinput></screen>
106 <para>These commands will skip a number of files reporting that it does not
107 recognize their file format. Most of these are scripts instead of binaries.
108 <!--Note that we use the <command>strip</command> program built in
109 <quote>Binutils pass 2</quote>, since it is the one that knows how to strip
110 our cross-compiled programs.--></para>
112 <para>At this point, you should have at least 5 GB of free space on the
113 chroot partition that can be used to build and install Glibc and GCC in
114 the next phase. If you can build and install Glibc, you can build and install
115 the rest too. You can check the free disk space with the command
116 <command>df -h $LFS</command>.</para>
118 </sect2>
120 <sect2>
121 <title>Backup</title>
123 <para>
124 Now that the essential tools have been created, its time to think about
125 a backup. When every check has passed successfully in the previously
126 built packages, your temporary tools are in a good state and might be
127 backed up for later reuse. In case of fatal failures in the subsequent
128 chapters, it often turns out that removing everything and starting over
129 (more carefully) is the best option to recover. Unfortunately, all the
130 temporary tools will be removed, too. To avoid spending extra time to
131 redo something which has been built successfully, prepare a backup.
132 </para>
134 <para>
135 Make sure you have at least 600 MB free disk space (the source tarballs
136 will be included in the backup archive) in the home directory of user
137 <systemitem class="username">root</systemitem>.
138 </para>
140 <para>
141 Create the backup archive by running the following command:
142 </para>
144<screen role="nodump" revision="sysv"><userinput>cd $LFS &amp;&amp;
145tar -cJpf $HOME/lfs-temp-tools-&version;.tar.xz .</userinput></screen>
147<screen role="nodump" revision="systemd"><userinput>cd $LFS &amp;&amp;
148tar -cJpf $HOME/lfs-temp-tools-&versiond;.tar.xz .</userinput></screen>
150 <para>
151 Replace <envar>$HOME</envar> by a directory of your choice if you
152 do not want to have the backup stored in <systemitem
153 class="username">root</systemitem>'s home directory.
154 </para>
155 </sect2>
157 <sect2>
158 <title>Restore</title>
160 <para>
161 In case some mistakes have been made and you need to start over, you can
162 use this backup to restore the temporary tools and save some recovery time.
163 Since the sources are located under
164 <filename class="directory">$LFS</filename>, they are included in the
165 backup archive as well, so they do not need to be downloaded again. After
166 checking that <envar>$LFS</envar> is set properly,
167 restore the backup by executing the following commands:
168 </para>
170<!-- Make the following look different so users don't blindly run the
171 restore when they don't need to. -->
173<screen role="nodump" revision="sysv"><computeroutput>cd $LFS &amp;&amp;
174rm -rf ./* &amp;&amp;
175tar -xpf $HOME/lfs-temp-tools-&version;.tar.xz</computeroutput></screen>
177<screen role="nodump" revision="systemd"><computeroutput>cd $LFS &amp;&amp;
178rm -rf ./* &amp;&amp;
179tar -xpf $HOME/lfs-temp-tools-&versiond;.tar.xz</computeroutput></screen>
181 <para>
182 Again, double check that the environment has been setup properly
183 and continue building the rest of the system.
184 </para>
186 <important>
187 <para>
188 If you left the chroot environment either to strip off debug
189 symbols, create a backup, or restart building using a restore,
190 remember to mount the kernel virtual filesystems now again as
191 described in <xref linkend='ch-tools-kernfs'/> and re-enter
192 the chroot environment (see <xref linkend='ch-tools-chroot'/>)
193 again before continuing.
194 </para>
195 </important>
197 </sect2>
Note: See TracBrowser for help on using the repository browser.