chroot.xml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/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 in order to begin building
  10. and installing your final LFS system. Still as <emphasis>root</emphasis> run
  11. the following command to enter the small world that is, at the moment,
  12. populated with only the temporary tools:</para>
  13. <screen><userinput>chroot "$LFS" /tools/bin/env -i \
  14. HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
  15. PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
  16. /tools/bin/bash --login +h</userinput></screen>
  17. <para>The <parameter>-i</parameter> option given to the
  18. <command>env</command> command will clear all variables of the chroot
  19. environment. After that, only the HOME, TERM, PS1 and PATH variables are
  20. set again. The <parameter>TERM=$TERM</parameter> construct will set the TERM variable inside chroot
  21. to the same value as outside chroot; this variable is needed for programs
  22. like <command>vim</command> and <command>less</command> to operate
  23. properly. If you need other variables present, such as CFLAGS or CXXFLAGS,
  24. this is a good place to set them again.</para>
  25. <para>From this point on there's no need to use the LFS variable anymore,
  26. because everything you do will be restricted to the LFS file system -- since
  27. what the shell thinks is <filename class="directory">/</filename> is actually
  28. the value of <filename class="directory">$LFS</filename>, which was passed to
  29. the chroot command.</para>
  30. <para>Notice that <filename class="directory">/tools/bin</filename> comes
  31. last in the PATH. This means that a temporary tool will not be used any more
  32. as soon as its final version is installed. Well, at least when the shell
  33. doesn't remember the locations of executed binaries -- for this reason hashing
  34. is switched off by passing the <parameter>+h</parameter> option to
  35. <command>bash</command>.</para>
  36. <para>You have to make sure all the commands in the rest of this chapter and
  37. in the following chapters are run from within the chroot environment.
  38. If you ever leave this environment for any reason (rebooting for example),
  39. you must remember to first mount the <systemitem class="filesystem">proc</systemitem>
  40. and <systemitem class="filesystem">devpts</systemitem> file systems (discussed
  41. in the previous section) <emphasis>and</emphasis> enter chroot again before
  42. continuing with the installations.</para>
  43. <para>Note that the <command>bash</command> prompt will say
  44. <computeroutput>I have no name!</computeroutput> This is
  45. normal, as the <filename>/etc/passwd</filename> file has not been created yet.
  46. </para>
  47. </sect1>