source: chapter06/createfiles.xml@ 0b403eb3

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 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 0b403eb3 was effe07a, checked in by Pierre Labastie <pieere@…>, 4 years ago

Fix circular deps between util-linux and eudev/systemd:

  • build util-linux in chapter 5 for both books
  • move eudev before util-linux in chapter 6
  • make utils-linux libs and headers accessible to /usr in "Creating essential ..."
  • not related, but forgotten at previous commit: make also libfl flex library accessible to /usr

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@11817 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<screen><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
46ln -sv /tools/lib/libfl.so* /usr/lib
47
48ln -sv bash /bin/sh
49
50for lib in blkid mount uuid fdisk
51do
52 ln -sv /tools/lib/lib$lib.so* /usr/lib
53 sed 's|/tools|/usr|' /tools/lib/pkgconfig/${lib}.pc \
54 &gt; /usr/lib/pkgconfig/${lib}.pc
55done
56for incdir in blkid libmount uuid libfdisk
57do
58 ln -svf /tools/include/$incdir /usr/include
59done</userinput></screen>
60
61 <variablelist>
62 <title>The purpose of each link:</title>
63
64 <varlistentry>
65 <term><parameter><filename>/bin/bash</filename></parameter></term>
66 <listitem>
67 <para>Many <command>bash</command> scripts specify
68 <filename>/bin/bash</filename>.</para>
69 </listitem>
70 </varlistentry>
71
72 <varlistentry>
73 <term><parameter><filename>/bin/cat</filename></parameter></term>
74 <listitem>
75 <para>This pathname is hard-coded into Glibc's configure script.</para>
76 </listitem>
77 </varlistentry>
78
79 <varlistentry>
80 <term><parameter><filename>/bin/dd</filename></parameter></term>
81 <listitem>
82 <para>The path to <filename>dd</filename> will be hard-coded into the
83 <filename>/usr/bin/libtool</filename> utility.</para>
84 </listitem>
85 </varlistentry>
86
87 <varlistentry>
88 <term><parameter><filename>/bin/echo</filename></parameter></term>
89 <listitem>
90 <para>This is to satisfy one of the tests in Glibc's test suite, which
91 expects <filename>/bin/echo</filename>.</para>
92 </listitem>
93 </varlistentry>
94
95 <varlistentry>
96 <term><parameter><filename>/usr/bin/env</filename></parameter></term>
97 <listitem>
98 <para>This pathname is hard-coded into some packages build procedures.
99 <!-- systemd This may not be needed if we move sysd to the end--></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>/bin/sh</filename></parameter></term>
170 <listitem>
171 <para>Many shell scripts hard-code <filename>/bin/sh</filename>.</para>
172 </listitem>
173 </varlistentry>
174
175 <varlistentry>
176 <term>
177 <parameter><filename>/usr/lib/libfl.so*</filename></parameter>
178 </term>
179 <listitem>
180 <para>This link allows binutils to find the flex library, and to
181 build enhanced versions of ar and ranlib.</para>
182 </listitem>
183 </varlistentry>
184
185 <varlistentry>
186 <term>
187 <parameter>
188 <filename>/usr/lib/lib{blkid,fdisk,mount,uuid}.so*</filename>,
189 <filename>/usr/include/{blkid,libfdisk,libmount,uuid}</filename>,
190 <filename>/usr/lib/pkgconfig/{blkid,fdisk,mount,uuid}.pc</filename>
191 </parameter>
192 </term>
193 <listitem>
194 <para>These links and files allow
195 <phrase revision="sysv">eudev</phrase>
196 <phrase revision="systemd">systemd</phrase> to find the
197 util-linux libraries installed in chapter 5, without creating
198 wrong references to /tools. The uuid library is also needed for
199 building a python module.</para>
200 </listitem>
201 </varlistentry>
202
203 </variablelist>
204
205 <para>Historically, Linux maintains a list of the mounted file systems in the
206 file <filename>/etc/mtab</filename>. Modern kernels maintain this list
207 internally and exposes it to the user via the <filename
208 class="directory">/proc</filename> filesystem. To satisfy utilities that
209 expect the presence of <filename>/etc/mtab</filename>, create the following
210 symbolic link:</para>
211
212<screen><userinput>ln -sv /proc/self/mounts /etc/mtab</userinput></screen>
213
214 <para>In order for user <systemitem class="username">root</systemitem> to be
215 able to login and for the name <quote>root</quote> to be recognized, there
216 must be relevant entries in the <filename>/etc/passwd</filename> and
217 <filename>/etc/group</filename> files.</para>
218
219 <para>Create the <filename>/etc/passwd</filename> file by running the following
220 command:</para>
221
222<screen revision="sysv"><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
227nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>
228EOF</userinput></screen>
229
230<screen revision="systemd"><userinput>cat &gt; /etc/passwd &lt;&lt; "EOF"
231<literal>root:x:0:0:root:/root:/bin/bash
232bin:x:1:1:bin:/dev/null:/bin/false
233daemon:x:6:6:Daemon User:/dev/null:/bin/false
234messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
235systemd-bus-proxy:x:72:72:systemd Bus Proxy:/:/bin/false
236systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/bin/false
237systemd-journal-remote:x:74:74:systemd Journal Remote:/:/bin/false
238systemd-journal-upload:x:75:75:systemd Journal Upload:/:/bin/false
239systemd-network:x:76:76:systemd Network Management:/:/bin/false
240systemd-resolve:x:77:77:systemd Resolver:/:/bin/false
241systemd-timesync:x:78:78:systemd Time Synchronization:/:/bin/false
242systemd-coredump:x:79:79:systemd Core Dumper:/:/bin/false
243nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>
244EOF</userinput></screen>
245
246 <para>The actual password for <systemitem class="username">root</systemitem>
247 (the <quote>x</quote> used here is just a placeholder) will be set later.</para>
248
249 <para>Create the <filename>/etc/group</filename> file by running the following
250 command:</para>
251
252<screen revision="sysv"><userinput>cat &gt; /etc/group &lt;&lt; "EOF"
253<literal>root:x:0:
254bin:x:1:daemon
255sys:x:2:
256kmem:x:3:
257tape:x:4:
258tty:x:5:
259daemon:x:6:
260floppy:x:7:
261disk:x:8:
262lp:x:9:
263dialout:x:10:
264audio:x:11:
265video:x:12:
266utmp:x:13:
267usb:x:14:
268cdrom:x:15:
269adm:x:16:
270messagebus:x:18:
271input:x:24:
272mail:x:34:
273kvm:x:61:
274wheel:x:97:
275nogroup:x:99:
276users:x:999:</literal>
277EOF</userinput></screen>
278
279<screen revision="systemd"><userinput>cat &gt; /etc/group &lt;&lt; "EOF"
280<literal>root:x:0:
281bin:x:1:daemon
282sys:x:2:
283kmem:x:3:
284tape:x:4:
285tty:x:5:
286daemon:x:6:
287floppy:x:7:
288disk:x:8:
289lp:x:9:
290dialout:x:10:
291audio:x:11:
292video:x:12:
293utmp:x:13:
294usb:x:14:
295cdrom:x:15:
296adm:x:16:
297messagebus:x:18:
298systemd-journal:x:23:
299input:x:24:
300mail:x:34:
301kvm:x:61:
302systemd-bus-proxy:x:72:
303systemd-journal-gateway:x:73:
304systemd-journal-remote:x:74:
305systemd-journal-upload:x:75:
306systemd-network:x:76:
307systemd-resolve:x:77:
308systemd-timesync:x:78:
309systemd-coredump:x:79:
310wheel:x:97:
311nogroup:x:99:
312users:x:999:</literal>
313EOF</userinput></screen>
314
315 <para>The created groups are not part of any standard&mdash;they are groups
316 decided on in part by the requirements of the Udev configuration in this
317 chapter, and in part by common convention employed by a number of existing
318 Linux distributions. In addition, some test suites rely on specific users
319 or groups. The Linux Standard Base (LSB, available at <ulink
320 url="http://www.linuxbase.org"/>) recommends only that, besides the group
321 <systemitem class="groupname">root</systemitem> with a Group ID (GID) of 0,
322 a group <systemitem class="groupname">bin</systemitem> with a GID of 1 be
323 present. All other group names and GIDs can be chosen freely by the system
324 administrator since well-written programs do not depend on GID numbers, but
325 rather use the group's name.</para>
326
327 <para>To remove the <quote>I have no name!</quote> prompt, start a new
328 shell. Since a full Glibc was installed in <xref
329 linkend="chapter-temporary-tools"/> and the
330 <filename>/etc/passwd</filename> and <filename>/etc/group</filename>
331 files have been created, user name and group name resolution will now
332 work:</para>
333
334<screen role="nodump"><userinput>exec /tools/bin/bash --login +h</userinput></screen>
335
336 <para>Note the use of the <parameter>+h</parameter> directive. This tells
337 <command>bash</command> not to use its internal path hashing. Without this
338 directive, <command>bash</command> would remember the paths to binaries it has
339 executed. To ensure the use of the newly compiled binaries as soon as they are
340 installed, the <parameter>+h</parameter> directive will be used for the duration
341 of this chapter.</para>
342
343 <para>The <command>login</command>, <command>agetty</command>, and
344 <command>init</command> programs (and others) use a number of log
345 files to record information such as who was logged into the system and
346 when. However, these programs will not write to the log files if they
347 do not already exist. Initialize the log files and give them
348 proper permissions:</para>
349
350<screen><userinput>touch /var/log/{btmp,lastlog,faillog,wtmp}
351chgrp -v utmp /var/log/lastlog
352chmod -v 664 /var/log/lastlog
353chmod -v 600 /var/log/btmp</userinput></screen>
354
355 <para>The <filename>/var/log/wtmp</filename> file records all logins and
356 logouts. The <filename>/var/log/lastlog</filename> file records when each
357 user last logged in. The <filename>/var/log/faillog</filename> file records
358 failed login attempts. The <filename>/var/log/btmp</filename> file records
359 the bad login attempts.</para>
360
361 <note><para>The <filename>/run/utmp</filename> file records the users that
362 are currently logged in. This file is created dynamically in the boot
363 scripts.</para></note>
364
365</sect1>
Note: See TracBrowser for help on using the repository browser.