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