source: chapter07/stripping.xml@ d04ce15

11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since d04ce15 was d04ce15, checked in by Bruce Dubbs <bdubbs@…>, 3 years ago

Wording

  • Property mode set to 100644
File size: 7.6 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><userinput>find /usr/{lib,libexec} -name \*.la -delete</userinput></screen>
19
20 <para>Remove the documentation of the temporary tools, to prevent them
21 from ending up in the final system, and save about 35 MB:</para>
22
23<screen><userinput>rm -rf /usr/share/{info,man,doc}/*</userinput></screen>
24
25 <note><para>
26 All the remaining steps in this section are optional. Nevertheless,
27 as soon as you begin installing packages in <xref
28 linkend="chapter-building-system"/>, the temporary tools will be
29 overwritten. So it may be a good idea to do a backup of the temporary
30 tools as described below. The other steps are only needed if you are
31 really short on disk space.
32 </para></note>
33
34 <para>
35 The following steps are performed from outside the chroot
36 environment. That means, you have to leave the chroot environment
37 first before continuing. The reason for that is to:
38 <itemizedlist>
39 <listitem>
40 <para>
41 make sure that objects are not in use while they are
42 manipulated.
43 </para>
44 </listitem>
45 <listitem>
46 <para>
47 get access to file system locations outside of the chroot
48 environment to store/read the backup archive which should
49 not be placed within the
50 <filename class="directory">$LFS</filename> hierarchy for
51 safety reasons.
52 </para>
53 </listitem>
54 </itemizedlist>
55 </para>
56
57 <para>
58 Now, if you are stripping installed files or making a backup,
59 leave the chroot environment:
60 </para>
61
62<screen role="nodump"><userinput>exit</userinput></screen>
63
64 <important>
65 <para>All of the following instructions are executed by
66 <systemitem class="username">root</systemitem>. Take extra
67 care about the commands you're going to run as mistakes
68 here can modify your host system. Be aware that the
69 environment variables <envar>LFS</envar> and <envar>LFS_TGT</envar>
70 are set for user <systemitem class="username">lfs</systemitem> by default
71 but may <emphasis>not</emphasis> be set for
72 <systemitem class="username">root</systemitem>. Whenever
73 commands are to be executed by <systemitem class="username">root</systemitem>,
74 make sure you have set <envar>LFS</envar> and <envar>LFS_TGT</envar> accordingly.
75 This has been discussed in <xref linkend='ch-partitioning-aboutlfs'/>.
76 </para>
77 </important>
78
79
80 <sect2>
81 <title>Stripping</title>
82
83 <para>If the LFS partition is rather small, it is good to
84 know that unnecessary items can be removed. The executables and
85 libraries built so far contain a little over 90 MB of unneeded debugging
86 symbols.</para>
87
88 <para>Strip off debugging symbols from binaries:</para>
89
90 <screen role="nodump"><userinput>cd $LFS/tools/$LFS_TGT
91bin/strip --strip-unneeded $LFS/usr/lib/*
92bin/strip --strip-unneeded $LFS/usr/{,s}bin/*
93bin/strip --strip-unneeded $LFS/tools/bin/*</userinput></screen>
94
95 <para>These commands will skip a number of files reporting that it does not
96 recognize their file format. Most of these are scripts instead of binaries.
97 </para>
98
99 <para>At this point, you should have at least 5 GB of free space on the
100 chroot partition that can be used to build and install Glibc and GCC in
101 the next phase. If you can build and install Glibc, you can build and install
102 the rest too. You can check the free disk space with the command
103 <command>df -h $LFS</command>.</para>
104
105 </sect2>
106
107 <sect2>
108 <title>Backup</title>
109
110 <para>
111 Now that the essential tools have been created, its time to think about
112 a backup. When every check has passed successfully in the previously
113 built packages, your temporary tools are in a good state and might be
114 backed up for later reuse. In case of fatal failures in the subsequent
115 chapters, it often turns out that removing everything and starting over
116 (more carefully) is the best option to recover. Unfortunately, all the
117 temporary tools will be removed, too. To avoid spending extra time to
118 redo something which has been built successfully, prepare a backup.
119 </para>
120
121 <para>
122 Make sure you have at least 600 MB free disk space (the source tarballs
123 will be included in the backup archive) in the home directory of user
124 <systemitem class="username">root</systemitem>.
125 </para>
126
127 <para>Before we make a backup, unmount the virtual file systems:</para>
128
129<screen role="nodump"><userinput>umount $LFS/dev{/pts,}
130umount $LFS/{sys,proc,run}</userinput></screen>
131
132 <para>
133 Create the backup archive by running the following command:
134 </para>
135
136<screen role="nodump" revision="sysv"><userinput>cd $LFS
137tar -cJpf $HOME/lfs-temp-tools-&version;.tar.xz .</userinput></screen>
138
139<screen role="nodump" revision="systemd"><userinput>cd $LFS
140tar -cJpf $HOME/lfs-temp-tools-&versiond;.tar.xz .</userinput></screen>
141
142 <para>
143 Replace <envar>$HOME</envar> by a directory of your choice if you
144 do not want to have the backup stored in <systemitem
145 class="username">root</systemitem>'s home directory.
146 </para>
147 </sect2>
148
149 <sect2>
150 <title>Restore</title>
151
152 <para>
153 In case some mistakes have been made and you need to start over, you can
154 use this backup to restore the temporary tools and save some recovery time.
155 Since the sources are located under
156 <filename class="directory">$LFS</filename>, they are included in the
157 backup archive as well, so they do not need to be downloaded again. After
158 checking that <envar>$LFS</envar> is set properly,
159 restore the backup by executing the following commands:
160 </para>
161
162<!-- Make the following look different so users don't blindly run the
163 restore when they don't need to. -->
164
165 <warning><para>The following commands are extremly dangerous. If
166 you run <command>rm -rf ./*</command> as the root user and you
167 do not change to the $LFS directory or the <envar>LFS</envar>
168 environment variable is not set for the root user, it will destroy
169 your entire host system. YOU ARE WARNED.</para></warning>
170
171<screen role="nodump" revision="sysv"><computeroutput>cd $LFS
172rm -rf ./*
173tar -xpf $HOME/lfs-temp-tools-&version;.tar.xz</computeroutput></screen>
174
175<screen role="nodump" revision="systemd"><computeroutput>cd $LFS
176rm -rf ./*
177tar -xpf $HOME/lfs-temp-tools-&versiond;.tar.xz</computeroutput></screen>
178
179 <para>
180 Again, double check that the environment has been setup properly
181 and continue building the rest of the system.
182 </para>
183
184 <important>
185 <para>
186 If you left the chroot environment
187 to create a backup or restart building using a restore,
188 remember to check that the virtual filesystems are still
189 mounted (<command>findmnt | grep $LFS</command>).
190 If they are not mounted, remount them now as
191 described in <xref linkend='ch-tools-kernfs'/> and re-enter
192 the chroot environment (see <xref linkend='ch-tools-chroot'/>)
193 before continuing.
194 </para>
195 </important>
196
197 </sect2>
198
199</sect1>
Note: See TracBrowser for help on using the repository browser.