source: chapter06/createfiles.xml@ 5a430f1

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 5a430f1 was 5a430f1, checked in by Xi Ruoyao <xry111@…>, 4 years ago

remove symlink to libfl.so, to satisify flex removal from chap5

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

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