[673b0d8] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[b06ca36] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
[673b0d8] | 4 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
[8ef8304] | 7 |
|
---|
[673b0d8] | 8 | <sect1 id="ch-system-createfiles">
|
---|
[8ef8304] | 9 | <?dbhtml filename="createfiles.html"?>
|
---|
| 10 |
|
---|
[d2c332bc] | 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>
|
---|
[673b0d8] | 32 |
|
---|
[8ef8304] | 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
|
---|
[f19e766] | 36 | has been installed:</para>
|
---|
[673b0d8] | 37 |
|
---|
[b943097] | 38 | <screen><userinput>ln -sv /tools/bin/{bash,cat,echo,pwd,stty} /bin
|
---|
[5998892] | 39 | ln -sv /tools/bin/perl /usr/bin
|
---|
| 40 | ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib
|
---|
[2f94d109] | 41 | ln -sv /tools/lib/libstdc++.so{,.6} /usr/lib
|
---|
[e844aee] | 42 | sed 's/tools/usr/' /tools/lib/libstdc++.la > /usr/lib/libstdc++.la
|
---|
[5998892] | 43 | ln -sv bash /bin/sh</userinput></screen>
|
---|
[673b0d8] | 44 |
|
---|
[61ce0b1] | 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 |
|
---|
[cc519cf] | 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>
|
---|
[d2c332bc] | 134 |
|
---|
[b1a51ac1] | 135 | <screen><userinput>ln -sv /proc/self/mounts /etc/mtab</userinput></screen>
|
---|
[d2c332bc] | 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 > /etc/passwd << "EOF"
|
---|
[4361397] | 146 | <literal>root:x:0:0:root:/root:/bin/bash
|
---|
[8f90f47d] | 147 | bin:x:1:1:bin:/dev/null:/bin/false
|
---|
[61ce0b1] | 148 | daemon:x:6:6:Daemon User:/dev/null:/bin/false
|
---|
[8edca0a] | 149 | messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
|
---|
[2e1e6e6] | 150 | systemd-bus-proxy:x:72:72:systemd Bus Proxy:/:/bin/false
|
---|
| 151 | systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/bin/false
|
---|
| 152 | systemd-journal-remote:x:74:74:systemd Journal Remote:/:/bin/false
|
---|
| 153 | systemd-journal-upload:x:75:75:systemd Journal Upload:/:/bin/false
|
---|
| 154 | systemd-network:x:76:76:systemd Network Management:/:/bin/false
|
---|
| 155 | systemd-resolve:x:77:77:systemd Resolver:/:/bin/false
|
---|
| 156 | systemd-timesync:x:78:78:systemd Time Synchronization:/:/bin/false
|
---|
[390e32c] | 157 | nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>
|
---|
[d2c332bc] | 158 | EOF</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 > /etc/group << "EOF"
|
---|
| 167 | <literal>root:x:0:
|
---|
[61ce0b1] | 168 | bin:x:1:daemon
|
---|
[d2c332bc] | 169 | sys:x:2:
|
---|
| 170 | kmem:x:3:
|
---|
[107e7a5] | 171 | tape:x:4:
|
---|
| 172 | tty:x:5:
|
---|
[044384d] | 173 | daemon:x:6:
|
---|
[d2c332bc] | 174 | floppy:x:7:
|
---|
| 175 | disk:x:8:
|
---|
| 176 | lp:x:9:
|
---|
[bb8939c] | 177 | dialout:x:10:
|
---|
[d2c332bc] | 178 | audio:x:11:
|
---|
| 179 | video:x:12:
|
---|
| 180 | utmp:x:13:
|
---|
| 181 | usb:x:14:
|
---|
[4361397] | 182 | cdrom:x:15:
|
---|
[0a56911] | 183 | adm:x:16:
|
---|
[8edca0a] | 184 | messagebus:x:18:
|
---|
[cc519cf] | 185 | systemd-journal:x:23:
|
---|
[346eaef1] | 186 | input:x:24:
|
---|
[d1538c0] | 187 | mail:x:34:
|
---|
[2e1e6e6] | 188 | systemd-bus-proxy:x:72:
|
---|
| 189 | systemd-journal-gateway:x:73:
|
---|
| 190 | systemd-journal-remote:x:74:
|
---|
| 191 | systemd-journal-upload:x:75:
|
---|
| 192 | systemd-network:x:76:
|
---|
| 193 | systemd-resolve:x:77:
|
---|
| 194 | systemd-timesync:x:78:
|
---|
[61ce0b1] | 195 | nogroup:x:99:
|
---|
| 196 | users:x:999:</literal>
|
---|
[d2c332bc] | 197 | EOF</userinput></screen>
|
---|
| 198 |
|
---|
| 199 | <para>The created groups are not part of any standard—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
|
---|
[61ce0b1] | 202 | Linux distributions. In addition, some test suites rely on specific users
|
---|
| 203 | or groups. The Linux Standard Base (LSB, available at <ulink
|
---|
[d2c332bc] | 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
|
---|
[f19e766] | 216 | work:</para>
|
---|
[d2c332bc] | 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 |
|
---|
[44f6add] | 234 | <screen><userinput>touch /var/log/{btmp,lastlog,wtmp}
|
---|
[4f2e707] | 235 | chgrp -v utmp /var/log/lastlog
|
---|
| 236 | chmod -v 664 /var/log/lastlog
|
---|
| 237 | chmod -v 600 /var/log/btmp</userinput></screen>
|
---|
[d2c332bc] | 238 |
|
---|
[44f6add] | 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>
|
---|
[d2c332bc] | 247 |
|
---|
[673b0d8] | 248 | </sect1>
|
---|