chroot.xml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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-chroot">
  8. <?dbhtml filename="chroot.html"?>
  9. <title>Entering the Chroot Environment</title>
  10. <para>Now that all the packages which are required to build the rest of the
  11. needed tools are on the system, it is time to enter the chroot environment to
  12. finish installing the remaining temporary tools. This environment will be in
  13. use also for installing the final system. As user <systemitem
  14. class="username">root</systemitem>, run the following command to enter the
  15. environment that is, at the moment, populated with only the temporary
  16. tools:</para>
  17. <screen role="nodump"><userinput>chroot "$LFS" /usr/bin/env -i \
  18. HOME=/root \
  19. TERM="$TERM" \
  20. PS1='(lfs chroot) \u:\w\$ ' \
  21. PATH=/bin:/usr/bin:/sbin:/usr/sbin \
  22. /bin/bash --login +h</userinput></screen>
  23. <para>The <parameter>-i</parameter> option given to the <command>env</command>
  24. command will clear all variables of the chroot environment. After that, only
  25. the <envar>HOME</envar>, <envar>TERM</envar>, <envar>PS1</envar>, and
  26. <envar>PATH</envar> variables are set again. The
  27. <parameter>TERM=$TERM</parameter> construct will set the <envar>TERM</envar>
  28. variable inside chroot to the same value as outside chroot. This variable is
  29. needed for programs like <command>vim</command> and <command>less</command>
  30. to operate properly. If other variables are desired, such as
  31. <envar>CFLAGS</envar> or <envar>CXXFLAGS</envar>, this is a good place to set
  32. them again.</para>
  33. <para>From this point on, there is no need to use the
  34. <envar>LFS</envar> variable anymore because all work will be restricted
  35. to the LFS file system. This is because the Bash shell is told that
  36. <filename class="directory">$LFS</filename> is now the root
  37. (<filename class="directory">/</filename>) directory.</para>
  38. <para>Notice that <filename class="directory">/tools/bin</filename> is not
  39. in the <envar>PATH</envar>. This means that the cross toolchain will no longer be
  40. used in the chroot environment. This occurs when the shell does not
  41. <quote>remember</quote> the locations of executed binaries&mdash;for this
  42. reason, hashing is switched off by passing the <parameter>+h</parameter> option
  43. to <command>bash</command>.</para>
  44. <para>Note that the <command>bash</command> prompt will say
  45. <computeroutput>I have no name!</computeroutput> This is normal because the
  46. <filename>/etc/passwd</filename> file has not been created yet.</para>
  47. <note>
  48. <para>It is important that all the commands throughout the remainder of this
  49. chapter and the following chapters are run from within the chroot
  50. environment. If you leave this environment for any reason (rebooting for
  51. example), ensure that the virtual kernel filesystems are mounted as
  52. explained in <xref linkend="ch-tools-bindmount"/> and <xref
  53. linkend="ch-tools-kernfsmount"/> and enter chroot again before continuing
  54. with the installation.</para>
  55. </note>
  56. </sect1>