source: chapter06/createfiles.xml@ 2e1e6e6

7.6-systemd 7.7-systemd 7.8-systemd 7.9-systemd
Last change on this file since 2e1e6e6 was 2e1e6e6, checked in by Krejzi <krejzi@…>, 10 years ago

Commit first draft of systemd-216 instructions.

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

  • Property mode set to 100644
File size: 9.2 KB
Line 
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/log/btmp">/var/log/btmp</primary>
23 </indexterm>
24
25 <indexterm zone="ch-system-createfiles">
26 <primary sortas="e-/var/log/lastlog">/var/log/lastlog</primary>
27 </indexterm>
28
29 <indexterm zone="ch-system-createfiles">
30 <primary sortas="e-/var/log/wtmp">/var/log/wtmp</primary>
31 </indexterm>
32
33 <para>Some programs use hard-wired paths to programs which do not exist yet. In
34 order to satisfy these programs, create a number of symbolic links which will be
35 replaced by real files throughout the course of this chapter after the software
36 has been installed:</para>
37
38<screen><userinput>ln -sv /tools/bin/{bash,cat,echo,pwd,stty} /bin
39ln -sv /tools/bin/perl /usr/bin
40ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib
41ln -sv /tools/lib/libstdc++.so{,.6} /usr/lib
42sed 's/tools/usr/' /tools/lib/libstdc++.la > /usr/lib/libstdc++.la
43ln -sv bash /bin/sh</userinput></screen>
44
45 <variablelist>
46 <title>The purpose of each link:</title>
47
48 <varlistentry>
49 <term><parameter><filename>/bin/bash</filename></parameter></term>
50 <listitem>
51 <para>Many <command>bash</command> scripts specify
52 <filename>/bin/bash</filename>.</para>
53 </listitem>
54 </varlistentry>
55
56 <varlistentry>
57 <term><parameter><filename>/bin/cat</filename></parameter></term>
58 <listitem>
59 <para>This pathname is hard-coded into Glibc's configure script.</para>
60 </listitem>
61 </varlistentry>
62
63 <varlistentry>
64 <term><parameter><filename>/bin/echo</filename></parameter></term>
65 <listitem>
66 <para>This is to satisfy one of the tests in Glibc's test suite, which
67 expects <filename>/bin/echo</filename>.</para>
68 </listitem>
69 </varlistentry>
70
71 <varlistentry>
72 <term><parameter><filename>/bin/pwd</filename></parameter></term>
73 <listitem>
74 <para>Some <command>configure</command> scripts, particularly Glibc's,
75 have this pathname hard-coded.</para>
76 </listitem>
77 </varlistentry>
78
79 <varlistentry>
80 <term><parameter><filename>/bin/stty</filename></parameter></term>
81 <listitem>
82 <para>This pathname is hard-coded into Expect, therefore it is needed
83 for Binutils and GCC test suites to pass.</para>
84 </listitem>
85 </varlistentry>
86
87 <varlistentry>
88 <term><parameter><filename>/usr/bin/perl</filename></parameter></term>
89 <listitem>
90 <para>Many Perl scripts hard-code this path to the
91 <command>perl</command> program.</para>
92 </listitem>
93 </varlistentry>
94
95 <varlistentry>
96 <term><parameter><filename>/usr/lib/libgcc_s.so{,.1}</filename></parameter></term>
97 <listitem>
98 <para>Glibc needs this for the pthreads library to work.</para>
99 </listitem>
100 </varlistentry>
101
102 <varlistentry>
103 <term><parameter><filename>/usr/lib/libstdc++{,.6}</filename></parameter></term>
104 <listitem>
105 <para>This is needed by several tests in Glibc's test suite, as well as
106 for C++ support in GMP.</para>
107 </listitem>
108 </varlistentry>
109
110 <varlistentry>
111 <term><parameter><filename>/usr/lib/libstdc++.la</filename></parameter></term>
112 <listitem>
113 <para>This prevents a <filename class="directory">/tools</filename>
114 reference that would otherwise be in
115 <filename>/usr/lib/libstdc++.la</filename> after GCC is installed.</para>
116 </listitem>
117 </varlistentry>
118
119 <varlistentry>
120 <term><parameter><filename>/bin/sh</filename></parameter></term>
121 <listitem>
122 <para>Many shell scripts hard-code <filename>/bin/sh</filename>.</para>
123 </listitem>
124 </varlistentry>
125
126 </variablelist>
127
128 <para>Historically, Linux maintains a list of the mounted file systems in the
129 file <filename>/etc/mtab</filename>. Modern kernels maintain this list
130 internally and exposes it to the user via the <filename
131 class="directory">/proc</filename> filesystem. To satisfy utilities that
132 expect the presence of <filename>/etc/mtab</filename>, create the following
133 symbolic link:</para>
134
135<screen><userinput>ln -sv /proc/self/mounts /etc/mtab</userinput></screen>
136
137 <para>In order for user <systemitem class="username">root</systemitem> to be
138 able to login and for the name <quote>root</quote> to be recognized, there
139 must be relevant entries in the <filename>/etc/passwd</filename> and
140 <filename>/etc/group</filename> files.</para>
141
142 <para>Create the <filename>/etc/passwd</filename> file by running the following
143 command:</para>
144
145<screen><userinput>cat &gt; /etc/passwd &lt;&lt; "EOF"
146<literal>root:x:0:0:root:/root:/bin/bash
147bin:x:1:1:bin:/dev/null:/bin/false
148daemon:x:6:6:Daemon User:/dev/null:/bin/false
149messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
150systemd-bus-proxy:x:72:72:systemd Bus Proxy:/:/bin/false
151systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/bin/false
152systemd-journal-remote:x:74:74:systemd Journal Remote:/:/bin/false
153systemd-journal-upload:x:75:75:systemd Journal Upload:/:/bin/false
154systemd-network:x:76:76:systemd Network Management:/:/bin/false
155systemd-resolve:x:77:77:systemd Resolver:/:/bin/false
156systemd-timesync:x:78:78:systemd Time Synchronization:/:/bin/false
157nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>
158EOF</userinput></screen>
159
160 <para>The actual password for <systemitem class="username">root</systemitem>
161 (the <quote>x</quote> used here is just a placeholder) will be set later.</para>
162
163 <para>Create the <filename>/etc/group</filename> file by running the following
164 command:</para>
165
166<screen><userinput>cat &gt; /etc/group &lt;&lt; "EOF"
167<literal>root:x:0:
168bin:x:1:daemon
169sys:x:2:
170kmem:x:3:
171tape:x:4:
172tty:x:5:
173daemon:x:6:
174floppy:x:7:
175disk:x:8:
176lp:x:9:
177dialout:x:10:
178audio:x:11:
179video:x:12:
180utmp:x:13:
181usb:x:14:
182cdrom:x:15:
183adm:x:16:
184messagebus:x:18:
185systemd-journal:x:23:
186input:x:24:
187mail:x:34:
188systemd-bus-proxy:x:72:
189systemd-journal-gateway:x:73:
190systemd-journal-remote:x:74:
191systemd-journal-upload:x:75:
192systemd-network:x:76:
193systemd-resolve:x:77:
194systemd-timesync:x:78:
195nogroup:x:99:
196users:x:999:</literal>
197EOF</userinput></screen>
198
199 <para>The created groups are not part of any standard&mdash;they are groups
200 decided on in part by the requirements of the Udev configuration in this
201 chapter, and in part by common convention employed by a number of existing
202 Linux distributions. In addition, some test suites rely on specific users
203 or groups. The Linux Standard Base (LSB, available at <ulink
204 url="http://www.linuxbase.org"/>) recommends only that, besides the group
205 <systemitem class="groupname">root</systemitem> with a Group ID (GID) of 0,
206 a group <systemitem class="groupname">bin</systemitem> with a GID of 1 be
207 present. All other group names and GIDs can be chosen freely by the system
208 administrator since well-written programs do not depend on GID numbers, but
209 rather use the group's name.</para>
210
211 <para>To remove the <quote>I have no name!</quote> prompt, start a new
212 shell. Since a full Glibc was installed in <xref
213 linkend="chapter-temporary-tools"/> and the
214 <filename>/etc/passwd</filename> and <filename>/etc/group</filename>
215 files have been created, user name and group name resolution will now
216 work:</para>
217
218<screen role="nodump"><userinput>exec /tools/bin/bash --login +h</userinput></screen>
219
220 <para>Note the use of the <parameter>+h</parameter> directive. This tells
221 <command>bash</command> not to use its internal path hashing. Without this
222 directive, <command>bash</command> would remember the paths to binaries it has
223 executed. To ensure the use of the newly compiled binaries as soon as they are
224 installed, the <parameter>+h</parameter> directive will be used for the duration
225 of this chapter.</para>
226
227 <para>The <command>login</command>, <command>agetty</command>, and
228 <command>init</command> programs (and others) use a number of log
229 files to record information such as who was logged into the system and
230 when. However, these programs will not write to the log files if they
231 do not already exist. Initialize the log files and give them
232 proper permissions:</para>
233
234<screen><userinput>touch /var/log/{btmp,lastlog,wtmp}
235chgrp -v utmp /var/log/lastlog
236chmod -v 664 /var/log/lastlog
237chmod -v 600 /var/log/btmp</userinput></screen>
238
239 <para>The <filename>/var/log/wtmp</filename> file records all logins and
240 logouts. The <filename>/var/log/lastlog</filename> file records when each
241 user last logged in. The <filename>/var/log/btmp</filename> file records the
242 bad login attempts.</para>
243
244 <note><para>The <filename>/run/utmp</filename> file records the users that
245 are currently logged in. This file is created dynamically in the boot
246 scripts.</para></note>
247
248</sect1>
Note: See TracBrowser for help on using the repository browser.