createfiles.xml 9.2 KB

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