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