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