source: BOOK/chroot/x86/before-chroot.xml @ a7a05cf

clfs-3.0.0-systemdsystemd
Last change on this file since a7a05cf was a7a05cf, checked in by Chris Staub <chris@…>, 10 years ago

Updated text in before-chroot page

  • Property mode set to 100644
File size: 5.8 KB
RevLine 
[42a32ea]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-chroot-before-chroot">
9  <?dbhtml filename="before-chroot.html"?>
10  <title>Before Entering the Chroot Environment</title>
11
12  <sect2 role="determining-ifneeded">
13    <title>Determining if steps need to be taken</title>
14
15    <para>Before we can enter the chroot we have to make sure that the system is
16    in the proper state. From this point on the <envar>${CLFS_TARGET}</envar>
[9d5337b]17    environment variable will no longer exist, so it will have no bearing on the
18    rest of the book - most packages will rely on
[42a32ea]19    <command>config.guess</command> provided by
20    <xref linkend="ch-system-automake"/>. Packages that do not use autotools
[9d5337b]21    either do not care about the target triplet, or have their own means
22    of determining its value.</para>
[42a32ea]23
[9d5337b]24    <para>In both cases, the information about the host cpu used to determine
[42a32ea]25    the target triplet is gathered from the same place,
26    <command>uname -m</command>. Executing this command outside of the chroot
[9d5337b]27    as well as inside the chroot will have the exact same output.</para>
[42a32ea]28
[9d5337b]29   <para>If you're unsure if your host and target have the same target
30    triplet, you can use this test to determine what the host's target triplet
[42a32ea]31    is and if you need to take any steps to ensure that you don't build for the
32    wrong architecture. Extract the <xref linkend="ch-system-automake"/> tarball
33    and <command>cd</command> into the created directory. Then execute the
[9d5337b]34    following to see what the detected target triplet is by
35    <command>config.guess</command>:</para>
[42a32ea]36
[6a24bdf]37<screen><userinput>lib/config.guess</userinput></screen>
[42a32ea]38
39    <para>If the output of that command does not equal what is in
40    <envar>${CLFS_TARGET}</envar> then you need to read on. If it does then you
41    can safely continue onto <xref linkend="ch-chroot-chroot"/>.</para>
42
43  </sect2>
44
45  <sect2 role="using-setarch">
46    <title>Using Setarch</title>
47
[a7a05cf]48    <para>If your host has a tool called <command>setarch</command>, this may
49    solve your problems, at least if you're building for i686. On an
50    architecture such as x86_64, using
51    <command>setarch linux32 uname -m</command> will only
[42a32ea]52    ever output i686. It is not possible to get an output of i486 or i586.</para>
53
54    <para>To test if setarch does everything you need it to, execute the
[9d5337b]55    following command from inside the <xref linkend="ch-system-automake"/>
[42a32ea]56    directory:</para>
57
[6a24bdf]58<screen><userinput>setarch linux32 lib/config.guess</userinput></screen>
[42a32ea]59
60    <para>If the output of the command above equals what is in
61    <envar>${CLFS_TARGET}</envar> then you have a viable solution. You can
62    wrap the chroot command on the next page with
63    <command>setarch linux32</command>. It will look like the following:</para>
64
65<screen><userinput>setarch linux32 chroot "${CLFS}" /tools/bin/env -i \
66    HOME=/root TERM="${TERM}" PS1='\u:\w\$ ' \
67    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
68    /tools/bin/bash --login +h</userinput></screen>
69
70    <para>If setarch works for you then you can safely continue onto
71    <xref linkend="ch-chroot-chroot"/>. If not, there is one more option
72    covered in this book.</para>
73
74  </sect2>
75
76  <sect2 role="using-uname_hack">
77    <title>Using a Uname Hack</title>
78
79    <para os="uua">The Uname Hack is a kernel module that modifies the output of
80    <command>uname -m</command> by directly changing the value of the
81    detected machine type. The kernel module will save the original value
82    and restore it when the module is unloaded.</para>
83
84    <variablelist os="uub" role="materials">
85      <varlistentry>
86        <term>Uname Hack (&uname_hack-version;) - &uname_hack-size;:</term>
87
88        <listitem>
89          <para>Home page: <ulink url="&uname_hack-home;"/></para>
90          <para>Download: <ulink url="&uname_hack-url;"/></para>
91          <para>MD5 sum: <literal>&uname_hack-md5;</literal></para>
92        </listitem>
93      </varlistentry>
94    </variablelist>
95
96    <para os="uuc">Extract the tarball and <command>cd</command> into the
97    created directory. To build the Uname Hack you must have the kernel sources
[9d5337b]98    for your currently running kernel available. Build the Uname Hack with the
[42a32ea]99    following or similar command:</para>
100
101<screen os="uud"><userinput>make uname_hack_fake_machine=i486</userinput></screen>
102
[bba53b5]103    <variablelist os="uue">
104      <title>The meaning of the make and install options:</title>
105
106      <varlistentry os="uue1">
107        <term><parameter>uname_hack_fake_machine=i486</parameter></term>
108        <listitem>
109          <para>This parameter sets the value that the uts machine type will be
[9d5337b]110          changed to. Alternatively this could be set to i586 or i686.</para>
[bba53b5]111        </listitem>
112      </varlistentry>
113
114    </variablelist>
115
[9d5337b]116    <para os="uuf">In the top level directory of the Uname Hack package you
117    should see a file named <filename>uname_hack.ko</filename>. As soon as
118    that module is loaded into the running kernel the output of
119    <command>uname -m</command> will be affected immediately system-wide.
120    Load the kernel module with the following command:</para>
[42a32ea]121
[bba53b5]122<screen os="uug"><userinput>insmod uname_hack.ko</userinput></screen>
[42a32ea]123
[bba53b5]124    <para os="uuh">To test if the Uname Hack is working properly, execute the
[9d5337b]125    following command from inside the <xref linkend="ch-system-automake"/>
[42a32ea]126    directory:</para>
127
[6a24bdf]128<screen os="uui"><userinput>lib/config.guess</userinput></screen>
[42a32ea]129
[bba53b5]130    <para os="uuj">The output of the above command should be the same as the
[9d5337b]131    <envar>${CLFS_TARGET}</envar> environment variable. If this is not the
132    case, you can try and get help on the CLFS Support Mailing List or the
[42a32ea]133    IRC Channel. See <xref linkend="ch-intro-askforhelp"/> for more
134    information.</para>
135
136  </sect2>
137
138</sect1>
Note: See TracBrowser for help on using the repository browser.