source: chapter06/createfiles.xml@ 89970f9

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 8.2 8.2-rc1 8.3 8.3-rc1 8.3-rc2 8.4 8.4-rc1 9.0 9.0-rc1 9.1 9.1-rc1 arm cross-chap5 ml-11.0 multilib old-trunk trunk xry111/clfs-ng xry111/git-transition xry111/glibc-2.34 xry111/lfs-next xry111/tester-nohack xry111/usr-move
Last change on this file since 89970f9 was 89970f9, checked in by Bruce Dubbs <bdubbs@…>, 4 years ago

Update to mpfr-4.0.0.
Update to mpc-1.1.0.

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@11352 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

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