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