source: chapter06/createfiles.xml@ 8eb3fe4

multilib-10.1
Last change on this file since 8eb3fe4 was 8eb3fe4, checked in by Thomas Trepl <thomas@…>, 5 years ago

First apply of multilib-patch of April 1st, 2019

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

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