stripping.xml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. <sect1 id="ch-tools-stripping">
  8. <?dbhtml filename="stripping.html"?>
  9. <title>Finishing Temporary Tools</title>
  10. <para>
  11. The steps in this section are optional. Skip this section entirely
  12. if you are not really short on disk space and do not want to create
  13. a backup of the temporary tools.
  14. </para>
  15. <sect2>
  16. <title>Stripping</title>
  17. <para>If the LFS partition is rather small, it is beneficial to
  18. learn that unnecessary items can be removed.
  19. The executables and libraries built so far contain about 70 MB of unneeded
  20. debugging symbols.</para>
  21. <screen><userinput>strip --strip-debug /usr/lib/*
  22. strip --strip-unneeded /usr/{,s}bin/*
  23. strip --strip-unneeded /tools/bin/*</userinput></screen>
  24. <para>These commands will skip a number of files reporting that it does not
  25. recognize their file format. Most of these are scripts instead of binaries.
  26. <!--Note that we use the <command>strip</command> program built in
  27. <quote>Binutils pass 1</quote>, since it is the one that knows how to strip
  28. our cross-compiled programs.--></para>
  29. <para>Take care <emphasis>NOT</emphasis> to use
  30. <parameter>--strip-unneeded</parameter> on the libraries. The static
  31. ones would be destroyed and the toolchain packages would need to be
  32. built all over again.</para>
  33. <para>To save more space, remove the documentation:</para>
  34. <screen><userinput>rm -rf /usr/{,share}/{info,man,doc}</userinput></screen>
  35. <para>The libtool .la files are only useful when linking with static
  36. libraries. They are unneeded, and potentially harmful, when using dynamic
  37. shared libraries, specially when using non-autotools build systems.
  38. Remove those files now:</para>
  39. <screen><userinput>find /usr/{lib,libexec} -name \*.la -delete</userinput></screen>
  40. <para>At this point, you should have at least 5 GB of free space on the
  41. chroot partition that can be used to build and install Glibc and Gcc in
  42. the next phase. If you can build and install Glibc, you can build and install
  43. the rest too. You can check the free disk space with the command
  44. <command>df -h /</command>.</para>
  45. </sect2>
  46. <sect2>
  47. <title>Backup / Restore</title>
  48. <para>
  49. Now that the essential tools have been created, its time to think about
  50. a backup. When every check has passed successfully in the previously
  51. built packages, your temporary tools are in a good state and might be
  52. backed up for later reuse. In case of fatal failures in the subsequent
  53. chapters, it often turns out that removing everything and starting over
  54. (more carefully) is the best option to recover. Unfortunatly, all the
  55. temporary tools will be removed, too. To avoid the extra time needed to redo
  56. something which has been built successfully, prepare a backup.
  57. </para>
  58. <para>
  59. Leave the chroot environment and make sure you have at least
  60. 600 MB free disk space (the source tarballs will be included in
  61. the backup archive) in the home directory of user
  62. <systemitem class="username">lfs</systemitem>. Leaving the
  63. chroot environment is required as the backup should be stored
  64. outside of the <filename class="directory">$LFS</filename> directory
  65. but those cannot be accessed when in chroot. Leave the chroot environment
  66. and unmount the virtual kernel filesystems:
  67. </para>
  68. <screen role="nodump"><userinput>exit
  69. umount $LFS/dev{/pts,}
  70. umount $LFS/{sys,proc,run}</userinput></screen>
  71. <para>Create the backup archive:</para>
  72. <screen role="nodump"><userinput>cd $LFS &amp;&amp;
  73. tar -cJpf $HOME/temp-tools.tar.xz .
  74. </userinput></screen>
  75. <para>
  76. In case some mistakes have been made and you need to start over, you can
  77. use this backup to restore the temporary tools and save some irecovery time.
  78. Since the sources are located under
  79. <filename class="directory">$LFS</filename>, they are included in the
  80. backup archive as well, so you need not to download them again. After
  81. checking that <filename class="directory">$LFS</filename> is set properly,
  82. restore the backup by executing the following commands:
  83. </para>
  84. <screen role="nodump"><userinput>cd $LFS &amp;&amp;
  85. rm -rf ./* &amp;&amp;
  86. tar -xpf $HOME/temp-tools.tar.xz
  87. </userinput></screen>
  88. <para>
  89. Again, double check that the environment has been setup properly
  90. and continue building the rest of the system.
  91. </para>
  92. <important>
  93. <para>
  94. If you left the chroot environment either to create a backup
  95. or restart building using a restore, remember to mount the
  96. kernel virtual filesystems as described in <xref
  97. linkend='ch-tools-kernfs'/> and re-enter the
  98. chroot environment (see <xref
  99. linkend='ch-tools-chroot'/>) again before continuing.</para>
  100. </important>
  101. </sect2>
  102. </sect1>