source: chapter06/createfiles.xml@ 92c9489

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 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 92c9489 was 92c9489, checked in by Bruce Dubbs <bdubbs@…>, 6 years ago

Update tar-1.30.
Update meson-0.44.0.
Update to systemd-236.
Update to linux-4.14.6.

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