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