source: chapter06/createfiles.xml@ 5985198

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 6.3 6.4 6.5 6.6 6.7 6.8 7.0 7.1 7.2 7.3 7.4 7.5 7.5-systemd 7.6 7.6-systemd 7.7 7.7-systemd 7.8 7.8-systemd 7.9 7.9-systemd 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 5985198 was 5985198, checked in by Dan Nichilson <dnicholson@…>, 17 years ago

Added /tools/bin/echo to essential symlinks for glibc posix/tst-vfork3

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@8231 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 5.5 KB
Line 
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. In
38 order to satisfy these programs, create a number of symbolic links which will be
39 replaced by real files throughout the course of this chapter after the software
40 has been installed:</para>
41
42<screen><userinput>ln -sv /tools/bin/{bash,cat,echo,grep,pwd,stty} /bin
43ln -sv /tools/bin/perl /usr/bin
44ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib
45ln -sv /tools/lib/libstdc++.so{,.6} /usr/lib
46ln -sv bash /bin/sh</userinput></screen>
47
48 <para>A proper Linux system maintains a list of the mounted file systems in
49 the file <filename>/etc/mtab</filename>. Normally, this file would be
50 created when we mount a new file system. Since we will not be mounting any
51 file systems inside our chroot environment, create an empty file for
52 utilities that expect the presence of <filename>/etc/mtab</filename>:</para>
53
54<screen><userinput>touch /etc/mtab</userinput></screen>
55
56 <para>In order for user <systemitem class="username">root</systemitem> to be
57 able to login and for the name <quote>root</quote> to be recognized, there
58 must be relevant entries in the <filename>/etc/passwd</filename> and
59 <filename>/etc/group</filename> files.</para>
60
61 <para>Create the <filename>/etc/passwd</filename> file by running the following
62 command:</para>
63
64<screen><userinput>cat &gt; /etc/passwd &lt;&lt; "EOF"
65<literal>root:x:0:0:root:/root:/bin/bash
66nobody:x:99:99:Unprivileged User:/dev/null:/bin/false</literal>
67EOF</userinput></screen>
68
69 <para>The actual password for <systemitem class="username">root</systemitem>
70 (the <quote>x</quote> used here is just a placeholder) will be set later.</para>
71
72 <para>Create the <filename>/etc/group</filename> file by running the following
73 command:</para>
74
75<screen><userinput>cat &gt; /etc/group &lt;&lt; "EOF"
76<literal>root:x:0:
77bin:x:1:
78sys:x:2:
79kmem:x:3:
80tty:x:4:
81tape:x:5:
82daemon:x:6:
83floppy:x:7:
84disk:x:8:
85lp:x:9:
86dialout:x:10:
87audio:x:11:
88video:x:12:
89utmp:x:13:
90usb:x:14:
91cdrom:x:15:
92mail:x:34:
93nogroup:x:99:</literal>
94EOF</userinput></screen>
95
96 <para>The created groups are not part of any standard&mdash;they are groups
97 decided on in part by the requirements of the Udev configuration in this
98 chapter, and in part by common convention employed by a number of existing
99 Linux distributions. The Linux Standard Base (LSB, available at <ulink
100 url="http://www.linuxbase.org"/>) recommends only that, besides the group
101 <systemitem class="groupname">root</systemitem> with a Group ID (GID) of 0,
102 a group <systemitem class="groupname">bin</systemitem> with a GID of 1 be
103 present. All other group names and GIDs can be chosen freely by the system
104 administrator since well-written programs do not depend on GID numbers, but
105 rather use the group's name.</para>
106
107 <para>To remove the <quote>I have no name!</quote> prompt, start a new
108 shell. Since a full Glibc was installed in <xref
109 linkend="chapter-temporary-tools"/> and the
110 <filename>/etc/passwd</filename> and <filename>/etc/group</filename>
111 files have been created, user name and group name resolution will now
112 work:</para>
113
114<screen role="nodump"><userinput>exec /tools/bin/bash --login +h</userinput></screen>
115
116 <para>Note the use of the <parameter>+h</parameter> directive. This tells
117 <command>bash</command> not to use its internal path hashing. Without this
118 directive, <command>bash</command> would remember the paths to binaries it has
119 executed. To ensure the use of the newly compiled binaries as soon as they are
120 installed, the <parameter>+h</parameter> directive will be used for the duration
121 of this chapter.</para>
122
123 <para>The <command>login</command>, <command>agetty</command>, and
124 <command>init</command> programs (and others) use a number of log
125 files to record information such as who was logged into the system and
126 when. However, these programs will not write to the log files if they
127 do not already exist. Initialize the log files and give them
128 proper permissions:</para>
129
130<screen><userinput>touch /var/run/utmp /var/log/{btmp,lastlog,wtmp}
131chgrp -v utmp /var/run/utmp /var/log/lastlog
132chmod -v 664 /var/run/utmp /var/log/lastlog</userinput></screen>
133
134 <para>The <filename>/var/run/utmp</filename> file records the users
135 that are currently logged in. The <filename>/var/log/wtmp</filename>
136 file records all logins and logouts. The
137 <filename>/var/log/lastlog</filename> file records when
138 each user last logged in. The <filename>/var/log/btmp</filename> file
139 records the bad login attempts.</para>
140
141</sect1>
Note: See TracBrowser for help on using the repository browser.