createfiles.xml 9.3 KB

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