chroot.xml 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
  3. <!ENTITY % general-entities SYSTEM "../general.ent">
  4. %general-entities;
  5. ]>
  6. <sect1 id="ch-system-chroot">
  7. <title>Entering the Chroot Environment</title>
  8. <?dbhtml filename="chroot.html"?>
  9. <para>It is time to enter the chroot environment to begin
  10. building and installing the final LFS system. As user
  11. <emphasis>root</emphasis>, run the following command to enter the
  12. realm that is, at the moment, populated with only the temporary
  13. tools:</para>
  14. <screen><userinput>chroot "$LFS" /tools/bin/env -i \
  15. HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
  16. PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
  17. /tools/bin/bash --login +h</userinput></screen>
  18. <para>The <parameter>-i</parameter> option given to the
  19. <command>env</command> command will clear all variables of the chroot
  20. environment. After that, only the <envar>HOME</envar>,
  21. <envar>TERM</envar>, <envar>PS1</envar>, and
  22. <envar>PATH</envar> variables are set again. The
  23. <parameter>TERM=$TERM</parameter> construct will set the
  24. <envar>TERM</envar> variable inside chroot to the same value as
  25. outside chroot. This variable is needed for programs like
  26. <command>vim</command> and <command>less</command> to operate
  27. properly. If other variables are needed, such as
  28. <envar>CFLAGS</envar> or <envar>CXXFLAGS</envar>, this is
  29. a good place to set them again.</para>
  30. <para>From this point on, there is no need to use the
  31. <envar>LFS</envar> variable anymore, because all work will be
  32. restricted to the LFS file system. This is because the Bash shell is
  33. told that <filename class="directory">$LFS</filename> is now the root
  34. (<filename class="directory">/</filename>) directory.</para>
  35. <para>Notice that <filename class="directory">/tools/bin</filename>
  36. comes last in the <envar>PATH</envar>. This means that a
  37. temporary tool will not be used anymore as soon as its final version
  38. is installed. This occurs when the shell does not <quote>remember</quote> the
  39. locations of executed binaries&mdash;for this reason, hashing is switched
  40. off by passing the <parameter>+h</parameter> option to <command>bash</command>.</para>
  41. <para>It is important that all the commands throughout the remainder
  42. of this chapter and the following chapters are run from within the
  43. chroot environment. If you leave this environment for any reason
  44. (rebooting for example), remember to first mount the <systemitem
  45. class="filesystem">proc</systemitem> and <systemitem
  46. class="filesystem">devpts</systemitem> file systems (discussed in the
  47. previous section) and enter chroot again before continuing with the
  48. installations.</para>
  49. <para>Note that the <command>bash</command> prompt will say
  50. <computeroutput>I have no name!</computeroutput> This is normal because the
  51. <filename>/etc/passwd</filename> file has not been created yet.</para>
  52. </sect1>