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
|
---|
43 | ln -sv /tools/bin/{env,install,perl,printf} /usr/bin
|
---|
44 | ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib
|
---|
45 | ln -sv /tools/lib/libstdc++.{a,so{,.6}} /usr/lib
|
---|
46 | ln -sv /tools/lib/libfl.so* /usr/lib
|
---|
47 |
|
---|
48 | ln -sv bash /bin/sh
|
---|
49 | for lib in blkid mount uuid fdisk
|
---|
50 | do
|
---|
51 | ln -sv /tools/lib/lib$lib.so* /usr/lib
|
---|
52 | sed 's|/tools|/usr|' /tools/lib/pkgconfig/${lib}.pc \
|
---|
53 | > /usr/lib/pkgconfig/${lib}.pc
|
---|
54 | done
|
---|
55 | for incdir in blkid libmount uuid libfdisk
|
---|
56 | do
|
---|
57 | ln -svf /tools/include/$incdir /usr/include
|
---|
58 | done
|
---|
59 |
|
---|
60 | mkdir -pv /tools/lib/locale
|
---|
61 | ln -sv /usr/lib/locale/locale-archive /tools/lib/locale</userinput></screen>
|
---|
62 |
|
---|
63 | <para arch="ml_32,ml_all">32-bit builds also require these links:</para>
|
---|
64 |
|
---|
65 | <screen arch="ml_32,ml_all"><userinput>ln -sv /tools/lib32/libgcc_s.so{,.1} /usr/lib32
|
---|
66 | ln -sv /tools/lib32/libstdc++.{a,so{,.6}} /usr/lib32
|
---|
67 | for lib in blkid mount uuid fdisk
|
---|
68 | do
|
---|
69 | ln -sv /tools/lib32/lib$lib.so* /usr/lib32/
|
---|
70 | sed 's|/tools|/usr|' /tools/lib32/pkgconfig/${lib}.pc \
|
---|
71 | > /usr/lib32/pkgconfig/${lib}.pc
|
---|
72 | done</userinput></screen>
|
---|
73 |
|
---|
74 | <para arch="ml_x32,ml_all">x32-bit builds also require these links:</para>
|
---|
75 |
|
---|
76 | <screen arch="ml_x32,ml_all"><userinput>ln -sv /tools/libx32/libgcc_s.so{,.1} /usr/libx32
|
---|
77 | ln -sv /tools/libx32/libstdc++.{a,so{,.6}} /usr/libx32
|
---|
78 | ln -sv /usr/libx32 /
|
---|
79 | for lib in blkid mount uuid fdisk
|
---|
80 | do
|
---|
81 | ln -sv /tools/libx32/lib$lib.so* /usr/libx32/
|
---|
82 | sed 's|/tools|/usr|' /tools/libx32/pkgconfig/${lib}.pc \
|
---|
83 | > /usr/libx32/pkgconfig/${lib}.pc
|
---|
84 | done</userinput></screen>
|
---|
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;/<target-triplet>/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;/<target-triplet>/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>
|
---|
192 |
|
---|
193 | <varlistentry>
|
---|
194 | <term><parameter><filename>/bin/sh</filename></parameter></term>
|
---|
195 | <listitem>
|
---|
196 | <para>Many shell scripts hard-code <filename>/bin/sh</filename>.</para>
|
---|
197 | </listitem>
|
---|
198 | </varlistentry>
|
---|
199 |
|
---|
200 | <varlistentry>
|
---|
201 | <term>
|
---|
202 | <parameter><filename>/usr/lib/libfl.so*</filename></parameter>
|
---|
203 | </term>
|
---|
204 | <listitem>
|
---|
205 | <para>This link allows binutils to find the flex library, and to
|
---|
206 | build enhanced versions of ar and ranlib.</para>
|
---|
207 | </listitem>
|
---|
208 | </varlistentry>
|
---|
209 |
|
---|
210 | <varlistentry>
|
---|
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>
|
---|
225 | </listitem>
|
---|
226 | </varlistentry>
|
---|
227 |
|
---|
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 |
|
---|
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 > /etc/passwd << "EOF"
|
---|
263 | <literal>root:x:0:0:root:/root:/bin/bash
|
---|
264 | bin:x:1:1:bin:/dev/null:/bin/false
|
---|
265 | daemon:x:6:6:Daemon User:/dev/null:/bin/false
|
---|
266 | messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
|
---|
267 | nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>
|
---|
268 | EOF</userinput></screen>
|
---|
269 |
|
---|
270 | <screen revision="systemd"><userinput>cat > /etc/passwd << "EOF"
|
---|
271 | <literal>root:x:0:0:root:/root:/bin/bash
|
---|
272 | bin:x:1:1:bin:/dev/null:/bin/false
|
---|
273 | daemon:x:6:6:Daemon User:/dev/null:/bin/false
|
---|
274 | messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
|
---|
275 | systemd-bus-proxy:x:72:72:systemd Bus Proxy:/:/bin/false
|
---|
276 | systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/bin/false
|
---|
277 | systemd-journal-remote:x:74:74:systemd Journal Remote:/:/bin/false
|
---|
278 | systemd-journal-upload:x:75:75:systemd Journal Upload:/:/bin/false
|
---|
279 | systemd-network:x:76:76:systemd Network Management:/:/bin/false
|
---|
280 | systemd-resolve:x:77:77:systemd Resolver:/:/bin/false
|
---|
281 | systemd-timesync:x:78:78:systemd Time Synchronization:/:/bin/false
|
---|
282 | systemd-coredump:x:79:79:systemd Core Dumper:/:/bin/false
|
---|
283 | nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>
|
---|
284 | EOF</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 > /etc/group << "EOF"
|
---|
293 | <literal>root:x:0:
|
---|
294 | bin:x:1:daemon
|
---|
295 | sys:x:2:
|
---|
296 | kmem:x:3:
|
---|
297 | tape:x:4:
|
---|
298 | tty:x:5:
|
---|
299 | daemon:x:6:
|
---|
300 | floppy:x:7:
|
---|
301 | disk:x:8:
|
---|
302 | lp:x:9:
|
---|
303 | dialout:x:10:
|
---|
304 | audio:x:11:
|
---|
305 | video:x:12:
|
---|
306 | utmp:x:13:
|
---|
307 | usb:x:14:
|
---|
308 | cdrom:x:15:
|
---|
309 | adm:x:16:
|
---|
310 | messagebus:x:18:
|
---|
311 | input:x:24:
|
---|
312 | mail:x:34:
|
---|
313 | kvm:x:61:
|
---|
314 | wheel:x:97:
|
---|
315 | nogroup:x:99:
|
---|
316 | users:x:999:</literal>
|
---|
317 | EOF</userinput></screen>
|
---|
318 |
|
---|
319 | <screen revision="systemd"><userinput>cat > /etc/group << "EOF"
|
---|
320 | <literal>root:x:0:
|
---|
321 | bin:x:1:daemon
|
---|
322 | sys:x:2:
|
---|
323 | kmem:x:3:
|
---|
324 | tape:x:4:
|
---|
325 | tty:x:5:
|
---|
326 | daemon:x:6:
|
---|
327 | floppy:x:7:
|
---|
328 | disk:x:8:
|
---|
329 | lp:x:9:
|
---|
330 | dialout:x:10:
|
---|
331 | audio:x:11:
|
---|
332 | video:x:12:
|
---|
333 | utmp:x:13:
|
---|
334 | usb:x:14:
|
---|
335 | cdrom:x:15:
|
---|
336 | adm:x:16:
|
---|
337 | messagebus:x:18:
|
---|
338 | systemd-journal:x:23:
|
---|
339 | input:x:24:
|
---|
340 | mail:x:34:
|
---|
341 | kvm:x:61:
|
---|
342 | systemd-bus-proxy:x:72:
|
---|
343 | systemd-journal-gateway:x:73:
|
---|
344 | systemd-journal-remote:x:74:
|
---|
345 | systemd-journal-upload:x:75:
|
---|
346 | systemd-network:x:76:
|
---|
347 | systemd-resolve:x:77:
|
---|
348 | systemd-timesync:x:78:
|
---|
349 | systemd-coredump:x:79:
|
---|
350 | wheel:x:97:
|
---|
351 | nogroup:x:99:
|
---|
352 | users:x:999:</literal>
|
---|
353 | EOF</userinput></screen>
|
---|
354 |
|
---|
355 | <para>The created groups are not part of any standard—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}
|
---|
391 | chgrp -v utmp /var/log/lastlog
|
---|
392 | chmod -v 664 /var/log/lastlog
|
---|
393 | chmod -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>
|
---|