source: chapter06/createfiles.xml@ 160e72c

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

MultiLib: Merge changes up to 11858

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

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