chroot.xml 2.9 KB

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