Ignore:
Timestamp:
02/26/2022 03:43:11 PM (2 years ago)
Author:
Xi Ruoyao <xry111@…>
Branches:
xry111/clfs-ng
Children:
ae636e7
Parents:
fa7acfc
git-author:
Xi Ruoyao <xry111@…> (08/25/2021 05:30:13 AM)
git-committer:
Xi Ruoyao <xry111@…> (02/26/2022 03:43:11 PM)
Message:

cross-ng: chapter 7: adjust introduction for cross build

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chapter07/chroot.xml

    rfa7acfc rfebac51  
    77
    88<sect1 id="ch-tools-chroot">
    9   <?dbhtml filename="chroot.html"?>
     9  <?dbhtml filename="env.html"?>
    1010
    11   <title>Entering the Chroot Environment</title>
     11  <title>Setting up the Environment</title>
    1212
    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 to
    15   finish installing the remaining temporary tools. This environment will be in
    16   use also for installing 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 only the temporary
    19   tools:</para>
     13    <para>The standard I/O streams of the initial shell process is connected
     14    with <filename>/dev/console</filename>.  However, the testsuite of some
     15    packages may expect the standard I/O streams to be connected with a
     16    <quote>real</quote> TTY device node.  Spawn a new shell process on the
     17    TTY device with <command>agetty</command>:</para>
    2018
    21 <screen role="nodump"><userinput>chroot "$LFS" /usr/bin/env -i   \
     19<screen role="nodump"><userinput>agetty -n -l /bin/bash <replaceable>tty0</replaceable></userinput></screen>
     20
     21    <para>If you are working via a serial console, replace
     22    <replaceable>tty0</replaceable> with the name of the serial console
     23    device node, for example <literal>ttyS0</literal>.</para>
     24
     25    <para>The command above spawns a new shell process on the TTY device
     26    specified in the command, and the initial shell process will run in
     27    background as an init process with very limited functions. The new shell
     28    process will output:</para>
     29
     30<screen role="nodump"><computeroutput>bash: cannot set terminal process group (-1): Inappropriate ioctl for device
     31bash: no job control in this shell</computeroutput></screen>
     32
     33    <para>This is normal because the shell is not assigned with a
     34    controlling terminal yet.  Now set up controlling terminal and
     35    environment variables:</para>
     36
     37<screen><userinput>exec setsid -c /usr/bin/env -i  \
    2238    HOME=/root                  \
    2339    TERM="$TERM"                \
    24     PS1='(lfs chroot) \u:\w\$ ' \
     40    PS1='(lfs) \u:\w\$ '        \
    2541    PATH=/usr/bin:/usr/sbin     \
    2642    /bin/bash --login</userinput></screen>
    2743
     44    <para>The command replace the current shell process with a new shell
     45    process, with controlling terminal set up.</para>
     46
    2847  <para>The <parameter>-i</parameter> option given to the <command>env</command>
    29   command will clear all variables of the chroot environment. After that, only
     48  command will clear all variables of the environment. After that, only
    3049  the <envar>HOME</envar>, <envar>TERM</envar>, <envar>PS1</envar>, and
    3150  <envar>PATH</envar> variables are set again. The
    3251  <parameter>TERM=$TERM</parameter> construct will set the <envar>TERM</envar>
    33   variable inside chroot to the same value as outside chroot. This variable is
     52  variable to the default value specified by <command>agetty</command>. This variable is
    3453  needed for programs like <command>vim</command> and <command>less</command>
    3554  to operate properly.  If other variables are desired, such as
     
    3756  them again.</para>
    3857
    39   <para>From this point on, there is no need to use the
    40   <envar>LFS</envar> variable anymore because all work will be restricted
    41   to the LFS file system.  This is because the Bash shell is told that
    42   <filename class="directory">$LFS</filename> is now the root
    43   (<filename class="directory">/</filename>) directory.</para>
    44 
    4558  <para>Notice that <filename class="directory">/tools/bin</filename> is not
    4659  in the <envar>PATH</envar>. This means that the cross toolchain will no longer be
    47   used in the chroot environment.</para>
     60  used on the target machine.</para>
    4861
    4962  <para>Note that the <command>bash</command> prompt will say
     
    5366  <note>
    5467    <para>It is important that all the commands throughout the remainder of this
    55     chapter and the following chapters are run from within the chroot
    56     environment. If you leave this environment for any reason (rebooting for
     68    chapter and the following chapters are run from within the environment
     69    we've set. If you leave this environment for any reason (rebooting for
    5770    example), ensure that the virtual kernel filesystems are mounted as
    58     explained in <xref linkend="ch-tools-bindmount"/> and <xref
    59     linkend="ch-tools-kernfsmount"/> and enter chroot again before continuing
    60     with the installation.</para>
     71    explained in <xref linkend="ch-tools-kernfsmount"/> and
     72    <xref linkend="ch-tools-devadjust"/> and set up the environment again before
     73    continuing with the installation.</para>
    6174  </note>
    6275
Note: See TracChangeset for help on using the changeset viewer.