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">
8 <sect1 id="ch-system-createfiles">
9 <?dbhtml filename="createfiles.html"?>
11 <title>Creating Essential Files and Symlinks</title>
13 <indexterm zone="ch-system-createfiles">
14 <primary sortas="e-/etc/passwd">/etc/passwd</primary>
17 <indexterm zone="ch-system-createfiles">
18 <primary sortas="e-/etc/group">/etc/group</primary>
21 <indexterm zone="ch-system-createfiles">
22 <primary sortas="e-/var/run/utmp">/var/run/utmp</primary>
25 <indexterm zone="ch-system-createfiles">
26 <primary sortas="e-/var/log/btmp">/var/log/btmp</primary>
29 <indexterm zone="ch-system-createfiles">
30 <primary sortas="e-/var/log/lastlog">/var/log/lastlog</primary>
33 <indexterm zone="ch-system-createfiles">
34 <primary sortas="e-/var/log/wtmp">/var/log/wtmp</primary>
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>
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
47 ln -sv bash /bin/sh</userinput></screen>
49 <!--for lib in blkid lzma mount uuid
51 ln -sv /tools/lib/lib$lib.so* /usr/lib
53 <!--ln -svf /tools/include/blkid /usr/include
54 ln -svf /tools/include/libmount /usr/include
55 ln -svf /tools/include/uuid /usr/include-->
56 <!--for pc in blkid mount uuid
58 sed 's@tools@usr@g' /tools/lib/pkgconfig/${pc}.pc \
59 > /usr/lib/pkgconfig/${pc}.pc
62 <title>The purpose of each link:</title>
65 <term><parameter><filename>/bin/bash</filename></parameter></term>
67 <para>Many <command>bash</command> scripts specify
68 <filename>/bin/bash</filename>.</para>
73 <term><parameter><filename>/bin/cat</filename></parameter></term>
75 <para>This pathname is hard-coded into Glibc's configure script.</para>
80 <term><parameter><filename>/bin/dd</filename></parameter></term>
82 <para>The path to <filename>dd</filename> will be hard-coded into the
83 <filename>/usr/bin/libtool</filename> utility.</para>
88 <term><parameter><filename>/bin/echo</filename></parameter></term>
90 <para>This is to satisfy one of the tests in Glibc's test suite, which
91 expects <filename>/bin/echo</filename>.</para>
96 <term><parameter><filename>/usr/bin/env</filename></parameter></term>
98 <para>This pathname is hard-coded into some packages build procedures.
99 <!-- systemd This may not be needed if we move sysd to the end--></para>
104 <term><parameter><filename>/usr/bin/install</filename></parameter></term>
106 <para>The path to <filename>install</filename> will be hard-coded into
107 the <filename>/usr/lib/bash/Makefile.inc</filename> file.</para>
112 <term><parameter><filename>/bin/ln</filename></parameter></term>
114 <para>The path to <filename>ln</filename> will be hard-coded into the
115 <filename>/usr/lib/perl5/&perl-version;/<target-triplet>/Config_heavy.pl</filename>
121 <term><parameter><filename>/bin/pwd</filename></parameter></term>
123 <para>Some <command>configure</command> scripts, particularly Glibc's,
124 have this pathname hard-coded.</para>
129 <term><parameter><filename>/bin/rm</filename></parameter></term>
131 <para>The path to <filename>rm</filename> will be hard-coded into the
132 <filename>/usr/lib/perl5/&perl-version;/<target-triplet>/Config_heavy.pl</filename>
138 <term><parameter><filename>/bin/stty</filename></parameter></term>
140 <para>This pathname is hard-coded into Expect, therefore it is needed
141 for Binutils and GCC test suites to pass.</para>
146 <term><parameter><filename>/usr/bin/perl</filename></parameter></term>
148 <para>Many Perl scripts hard-code this path to the
149 <command>perl</command> program.</para>
154 <term><parameter><filename>/usr/lib/libgcc_s.so{,.1}</filename></parameter></term>
156 <para>Glibc needs this for the pthreads library to work.</para>
161 <term><parameter><filename>/usr/lib/libstdc++{,.6}</filename></parameter></term>
163 <para>This is needed by several tests in Glibc's test suite, as well as
164 for C++ support in GMP.</para>
169 <term><parameter><filename>/usr/lib/libstdc++.la</filename></parameter></term>
171 <para>This prevents a <filename class="directory">/tools</filename>
172 reference that would otherwise be in
173 <filename>/usr/lib/libstdc++.la</filename> after GCC is installed.</para>
177 <!--<varlistentry revision="systemd">-->
179 <term><parameter><filename>/usr/lib/lib{blkid,lzma,mount,uuid}.{a,la,so*}</filename></parameter></term>
181 <para>These links prevent utilities from acquiring an
182 unnecessary reference to the
183 <filename class="directory">/tools</filename> directory.</para>
188 <term><parameter><filename>/bin/sh</filename></parameter></term>
190 <para>Many shell scripts hard-code <filename>/bin/sh</filename>.</para>
196 <para>Historically, Linux maintains a list of the mounted file systems in the
197 file <filename>/etc/mtab</filename>. Modern kernels maintain this list
198 internally and exposes it to the user via the <filename
199 class="directory">/proc</filename> filesystem. To satisfy utilities that
200 expect the presence of <filename>/etc/mtab</filename>, create the following
201 symbolic link:</para>
203 <screen><userinput>ln -sv /proc/self/mounts /etc/mtab</userinput></screen>
205 <para>In order for user <systemitem class="username">root</systemitem> to be
206 able to login and for the name <quote>root</quote> to be recognized, there
207 must be relevant entries in the <filename>/etc/passwd</filename> and
208 <filename>/etc/group</filename> files.</para>
210 <para>Create the <filename>/etc/passwd</filename> file by running the following
213 <screen revision="sysv"><userinput>cat > /etc/passwd << "EOF"
214 <literal>root:x:0:0:root:/root:/bin/bash
215 bin:x:1:1:bin:/dev/null:/bin/false
216 daemon:x:6:6:Daemon User:/dev/null:/bin/false
217 messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
218 nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>
219 EOF</userinput></screen>
221 <screen revision="systemd"><userinput>cat > /etc/passwd << "EOF"
222 <literal>root:x:0:0:root:/root:/bin/bash
223 bin:x:1:1:bin:/dev/null:/bin/false
224 daemon:x:6:6:Daemon User:/dev/null:/bin/false
225 messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
226 systemd-bus-proxy:x:72:72:systemd Bus Proxy:/:/bin/false
227 systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/bin/false
228 systemd-journal-remote:x:74:74:systemd Journal Remote:/:/bin/false
229 systemd-journal-upload:x:75:75:systemd Journal Upload:/:/bin/false
230 systemd-network:x:76:76:systemd Network Management:/:/bin/false
231 systemd-resolve:x:77:77:systemd Resolver:/:/bin/false
232 systemd-timesync:x:78:78:systemd Time Synchronization:/:/bin/false
233 systemd-coredump:x:79:79:systemd Core Dumper:/:/bin/false
234 nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>
235 EOF</userinput></screen>
237 <para>The actual password for <systemitem class="username">root</systemitem>
238 (the <quote>x</quote> used here is just a placeholder) will be set later.</para>
240 <para>Create the <filename>/etc/group</filename> file by running the following
243 <screen revision="sysv"><userinput>cat > /etc/group << "EOF"
267 users:x:999:</literal>
268 EOF</userinput></screen>
270 <screen revision="systemd"><userinput>cat > /etc/group << "EOF"
289 systemd-journal:x:23:
293 systemd-bus-proxy:x:72:
294 systemd-journal-gateway:x:73:
295 systemd-journal-remote:x:74:
296 systemd-journal-upload:x:75:
297 systemd-network:x:76:
298 systemd-resolve:x:77:
299 systemd-timesync:x:78:
300 systemd-coredump:x:79:
303 users:x:999:</literal>
304 EOF</userinput></screen>
306 <para>The created groups are not part of any standard—they are groups
307 decided on in part by the requirements of the Udev configuration in this
308 chapter, and in part by common convention employed by a number of existing
309 Linux distributions. In addition, some test suites rely on specific users
310 or groups. The Linux Standard Base (LSB, available at <ulink
311 url="http://www.linuxbase.org"/>) recommends only that, besides the group
312 <systemitem class="groupname">root</systemitem> with a Group ID (GID) of 0,
313 a group <systemitem class="groupname">bin</systemitem> with a GID of 1 be
314 present. All other group names and GIDs can be chosen freely by the system
315 administrator since well-written programs do not depend on GID numbers, but
316 rather use the group's name.</para>
318 <para>To remove the <quote>I have no name!</quote> prompt, start a new
319 shell. Since a full Glibc was installed in <xref
320 linkend="chapter-temporary-tools"/> and the
321 <filename>/etc/passwd</filename> and <filename>/etc/group</filename>
322 files have been created, user name and group name resolution will now
325 <screen role="nodump"><userinput>exec /tools/bin/bash --login +h</userinput></screen>
327 <para>Note the use of the <parameter>+h</parameter> directive. This tells
328 <command>bash</command> not to use its internal path hashing. Without this
329 directive, <command>bash</command> would remember the paths to binaries it has
330 executed. To ensure the use of the newly compiled binaries as soon as they are
331 installed, the <parameter>+h</parameter> directive will be used for the duration
332 of this chapter.</para>
334 <para>The <command>login</command>, <command>agetty</command>, and
335 <command>init</command> programs (and others) use a number of log
336 files to record information such as who was logged into the system and
337 when. However, these programs will not write to the log files if they
338 do not already exist. Initialize the log files and give them
339 proper permissions:</para>
341 <screen><userinput>touch /var/log/{btmp,lastlog,faillog,wtmp}
342 chgrp -v utmp /var/log/lastlog
343 chmod -v 664 /var/log/lastlog
344 chmod -v 600 /var/log/btmp</userinput></screen>
346 <para>The <filename>/var/log/wtmp</filename> file records all logins and
347 logouts. The <filename>/var/log/lastlog</filename> file records when each
348 user last logged in. The <filename>/var/log/faillog</filename> file records
349 failed login attempts. The <filename>/var/log/btmp</filename> file records
350 the bad login attempts.</para>
352 <note><para>The <filename>/run/utmp</filename> file records the users that
353 are currently logged in. This file is created dynamically in the boot
354 scripts.</para></note>