source: chapter07/chroot.xml@ 95ebbb4

12.1 12.1-rc1 multilib trunk xry111/arm64 xry111/clfs-ng xry111/loongarch xry111/loongarch-12.1 xry111/mips64el xry111/update-glibc
Last change on this file since 95ebbb4 was 95ebbb4, checked in by Xi Ruoyao <xry111@…>, 8 months ago

chroot: Set MAKEFLAGS and TESTSUITEFLAGS for parallelism

  • Property mode set to 100644
File size: 3.6 KB
Line 
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
8<sect1 id="ch-tools-chroot">
9 <?dbhtml filename="chroot.html"?>
10
11 <title>Entering the Chroot Environment</title>
12
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>
20
21<screen role="nodump"><userinput>chroot "$LFS" /usr/bin/env -i \
22 HOME=/root \
23 TERM="$TERM" \
24 PS1='(lfs chroot) \u:\w\$ ' \
25 PATH=/usr/bin:/usr/sbin \
26 MAKEFLAGS="-j<replaceable>$(nproc)</replaceable>" \
27 TESTSUITEFLAGS="-j<replaceable>$(nproc)</replaceable>" \
28 /bin/bash --login</userinput></screen>
29
30 <para>
31 Again, replace <replaceable>$(nproc)</replaceable> with the number
32 of logical cores you want to use for building packages in this chapter
33 and the following chapters if you don't want to use all available
34 logical cores. The test suites of some packages (notably Autoconf,
35 Libtool, and Tar) in &ch-final; are not affected by
36 <envar>MAKEFLAGS</envar>, they use a <envar>TESTSUITEFLAGS</envar>
37 environment variable instead. So we set it here as well for running
38 these test suites with multiple cores.
39 </para>
40
41 <para>The <parameter>-i</parameter> option given to the <command>env</command>
42 command will clear all the variables in the chroot environment. After that, only
43 the <envar>HOME</envar>, <envar>TERM</envar>, <envar>PS1</envar>, and
44 <envar>PATH</envar> variables are set again. The
45 <parameter>TERM=$TERM</parameter> construct sets the <envar>TERM</envar>
46 variable inside chroot to the same value as outside chroot. This variable is
47 needed so programs like <command>vim</command> and <command>less</command>
48 can operate properly. If other variables are desired, such as
49 <envar>CFLAGS</envar> or <envar>CXXFLAGS</envar>, this is a good place to set
50 them.</para>
51
52 <para>From this point on, there is no need to use the
53 <envar>LFS</envar> variable any more because all work will be restricted
54 to the LFS file system; the <command>chroot</command> command runs the
55 Bash shell with the root
56 (<filename class="directory">/</filename>) directory set to
57 <filename class='directory'>$LFS</filename>.</para>
58
59 <para>Notice that <filename class="directory">/tools/bin</filename> is not
60 in the <envar>PATH</envar>. This means that the cross toolchain will no longer be
61 used.</para>
62
63 <para>Note that the <command>bash</command> prompt will say
64 <computeroutput>I have no name!</computeroutput> This is normal because the
65 <filename>/etc/passwd</filename> file has not been created yet.</para>
66
67 <note>
68 <para>It is important that all the commands throughout the remainder of this
69 chapter and the following chapters are run from within the chroot
70 environment. If you leave this environment for any reason (rebooting for
71 example), ensure that the virtual kernel filesystems are mounted as
72 explained in <xref linkend="ch-tools-bindmount"/> and <xref
73 linkend="ch-tools-kernfsmount"/> and enter chroot again before continuing
74 with the installation.</para>
75 </note>
76
77</sect1>
Note: See TracBrowser for help on using the repository browser.