source: chapter06/createfiles.xml@ 0aaf6a31

ml-11.0 multilib xry111/multilib
Last change on this file since 0aaf6a31 was 0aaf6a31, checked in by Xℹ Ruoyao <xry111@…>, 3 years ago

MultiLib: Merge changes from trunk

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/multilib@11681 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 13.2 KB
RevLine 
[673b0d8]1<?xml version="1.0" encoding="ISO-8859-1"?>
[b06ca36]2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
[673b0d8]4 <!ENTITY % general-entities SYSTEM "../general.ent">
5 %general-entities;
6]>
[8ef8304]7
[673b0d8]8<sect1 id="ch-system-createfiles">
[8ef8304]9 <?dbhtml filename="createfiles.html"?>
10
[d2c332bc]11 <title>Creating Essential Files and Symlinks</title>
12
13 <indexterm zone="ch-system-createfiles">
14 <primary sortas="e-/etc/passwd">/etc/passwd</primary>
15 </indexterm>
16
17 <indexterm zone="ch-system-createfiles">
18 <primary sortas="e-/etc/group">/etc/group</primary>
19 </indexterm>
20
21 <indexterm zone="ch-system-createfiles">
22 <primary sortas="e-/var/run/utmp">/var/run/utmp</primary>
23 </indexterm>
24
25 <indexterm zone="ch-system-createfiles">
26 <primary sortas="e-/var/log/btmp">/var/log/btmp</primary>
27 </indexterm>
28
29 <indexterm zone="ch-system-createfiles">
30 <primary sortas="e-/var/log/lastlog">/var/log/lastlog</primary>
31 </indexterm>
32
33 <indexterm zone="ch-system-createfiles">
34 <primary sortas="e-/var/log/wtmp">/var/log/wtmp</primary>
35 </indexterm>
[673b0d8]36
[d1a862d7]37 <para>Some programs use hard-wired paths to programs which do not exist yet.
38 In order to satisfy these programs, create a number of symbolic links which
39 will be replaced by real files throughout the course of this chapter after the
40 software has been installed:</para>
[673b0d8]41
[172244e]42<screen><userinput>ln -sv /tools/bin/{bash,cat,chmod,dd,echo,ln,mkdir,pwd,rm,stty,touch} /bin
[d89628d]43ln -sv /tools/bin/{env,install,perl,printf} /usr/bin
[6c67242]44ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib
45ln -sv /tools/lib/libstdc++.{a,so{,.6}} /usr/lib
[8054162]46
[b3f1ebb3]47ln -sv bash /bin/sh</userinput></screen>
48
[0aaf6a31]49 <para arch="ml_32,ml_x32,ml_all">32-bit builds also require these links:</para>
50
51<screen arch="ml_32,ml_x32,ml_all"><userinput arch="ml_32,ml_all">ln -sv /tools/lib32/libgcc_s.so{,.1} /usr/lib32
52ln -sv /tools/lib32/libstdc++.{a,so{,.6}} /usr/lib32</userinput></screen>
53
54 <para arch="ml_x32,ml_all">x32-bit builds also require these links:</para>
55
56<screen arch="ml_x32,ml_all"><userinput arch="ml_x32,ml_all">ln -sv /tools/libx32/libgcc_s.so{,.1} /usr/libx32
[172244e]57ln -sv /tools/libx32/libstdc++.{a,so{,.6}} /usr/libx32
[0aaf6a31]58ln -sv /usr/libx32 /</userinput></screen>
[a91de2aa]59
[6c67242]60<!--for lib in blkid lzma mount uuid
[d1a862d7]61do
[3f60e0c]62 ln -sv /tools/lib/lib$lib.so* /usr/lib
[6c67242]63done-->
64<!--ln -svf /tools/include/blkid /usr/include
[f1e1fe6]65ln -svf /tools/include/libmount /usr/include
[6c67242]66ln -svf /tools/include/uuid /usr/include-->
67<!--for pc in blkid mount uuid
[f1e1fe6]68do
69 sed 's@tools@usr@g' /tools/lib/pkgconfig/${pc}.pc \
70 > /usr/lib/pkgconfig/${pc}.pc
[6c67242]71done-->
[448e226]72 <variablelist>
73 <title>The purpose of each link:</title>
74
75 <varlistentry>
76 <term><parameter><filename>/bin/bash</filename></parameter></term>
77 <listitem>
78 <para>Many <command>bash</command> scripts specify
79 <filename>/bin/bash</filename>.</para>
80 </listitem>
81 </varlistentry>
82
83 <varlistentry>
84 <term><parameter><filename>/bin/cat</filename></parameter></term>
85 <listitem>
86 <para>This pathname is hard-coded into Glibc's configure script.</para>
87 </listitem>
88 </varlistentry>
89
[d1a862d7]90 <varlistentry>
91 <term><parameter><filename>/bin/dd</filename></parameter></term>
92 <listitem>
93 <para>The path to <filename>dd</filename> will be hard-coded into the
94 <filename>/usr/bin/libtool</filename> utility.</para>
95 </listitem>
96 </varlistentry>
97
[448e226]98 <varlistentry>
99 <term><parameter><filename>/bin/echo</filename></parameter></term>
100 <listitem>
101 <para>This is to satisfy one of the tests in Glibc's test suite, which
102 expects <filename>/bin/echo</filename>.</para>
103 </listitem>
104 </varlistentry>
105
[6c67242]106 <varlistentry>
107 <term><parameter><filename>/usr/bin/env</filename></parameter></term>
108 <listitem>
109 <para>This pathname is hard-coded into some packages build procedures.
110 <!-- systemd This may not be needed if we move sysd to the end--></para>
111 </listitem>
112 </varlistentry>
113
[d1a862d7]114 <varlistentry>
115 <term><parameter><filename>/usr/bin/install</filename></parameter></term>
116 <listitem>
117 <para>The path to <filename>install</filename> will be hard-coded into
118 the <filename>/usr/lib/bash/Makefile.inc</filename> file.</para>
119 </listitem>
120 </varlistentry>
121
122 <varlistentry>
123 <term><parameter><filename>/bin/ln</filename></parameter></term>
124 <listitem>
125 <para>The path to <filename>ln</filename> will be hard-coded into the
126 <filename>/usr/lib/perl5/&perl-version;/&lt;target-triplet&gt;/Config_heavy.pl</filename>
127 file.</para>
128 </listitem>
129 </varlistentry>
130
[448e226]131 <varlistentry>
132 <term><parameter><filename>/bin/pwd</filename></parameter></term>
133 <listitem>
134 <para>Some <command>configure</command> scripts, particularly Glibc's,
135 have this pathname hard-coded.</para>
136 </listitem>
137 </varlistentry>
138
[d1a862d7]139 <varlistentry>
140 <term><parameter><filename>/bin/rm</filename></parameter></term>
141 <listitem>
142 <para>The path to <filename>rm</filename> will be hard-coded into the
143 <filename>/usr/lib/perl5/&perl-version;/&lt;target-triplet&gt;/Config_heavy.pl</filename>
144 file.</para>
145 </listitem>
146 </varlistentry>
147
[448e226]148 <varlistentry>
149 <term><parameter><filename>/bin/stty</filename></parameter></term>
150 <listitem>
151 <para>This pathname is hard-coded into Expect, therefore it is needed
152 for Binutils and GCC test suites to pass.</para>
153 </listitem>
154 </varlistentry>
155
156 <varlistentry>
157 <term><parameter><filename>/usr/bin/perl</filename></parameter></term>
158 <listitem>
159 <para>Many Perl scripts hard-code this path to the
160 <command>perl</command> program.</para>
161 </listitem>
162 </varlistentry>
163
164 <varlistentry>
165 <term><parameter><filename>/usr/lib/libgcc_s.so{,.1}</filename></parameter></term>
166 <listitem>
167 <para>Glibc needs this for the pthreads library to work.</para>
168 </listitem>
169 </varlistentry>
170
171 <varlistentry>
172 <term><parameter><filename>/usr/lib/libstdc++{,.6}</filename></parameter></term>
173 <listitem>
174 <para>This is needed by several tests in Glibc's test suite, as well as
175 for C++ support in GMP.</para>
176 </listitem>
177 </varlistentry>
[89970f9]178<!--
[448e226]179 <varlistentry>
180 <term><parameter><filename>/usr/lib/libstdc++.la</filename></parameter></term>
181 <listitem>
182 <para>This prevents a <filename class="directory">/tools</filename>
183 reference that would otherwise be in
184 <filename>/usr/lib/libstdc++.la</filename> after GCC is installed.</para>
185 </listitem>
186 </varlistentry>
[89970f9]187-->
[8054162]188 <!--<varlistentry revision="systemd">-->
[6c67242]189<!-- <varlistentry>
[d1a862d7]190 <term><parameter><filename>/usr/lib/lib{blkid,lzma,mount,uuid}.{a,la,so*}</filename></parameter></term>
191 <listitem>
[6c67242]192 <para>These links prevent utilities from acquiring an
[d1a862d7]193 unnecessary reference to the
194 <filename class="directory">/tools</filename> directory.</para>
195 </listitem>
[6c67242]196 </varlistentry>-->
[d1a862d7]197
[448e226]198 <varlistentry>
199 <term><parameter><filename>/bin/sh</filename></parameter></term>
200 <listitem>
201 <para>Many shell scripts hard-code <filename>/bin/sh</filename>.</para>
202 </listitem>
203 </varlistentry>
204
205 </variablelist>
206
[85e7f3c]207 <para>Historically, Linux maintains a list of the mounted file systems in the
[ba8848f]208 file <filename>/etc/mtab</filename>. Modern kernels maintain this list
[85e7f3c]209 internally and exposes it to the user via the <filename
[ba8848f]210 class="directory">/proc</filename> filesystem. To satisfy utilities that
[85e7f3c]211 expect the presence of <filename>/etc/mtab</filename>, create the following
212 symbolic link:</para>
213
214<screen><userinput>ln -sv /proc/self/mounts /etc/mtab</userinput></screen>
[d2c332bc]215
216 <para>In order for user <systemitem class="username">root</systemitem> to be
217 able to login and for the name <quote>root</quote> to be recognized, there
218 must be relevant entries in the <filename>/etc/passwd</filename> and
219 <filename>/etc/group</filename> files.</para>
220
221 <para>Create the <filename>/etc/passwd</filename> file by running the following
222 command:</para>
223
[1118b17]224<screen revision="sysv"><userinput>cat &gt; /etc/passwd &lt;&lt; "EOF"
[4361397]225<literal>root:x:0:0:root:/root:/bin/bash
[8f90f47d]226bin:x:1:1:bin:/dev/null:/bin/false
[030875a8]227daemon:x:6:6:Daemon User:/dev/null:/bin/false
[f8fe8970]228messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
[390e32c]229nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>
[1118b17]230EOF</userinput></screen>
231
[cbd8bf0f]232<screen revision="systemd"><userinput>cat &gt; /etc/passwd &lt;&lt; "EOF"
[1118b17]233<literal>root:x:0:0:root:/root:/bin/bash
234bin:x:1:1:bin:/dev/null:/bin/false
235daemon:x:6:6:Daemon User:/dev/null:/bin/false
236messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
237systemd-bus-proxy:x:72:72:systemd Bus Proxy:/:/bin/false
238systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/bin/false
239systemd-journal-remote:x:74:74:systemd Journal Remote:/:/bin/false
240systemd-journal-upload:x:75:75:systemd Journal Upload:/:/bin/false
241systemd-network:x:76:76:systemd Network Management:/:/bin/false
242systemd-resolve:x:77:77:systemd Resolver:/:/bin/false
243systemd-timesync:x:78:78:systemd Time Synchronization:/:/bin/false
244systemd-coredump:x:79:79:systemd Core Dumper:/:/bin/false
245nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>
[d2c332bc]246EOF</userinput></screen>
247
248 <para>The actual password for <systemitem class="username">root</systemitem>
249 (the <quote>x</quote> used here is just a placeholder) will be set later.</para>
250
251 <para>Create the <filename>/etc/group</filename> file by running the following
252 command:</para>
253
[1118b17]254<screen revision="sysv"><userinput>cat &gt; /etc/group &lt;&lt; "EOF"
255<literal>root:x:0:
256bin:x:1:daemon
257sys:x:2:
258kmem:x:3:
259tape:x:4:
260tty:x:5:
261daemon:x:6:
262floppy:x:7:
263disk:x:8:
264lp:x:9:
265dialout:x:10:
266audio:x:11:
267video:x:12:
268utmp:x:13:
269usb:x:14:
270cdrom:x:15:
271adm:x:16:
272messagebus:x:18:
273input:x:24:
274mail:x:34:
[e0472a1]275kvm:x:61:
[31bf7e7]276wheel:x:97:
[1118b17]277nogroup:x:99:
278users:x:999:</literal>
279EOF</userinput></screen>
280
281<screen revision="systemd"><userinput>cat &gt; /etc/group &lt;&lt; "EOF"
[d2c332bc]282<literal>root:x:0:
[030875a8]283bin:x:1:daemon
[d2c332bc]284sys:x:2:
285kmem:x:3:
[107e7a5]286tape:x:4:
287tty:x:5:
[d2c332bc]288daemon:x:6:
289floppy:x:7:
290disk:x:8:
291lp:x:9:
[bb8939c]292dialout:x:10:
[d2c332bc]293audio:x:11:
294video:x:12:
295utmp:x:13:
296usb:x:14:
[4361397]297cdrom:x:15:
[f8fe8970]298adm:x:16:
299messagebus:x:18:
300systemd-journal:x:23:
[e4429b7]301input:x:24:
[d1538c0]302mail:x:34:
[92c9489]303kvm:x:61:
[1118b17]304systemd-bus-proxy:x:72:
305systemd-journal-gateway:x:73:
306systemd-journal-remote:x:74:
307systemd-journal-upload:x:75:
308systemd-network:x:76:
309systemd-resolve:x:77:
310systemd-timesync:x:78:
311systemd-coredump:x:79:
[b8cb3b3]312wheel:x:97:
[030875a8]313nogroup:x:99:
314users:x:999:</literal>
[d2c332bc]315EOF</userinput></screen>
316
317 <para>The created groups are not part of any standard&mdash;they are groups
318 decided on in part by the requirements of the Udev configuration in this
319 chapter, and in part by common convention employed by a number of existing
[030875a8]320 Linux distributions. In addition, some test suites rely on specific users
321 or groups. The Linux Standard Base (LSB, available at <ulink
[d2c332bc]322 url="http://www.linuxbase.org"/>) recommends only that, besides the group
323 <systemitem class="groupname">root</systemitem> with a Group ID (GID) of 0,
324 a group <systemitem class="groupname">bin</systemitem> with a GID of 1 be
325 present. All other group names and GIDs can be chosen freely by the system
326 administrator since well-written programs do not depend on GID numbers, but
327 rather use the group's name.</para>
328
329 <para>To remove the <quote>I have no name!</quote> prompt, start a new
330 shell. Since a full Glibc was installed in <xref
331 linkend="chapter-temporary-tools"/> and the
332 <filename>/etc/passwd</filename> and <filename>/etc/group</filename>
333 files have been created, user name and group name resolution will now
[f19e766]334 work:</para>
[d2c332bc]335
336<screen role="nodump"><userinput>exec /tools/bin/bash --login +h</userinput></screen>
337
338 <para>Note the use of the <parameter>+h</parameter> directive. This tells
339 <command>bash</command> not to use its internal path hashing. Without this
340 directive, <command>bash</command> would remember the paths to binaries it has
341 executed. To ensure the use of the newly compiled binaries as soon as they are
342 installed, the <parameter>+h</parameter> directive will be used for the duration
343 of this chapter.</para>
344
345 <para>The <command>login</command>, <command>agetty</command>, and
346 <command>init</command> programs (and others) use a number of log
347 files to record information such as who was logged into the system and
348 when. However, these programs will not write to the log files if they
349 do not already exist. Initialize the log files and give them
350 proper permissions:</para>
351
[5bf238b]352<screen><userinput>touch /var/log/{btmp,lastlog,faillog,wtmp}
[4f2e707]353chgrp -v utmp /var/log/lastlog
354chmod -v 664 /var/log/lastlog
355chmod -v 600 /var/log/btmp</userinput></screen>
[d2c332bc]356
[44f6add]357 <para>The <filename>/var/log/wtmp</filename> file records all logins and
358 logouts. The <filename>/var/log/lastlog</filename> file records when each
[5bf238b]359 user last logged in. The <filename>/var/log/faillog</filename> file records
360 failed login attempts. The <filename>/var/log/btmp</filename> file records
361 the bad login attempts.</para>
[44f6add]362
363 <note><para>The <filename>/run/utmp</filename> file records the users that
364 are currently logged in. This file is created dynamically in the boot
365 scripts.</para></note>
[d2c332bc]366
[673b0d8]367</sect1>
Note: See TracBrowser for help on using the repository browser.