source: chapter06/createfiles.xml@ 8054162

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 8.3 8.3-rc1 8.3-rc2 8.4 8.4-rc1 9.0 9.0-rc1 9.1 9.1-rc1 cross-chap5 ml-11.0 multilib old-trunk trunk xry111/git-transition xry111/glibc-2.34 xry111/tester-nohack xry111/usr-move
Last change on this file since 8054162 was 8054162, checked in by Bruce Dubbs <bdubbs@…>, 3 years ago

Make symbolic links in inital part of Chapter 6 consistent
for all versions of the book. Allows removing environment
variables no longer needed with e2fsprogs.

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

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