source: chapter06/createfiles.xml@ 0ce8c18

multilib-10.1
Last change on this file since 0ce8c18 was 0ce8c18, checked in by Thomas Trepl <thomas@…>, 4 years ago

Create util-linux-links for {,x}32-bit also

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

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