source: chapter07/stripping.xml@ 2dfe134

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

Remove useless comment

  • Property mode set to 100644
File size: 8.3 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4 <!ENTITY % general-entities SYSTEM "../general.ent">
5 %general-entities;
6]>
7
8<sect1 id="ch-tools-stripping">
9 <?dbhtml filename="stripping.html"?>
10
11 <title>Cleaning up and Saving the Temporary System</title>
12
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>
17
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>
22
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>
25
26<screen><userinput>rm -rf /usr/share/{info,man,doc}/*</userinput></screen>
27
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>
36
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>
59
60 <para>
61 Now, if you are stripping installed files or making a backup,
62 leave the chroot environment:
63 </para>
64
65<screen role="nodump"><userinput>exit</userinput></screen>
66
67 <important>
68 <para>All of the following instructions are executed by
69 <systemitem class="username">root</systemitem>. Take extra
70 care about the commands you're going to run as mistakes
71 here can modify your host system. Be aware that the
72 environment variables <envar>LFS</envar> and <envar>LFS_TGT</envar>
73 are set for user <systemitem class="username">lfs</systemitem> by default
74 but may <emphasis>not</emphasis> be set for
75 <systemitem class="username">root</systemitem>. Whenever
76 commands are to be executed by <systemitem class="username">root</systemitem>,
77 make sure you have set <envar>LFS</envar> and <envar>LFS_TGT</envar> accordingly.
78 This has been discussed in <xref linkend='ch-partitioning-aboutlfs'/>.
79 </para>
80 </important>
81
82
83 <sect2>
84 <title>Stripping</title>
85
86 <para>If the LFS partition is rather small, it is good to
87 know that unnecessary items can be removed. The executables and
88 libraries built so far contain a little over 90 MB of unneeded debugging
89 symbols.</para>
90
91 <para>Strip off debugging symbols from binaries:</para>
92
93 <screen role="nodump"><userinput>cd $LFS/tools/$LFS_TGT
94bin/strip --strip-unneeded $LFS/usr/lib/*</userinput><userinput arch="ml_32">
95bin/strip --strip-unneeded $LFS/usr/lib32/*</userinput><userinput arch="ml_x32">
96bin/strip --strip-unneeded $LFS/usr/libx32/*</userinput><userinput arch="ml_all">
97bin/strip --strip-unneeded $LFS/usr/lib{,x}32/*</userinput><userinput>
98bin/strip --strip-unneeded $LFS/usr/{,s}bin/*
99bin/strip --strip-unneeded $LFS/tools/bin/*</userinput></screen>
100
101 <screen arch="ml_32" role="nodump"><userinput></userinput></screen>
102
103
104 <para>These commands will skip a number of files reporting that it does not
105 recognize their file format. Most of these are scripts instead of binaries.
106 </para>
107
108 <para>At this point, you should have at least 5 GB of free space on the
109 chroot partition that can be used to build and install Glibc and GCC in
110 the next phase. If you can build and install Glibc, you can build and install
111 the rest too. You can check the free disk space with the command
112 <command>df -h $LFS</command>.</para>
113
114 </sect2>
115
116 <sect2>
117 <title>Backup</title>
118
119 <para>
120 Now that the essential tools have been created, its time to think about
121 a backup. When every check has passed successfully in the previously
122 built packages, your temporary tools are in a good state and might be
123 backed up for later reuse. In case of fatal failures in the subsequent
124 chapters, it often turns out that removing everything and starting over
125 (more carefully) is the best option to recover. Unfortunately, all the
126 temporary tools will be removed, too. To avoid spending extra time to
127 redo something which has been built successfully, prepare a backup.
128 </para>
129
130 <para>
131 Make sure you have at least 600 MB free disk space (the source tarballs
132 will be included in the backup archive) in the home directory of user
133 <systemitem class="username">root</systemitem>.
134 </para>
135
136 <para>Before we make a backup, unmount the virtual file systems:</para>
137
138<screen role="nodump"><userinput>umount $LFS/dev{/pts,}
139umount $LFS/{sys,proc,run}</userinput></screen>
140
141 <para>
142 Create the backup archive by running the following command:
143 </para>
144
145<screen role="nodump" revision="sysv"><userinput>cd $LFS
146tar -cJpf $HOME/lfs-temp-tools-&version;.tar.xz .</userinput></screen>
147
148<screen role="nodump" revision="systemd"><userinput>cd $LFS
149tar -cJpf $HOME/lfs-temp-tools-&versiond;.tar.xz .</userinput></screen>
150
151 <para>
152 Replace <envar>$HOME</envar> by a directory of your choice if you
153 do not want to have the backup stored in <systemitem
154 class="username">root</systemitem>'s home directory.
155 </para>
156 </sect2>
157
158 <sect2>
159 <title>Restore</title>
160
161 <para>
162 In case some mistakes have been made and you need to start over, you can
163 use this backup to restore the temporary tools and save some recovery time.
164 Since the sources are located under
165 <filename class="directory">$LFS</filename>, they are included in the
166 backup archive as well, so they do not need to be downloaded again. After
167 checking that <envar>$LFS</envar> is set properly,
168 restore the backup by executing the following commands:
169 </para>
170
171<!-- Make the following look different so users don't blindly run the
172 restore when they don't need to. -->
173
174 <warning><para>The following commands are extremly dangerous. If
175 you run <command>rm -rf ./*</command> as the root user and you
176 do not change to the $LFS directory or the <envar>LFS</envar>
177 environment variable is not set for the root user, it will destroy
178 your entire host system. YOU ARE WARNED.</para></warning>
179
180<screen role="nodump" revision="sysv"><computeroutput>cd $LFS
181rm -rf ./*
182tar -xpf $HOME/lfs-temp-tools-&version;.tar.xz</computeroutput></screen>
183
184<screen role="nodump" revision="systemd"><computeroutput>cd $LFS
185rm -rf ./*
186tar -xpf $HOME/lfs-temp-tools-&versiond;.tar.xz</computeroutput></screen>
187
188 <para>
189 Again, double check that the environment has been setup properly
190 and continue building the rest of the system.
191 </para>
192
193 <important>
194 <para>
195 If you left the chroot environment
196 to create a backup or restart building using a restore,
197 remember to check that the virtual filesystems are still
198 mounted (<command>findmnt | grep $LFS</command>).
199 If they are not mounted, remount them now as
200 described in <xref linkend='ch-tools-kernfs'/> and re-enter
201 the chroot environment (see <xref linkend='ch-tools-chroot'/>)
202 before continuing.
203 </para>
204 </important>
205
206 </sect2>
207
208</sect1>
Note: See TracBrowser for help on using the repository browser.