createfiles.xml 13 KB

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