Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • chapter07/chroot.xml

    re49e2ea r7152faa  
    1 <?xml version="1.0" encoding="ISO-8859-1"?>
     1<?xml version="1.0" encoding="UTF-8"?>
    22<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
    33  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
     
    77
    88<sect1 id="ch-tools-chroot">
    9   <?dbhtml filename="env.html"?>
     9  <?dbhtml filename="chroot.html"?>
    1010
    11   <title>Setting up the Environment</title>
     11  <title>Entering the Chroot Environment</title>
    1212
    13     <para>The current shell is also the <command>init</command> process,
    14     so exiting from it will cause kernel panic.  Prevent exiting from the
    15     shell accidentally:</para>
     13  <para>Now that all the packages which are required to build the rest of the
     14  needed tools are on the system, it is time to enter the chroot environment and
     15  finish installing the temporary tools. This environment will also be
     16  used to install the final system. As user <systemitem
     17  class="username">root</systemitem>, run the following command to enter the
     18  environment that is, at the moment, populated with nothing but temporary
     19  tools:</para>
    1620
    17 <screen role="nodump"><userinput>enable -n exit
    18 readonly IGNOREEOF=1000</userinput></screen>
    19 
    20     <para>The standard I/O streams of the initial shell process is connected
    21     with <filename>/dev/console</filename>.  However, the testsuite of some
    22     packages may expect the standard I/O streams to be connected with a
    23     <quote>real</quote> TTY device node.  Spawn a new shell process on the
    24     TTY device with <command>agetty</command>:</para>
    25 
    26 <screen role="nodump"><userinput>agetty -n -l /bin/bash <replaceable>tty0</replaceable></userinput></screen>
    27 
    28     <para>If you are working via a serial console, replace
    29     <replaceable>tty0</replaceable> with the name of the serial console
    30     device node, for example <literal>ttyS0</literal>.</para>
    31 
    32     <para>The command above spawns a new shell process on the TTY device
    33     specified in the command, and the initial shell process will run in
    34     background as an init process with very limited functions. The new shell
    35     process will output:</para>
    36 
    37 <screen role="nodump"><computeroutput>bash: cannot set terminal process group (-1): Inappropriate ioctl for device
    38 bash: no job control in this shell</computeroutput></screen>
    39 
    40     <para>This is normal because the shell is not assigned with a
    41     controlling terminal yet.  Now set up the controlling terminal and
    42     some environment variables:</para>
    43 
    44 <screen><userinput>exec setsid -c /usr/bin/env -i  \
     21<screen role="nodump"><userinput>chroot "$LFS" /usr/bin/env -i   \
    4522    HOME=/root                  \
    4623    TERM="$TERM"                \
    47     PS1='(lfs) \u:\w\$ '        \
     24    PS1='(lfs chroot) \u:\w\$ ' \
    4825    PATH=/usr/bin:/usr/sbin     \
    4926    MAKEFLAGS="-j<replaceable>$(nproc)</replaceable>"      \
    5027    TESTSUITEFLAGS="-j<replaceable>$(nproc)</replaceable>" \
    5128    /bin/bash --login</userinput></screen>
    52 
    53     <para>The command replaces the current shell process with a new shell
    54     process, with controlling terminal set up.</para>
    5529
    5630  <para>
     
    6539
    6640  <para>The <parameter>-i</parameter> option given to the <command>env</command>
    67   command will clear all the variables in the environment. After that, only
     41  command will clear all the variables in the chroot environment. After that, only
    6842  the <envar>HOME</envar>, <envar>TERM</envar>, <envar>PS1</envar>, and
    6943  <envar>PATH</envar> variables are set again. The
    70   <parameter>TERM=$TERM</parameter> construct will set the <envar>TERM</envar>
    71   variable to the default value specified by <command>agetty</command>. This variable is
     44  <parameter>TERM=$TERM</parameter> construct sets the <envar>TERM</envar>
     45  variable inside chroot to the same value as outside chroot. This variable is
    7246  needed so programs like <command>vim</command> and <command>less</command>
    7347  can operate properly.  If other variables are desired, such as
    7448  <envar>CFLAGS</envar> or <envar>CXXFLAGS</envar>, this is a good place to set
    7549  them.</para>
     50
     51  <para>From this point on, there is no need to use the
     52  <envar>LFS</envar> variable any more because all work will be restricted
     53  to the LFS file system; the <command>chroot</command> command runs the
     54  Bash shell with the root
     55  (<filename class="directory">/</filename>) directory set to
     56  <filename class='directory'>$LFS</filename>.</para>
    7657
    7758  <para>Notice that <filename class="directory">/tools/bin</filename> is not
     
    8364  <filename>/etc/passwd</filename> file has not been created yet.</para>
    8465
    85   <para>Now set up a temporary hostname, which is required by test suite of
    86   some packages:</para>
    87 
    88 <screen><userinput>hostname lfs</userinput></screen>
    89 
    9066  <note>
    9167    <para>It is important that all the commands throughout the remainder of this
    92     chapter and the following chapters are run from within the environment
    93     we've set. If you leave this environment for any reason (rebooting for
     68    chapter and the following chapters are run from within the chroot
     69    environment. If you leave this environment for any reason (rebooting for
    9470    example), ensure that the virtual kernel filesystems are mounted as
    95     explained in <xref linkend="ch-tools-kernfsmount"/> and
    96     <xref linkend="ch-tools-devadjust"/> and set up the environment again before
    97     continuing with the installation.</para>
     71    explained in <xref linkend="ch-tools-bindmount"/> and <xref
     72    linkend="ch-tools-kernfsmount"/> and enter chroot again before continuing
     73    with the installation.</para>
    9874  </note>
    9975
Note: See TracChangeset for help on using the changeset viewer.