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