source: chapter06/createfiles.xml@ f1e1fe6

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 f1e1fe6 was f1e1fe6, checked in by DJ Lucas <dj@…>, 6 years ago

Simplify linking for systemd and remove text references to /tools/include.

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

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