source: chapter06/chapter06.xml@ 5b7293a

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.0 6.1 6.1.1 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 v5_1 v5_1_1 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 5b7293a was 5b7293a, checked in by Alex Gronenwoud <alex@…>, 20 years ago

Removing HOME and --login from the chroot commands.

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

  • Property mode set to 100644
File size: 27.3 KB
Line 
1<chapter id="chapter-building-system" xreflabel="Chapter 6">
2<title>Installing basic system software</title>
3<?dbhtml filename="chapter06.html" dir="chapter06"?>
4
5
6<sect1 id="ch-system-introduction">
7<title>Introduction</title>
8<?dbhtml filename="introduction.html" dir="chapter06"?>
9
10<para>In this chapter we enter the building site, and start
11constructing our LFS system in earnest. That is, we chroot into
12our temporary mini Linux system, create some auxiliary things,
13and then start installing all the packages, one by one.</para>
14
15<para>The installation of all this software is pretty straightforward,
16and you will probably think it would be much shorter to give here
17the generic installation instructions and explain in full only the
18installation of those packages that require an alternate method.
19Although we agree with that, we nevertheless choose to give the
20full instructions for each and every package, simply to minimize
21the possibilities for mistakes.</para>
22
23<para>The key to learning what makes a Linux system work is to know
24what each package is used for and why the user (or the system) needs it.
25For this purpose for every installed package a summary of its content is
26given followed by concise descriptions of each program and library it
27installed.</para>
28
29<para>If you plan to use compiler optimizations in this chapter, take a look at
30the optimization hint at <ulink url="&hints-root;optimization.txt"/>. Compiler
31optimizations can make a program run slightly faster, but they may also cause
32compilation difficulties and even problems when running the program. If a
33package refuses to compile when using optimization, try to compile it without
34optimization and see if the problem goes away. Even if the package does compile
35when using optimization, there is the risk it may have been compiled incorrectly
36due to complex interactions between the code and build tools. In short, the
37small potential gains achieved in using compiler optimization are generally
38outweighed by the risk. First time builders of LFS are encouraged to build
39without custom optimizations. Your system will still be very fast and very
40stable at the same time.</para>
41
42<para>The order in which packages are installed in this chapter has
43to be strictly followed, to ensure that no program gets a path referring
44to <filename class="directory">/tools</filename> hard-wired into it.
45For the same reason, <emphasis>do not </emphasis> compile packages
46in parallel. Compiling in parallel may save you some time (especially on
47dual-CPU machines), but it could result in a program containing a
48hard-wired path to <filename class="directory">/tools</filename>,
49which will cause the program to stop working when that directory
50is removed.</para>
51
52<para>Before the installation instructions each installation page gives some
53information about the package: a concise description of what it contains, how
54long it will approximately take to build it, how much disk space it needs
55during this building process, the official download location of the package
56(in case you just want to update a few of them), and which other packages it
57needs in order to be built successfully. After the installation instructions
58follows a list of programs and libraries that the package installs, together
59with a series of short descriptions of these.</para>
60
61<para>If you wish to keep track of which package installs what files, you may
62want to use a package manager. For a general overview of package managers have
63a look at <ulink url="&blfs-root;view/cvs/introduction/pkgmgt.html"/>. And for
64a package management method specifically geared towards LFS see
65<ulink url="&hints-root;more_control_and_pkg_man.txt"/>.</para>
66
67</sect1>
68
69
70<sect1 id="ch-system-proc">
71<title>Mounting the proc and devpts file systems</title>
72<?dbhtml filename="proc.html" dir="chapter06"?>
73
74<para>In order for certain programs to function properly, the
75<emphasis>proc</emphasis> and <emphasis>devpts</emphasis> file systems must be
76available within the chroot environment. The proc file system is the process
77information pseudo file system through which the kernel provides information
78about the status of the system. And the devpts file system is nowadays the most
79common way pseudo terminals (PTYs) are implemented. Since kernel version 2.4, a
80file system can be mounted as many times and in as many places as you like,
81thus it's not a problem that these file systems are already mounted on your
82host system, especially so because they are virtual file systems.</para>
83
84<para>First become <emphasis>root</emphasis>, as only <emphasis>root</emphasis>
85can mount file systems in unusual places. Then check again that the LFS
86environment variable is set correctly by running <userinput>echo
87$LFS</userinput> and making sure it shows the path to your LFS partition's
88mount point, which is <filename class="directory">/mnt/lfs</filename> if you
89followed our example.</para>
90
91<para>Now make the mount points for these filesystems:</para>
92
93<screen><userinput>mkdir -p $LFS/{proc,dev/pts}</userinput></screen>
94
95<para>Mount the <emphasis>proc</emphasis> file system with:</para>
96
97<screen><userinput>mount proc $LFS/proc -t proc</userinput></screen>
98
99<para>And mount the <emphasis>devpts</emphasis> file system with:</para>
100
101<screen><userinput>mount devpts $LFS/dev/pts -t devpts</userinput></screen>
102
103<para>This last command might fail with an error like:</para>
104
105<blockquote><screen>filesystem devpts not supported by kernel</screen></blockquote>
106
107<para>The most likely cause for this is that your host system's kernel was
108compiled without support for the devpts file system (you can check which file
109systems your kernel supports with <command>cat /proc/filesystems</command>,
110for example). A few PTYs are needed to be able to run the suites for Binutils
111and GCC later on. If your kernel does not support devpts, do not worry, there
112is another way to get them working inside the chroot environment. We'll cover
113this shortly in the <xref linkend="ch-system-MAKEDEV"/> section.</para>
114
115<para>Remember that if for any reason you stop working on your LFS, and start
116again later, it's important to check that these file systems are mounted again
117before entering the chroot environment, otherwise problems could occur.</para>
118
119</sect1>
120
121
122<sect1 id="ch-system-chroot">
123<title>Entering the chroot environment</title>
124<?dbhtml filename="chroot.html" dir="chapter06"?>
125
126<para>It is time to enter the chroot environment in order to begin building
127and installing your final LFS system. Still as <emphasis>root</emphasis> run
128the following command to enter the small world that is, at the moment,
129populated with only the temporary tools:</para>
130
131<screen><userinput>chroot $LFS /tools/bin/env -i \
132&nbsp;&nbsp;&nbsp;&nbsp;TERM=$TERM PS1='\u:\w\$ ' \
133&nbsp;&nbsp;&nbsp;&nbsp;PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
134&nbsp;&nbsp;&nbsp;&nbsp;/tools/bin/bash +h</userinput></screen>
135
136<para>The <emphasis>-i</emphasis> option given to the
137<command>env</command> command will clear all variables of the chroot
138environment. After that, only the TERM, PS1 and PATH variables are
139set again. The TERM=$TERM construct will set the TERM variable inside chroot
140to the same value as outside chroot; this variable is needed for programs
141like <command>less</command> and <command>vim</command> to operate
142properly. If you need other variables present, such as CFLAGS, CXXFLAGS or
143HOME, this is a good place to set them.</para>
144
145<para>From this point on there's no need to use the LFS variable anymore,
146because everything you do will be restricted to the LFS file system -- since
147what the shell thinks is <filename class="directory">/</filename> is actually
148the value of <filename class="directory">$LFS</filename>, which was passed to
149the chroot command.</para>
150
151<para>Notice that <filename class="directory">/tools/bin</filename> comes
152last in the PATH. This means that a temporary tool will not be used any more
153as soon as its final version is installed. Well, at least when the shell
154doesn't remember the locations of executed binaries -- for this reason hashing
155is switched off by passing the <emphasis>+h</emphasis> option to
156<command>bash</command>.</para>
157
158<para>You have to make sure all the commands in the rest of this chapter and
159in the following chapters are run from within the chroot environment.
160If you ever leave this environment for any reason (rebooting for example),
161you must remember to first mount the proc and devpts file systems (discussed
162in the previous section) <emphasis>and</emphasis> enter chroot again before
163continuing with the installations.</para>
164
165<para>Note that the bash prompt will say "I have no name!" This is normal, as
166the <filename>/etc/passwd</filename> file has not been created yet.</para>
167
168</sect1>
169
170
171<sect1 id="ch-system-changingowner">
172<title>Changing ownership</title>
173<?dbhtml filename="changingowner.html" dir="chapter06"?>
174
175<para>Right now the <filename class="directory">/tools</filename> directory
176is owned by the user <emphasis>lfs</emphasis>, a user that exists only on your
177host system. Although you will probably want to delete the
178<filename class="directory">/tools</filename> directory once you have
179finished your LFS system, you may want to keep it around, for example to
180build more LFS systems. But if you keep the
181<filename class="directory">/tools</filename> directory as it is, you end up
182with files owned by a user ID without a corresponding account. This is
183dangerous because a user account created later on could get this same user ID
184and would suddenly own the <filename class="directory">/tools</filename>
185directory and all the files therein, thus exposing these files to possible
186malicious manipulation.</para>
187
188<para>To avoid this issue, you could add the <emphasis>lfs</emphasis> user to
189your new LFS system later on when creating the <filename>/etc/passwd</filename>
190file, taking care to assign it the same user and group IDs as on your host
191system. Alternatively, you can (and the book assumes you do) assign the
192contents of the <filename class="directory">/tools</filename> directory to
193user <emphasis>root</emphasis> by running the following command:</para>
194
195<screen><userinput>chown -R 0:0 /tools</userinput></screen>
196
197<para>The command uses "0:0" instead of "root:root", because
198<userinput>chown</userinput> is unable to resolve the name "root" until the
199password file has been created.</para>
200
201</sect1>
202
203
204<sect1 id="ch-system-creatingdirs">
205<title>Creating directories</title>
206<?dbhtml filename="creatingdirs.html" dir="chapter06"?>
207
208<para>Let's now create some structure in our LFS file system. Let's create
209a directory tree. Issuing the following commands will create a more or less
210standard tree:</para>
211
212<screen><userinput>mkdir -p /{bin,boot,dev/{pts,shm},etc/opt,home,lib,mnt,proc}
213mkdir -p /{root,sbin,tmp,usr/local,var,opt}
214mkdir /usr/{bin,include,lib,sbin,share,src}
215ln -s share/{man,doc,info} /usr
216mkdir /usr/share/{doc,info,locale,man}
217mkdir /usr/share/{misc,terminfo,zoneinfo}
218mkdir /usr/share/man/man{1,2,3,4,5,6,7,8}
219mkdir /usr/local/{bin,etc,include,lib,sbin,share,src}
220ln -s share/{man,doc,info} /usr/local
221mkdir /usr/local/share/{doc,info,locale,man}
222mkdir /usr/local/share/{misc,terminfo,zoneinfo}
223mkdir /usr/local/share/man/man{1,2,3,4,5,6,7,8}
224mkdir /var/{lock,log,mail,run,spool}
225mkdir -p /var/{tmp,opt,cache,lib/misc,local}
226mkdir /opt/{bin,doc,include,info}
227mkdir -p /opt/{lib,man/man{1,2,3,4,5,6,7,8}}</userinput></screen>
228
229<para>Directories are, by default, created with permission mode 755, but this
230isn't desirable for all directories. We will make two changes: one to the home
231directory of <emphasis>root</emphasis>, and another to the directories for
232temporary files.</para>
233
234<screen><userinput>chmod 0750 /root
235chmod 1777 /tmp /var/tmp</userinput></screen>
236
237<para>The first mode change ensures that not just anybody can enter the
238<filename class="directory">/root</filename> directory -- the same
239as a normal user would do with his or her home directory.
240The second mode change makes sure that any user can write to the
241<filename class="directory">/tmp</filename> and
242<filename class="directory">/var/tmp</filename> directories, but
243cannot remove other users' files from them. The latter is prohibited
244by the so-called "sticky bit" -- the highest bit in the 1777 bit mask.</para>
245
246<sect2>
247<title>FHS compliance note</title>
248
249<para>We have based our directory tree on the FHS standard (available at
250<ulink url="http://www.pathname.com/fhs/"/>). Besides the above created
251tree this standard stipulates the existence of
252<filename class="directory">/usr/local/games</filename> and
253<filename class="directory">/usr/share/games</filename>, but we don't
254much like these for a base system. However, feel free to make your system
255FHS-compliant. As to the structure of the
256<filename class="directory">/usr/local/share</filename> subdirectory, the FHS
257isn't precise, so we created here the directories that we think are needed.</para>
258
259</sect2>
260
261</sect1>
262
263
264<sect1 id="ch-system-createfiles">
265<title>Creating essential symlinks</title>
266<?dbhtml filename="createfiles.html" dir="chapter06"?>
267
268<para>Some programs hard-wire paths to programs which don't exist yet. In
269order to satisfy these programs, we create a number of symbolic links which
270will be replaced by real files throughout the course of this chapter when
271we're installing all the software.</para>
272
273<screen><userinput>ln -s /tools/bin/{bash,cat,pwd,stty} /bin
274ln -s /tools/bin/perl /usr/bin
275ln -s /tools/lib/libgcc_s.so.1 /usr/lib
276ln -s bash /bin/sh</userinput></screen>
277
278</sect1>
279
280
281<sect1 id="ch-system-pwdgroup">
282<title>Creating the passwd, group and log files</title>
283<?dbhtml filename="pwdgroup.html" dir="chapter06"?>
284
285<para>In order for <emphasis>root</emphasis> to be able to login and for the
286name "root" to be recognized, there need to be relevant entries in the
287<filename>/etc/passwd</filename> and <filename>/etc/group</filename> files.</para>
288
289<para>Create the <filename>/etc/passwd</filename> file by running the following
290command:</para>
291
292<screen><userinput>cat &gt; /etc/passwd &lt;&lt; "EOF"</userinput>
293root:x:0:0:root:/root:/bin/bash
294<userinput>EOF</userinput></screen>
295
296<para>The actual password for <emphasis>root</emphasis> (the "x" here is just a
297placeholder) will be set later.</para>
298
299<para>Create the <filename>/etc/group</filename> file by running the following
300command:</para>
301
302<screen><userinput>cat &gt; /etc/group &lt;&lt; "EOF"</userinput>
303root:x:0:
304bin:x:1:
305sys:x:2:
306kmem:x:3:
307tty:x:4:
308tape:x:5:
309daemon:x:6:
310floppy:x:7:
311disk:x:8:
312lp:x:9:
313dialout:x:10:
314audio:x:11:
315<userinput>EOF</userinput></screen>
316
317<para>The created groups aren't part of any standard -- they are some of the
318groups that the <command>make_devices</command> script in the next section
319uses. The LSB (<ulink url="http://www.linuxbase.org/">Linux Standard
320Base</ulink>) recommends only that, beside the group "root" with a GID of 0, a
321group "bin" with a GID of 1 be present. All other group names and GIDs can
322be chosen freely by the system administrator, since well-written packages don't
323depend on GID numbers but use the group's name.</para>
324
325<para>To get rid of the "I have no name!" prompt, we will start a new shell.
326Since we installed a full Glibc in <xref linkend="chapter-temporary-tools"/>,
327and have just created the <filename>/etc/passwd</filename> and
328<filename>/etc/group</filename> files, user name and group name resolution
329will now work.</para>
330
331<screen><userinput>exec /tools/bin/bash +h</userinput></screen>
332
333<para>Note the use of the <emphasis>+h</emphasis> directive. This tells
334<command>bash</command> not to use its internal path hashing. Without this
335directive, <command>bash</command> would remember the paths to binaries it
336has executed. Since we want to use our newly compiled binaries as soon as
337they are installed, we turn off this function for the duration of this
338chapter.</para>
339
340<para>The <command>login</command>, <command>agetty</command> and
341<command>init</command> programs (and some others) use a number of log
342files to record information such as who was logged into the system and when.
343These programs, however, won't write to the log files if they don't already
344exist. Initialize the log files and give them their proper permissions:</para>
345
346<screen><userinput>touch /var/run/utmp /var/log/{btmp,lastlog,wtmp}
347chmod 644 /var/run/utmp /var/log/{btmp,lastlog,wtmp}</userinput></screen>
348
349<para>The <filename>/var/run/utmp</filename> file records the users that are
350currently logged in. The <filename>/var/log/wtmp</filename> file records all
351logins and logouts. The <filename>/var/log/lastlog</filename> file records for
352each user when he or she last logged in. The <filename>/var/log/btmp</filename>
353file records the bad login attempts.</para>
354
355</sect1>
356
357
358&c6-makedev;
359&c6-kernel-headers;
360&c6-manpages;
361&c6-glibc;
362
363
364<sect1 id="ch-system-readjusting">
365<title>Re-adjusting the toolchain</title>
366<?dbhtml filename="readjusting.html" dir="chapter06"?>
367
368<para>Now that the new and final C libraries have been installed, it's time to
369adjust our toolchain again. We'll adjust it so that it will link any newly
370compiled program against these new libraries. This is in fact the same thing we
371did in the "Adjusting" phase in the beginning of the previous chapter, even
372though it looks like the reverse: then we guided the chain from the host's
373<filename class="directory">/{,usr/}lib</filename> to the new
374<filename class="directory">/tools/lib</filename>, now we guide it from that
375same <filename class="directory">/tools/lib</filename>
376to the LFS's <filename class="directory">/{,usr/}lib</filename>.</para>
377
378<para>First we adjust the linker. For this we retained the
379source and build directories from the second pass over Binutils. Install the
380adjusted linker by running the following from within the
381<filename class="directory">binutils-build</filename> directory:</para>
382
383<screen><userinput>make -C ld INSTALL=/tools/bin/install install</userinput></screen>
384
385<note><para>If you somehow missed the earlier warning to retain the Binutils
386source and build directories from the second pass in
387<xref linkend="chapter-temporary-tools"/>, or otherwise accidentally deleted them or just
388don't have access to them, don't worry, all is not lost. Just ignore the above
389command. The result will be that the next package, Binutils, will link against
390the C libraries in <filename class="directory">/tools</filename> rather
391than in <filename class="directory">/{,usr/}lib</filename>. This is not ideal,
392however, our testing has shown that the resulting Binutils program binaries
393should be identical.</para></note>
394
395<para>From now on every compiled program will link <emphasis>only</emphasis>
396against the libraries in <filename>/usr/lib</filename> and
397<filename>/lib</filename>. The extra
398<emphasis>INSTALL=/tools/bin/install</emphasis> is needed because the Makefile
399created during the second pass still contains the reference to
400<filename>/usr/bin/install</filename>, which we obviously haven't installed yet.
401Some host distributions contain a <filename class="symlink">ginstall</filename>
402symbolic link which takes precedence in the Makefile and thus can cause a
403problem here. The above command takes care of this also.</para>
404
405<para>You can now remove the Binutils source and build directories.</para>
406
407<para>The next thing to do is to amend our GCC specs file so that it points
408to the new dynamic linker. Just like earlier on, we use a sed to accomplish
409this:</para>
410
411<!-- Ampersands are needed to allow cut and paste -->
412
413<screen><userinput>SPECFILE=/tools/lib/gcc-lib/*/*/specs &amp;&amp;
414sed -e 's@ /tools/lib/ld-linux.so.2@ /lib/ld-linux.so.2@g' \
415&nbsp;&nbsp;&nbsp;&nbsp;$SPECFILE &gt; newspecfile &amp;&amp;
416mv -f newspecfile $SPECFILE &amp;&amp;
417unset SPECFILE</userinput></screen>
418
419<para>Again, cutting and pasting the above is recommended. And just like
420before, it is a good idea to visually inspect the specs file to verify the
421intended change was actually made.</para>
422
423<important><para>If you are working on a platform where the name of the dynamic
424linker is something other than <filename>ld-linux.so.2</filename>, you
425<emphasis>must</emphasis> substitute <filename>ld-linux.so.2</filename> with the
426name of your platform's dynamic linker in the above commands. Refer back to
427<xref linkend="tools-technicalnotes"/> if necessary.</para></important>
428
429<!-- HACK - Force some whitespace to appease tidy -->
430<literallayout></literallayout>
431
432<caution><para>It is imperative at this point to stop and ensure that the
433basic functions (compiling and linking) of the adjusted toolchain are working
434as expected. For this we are going to perform a simple sanity check:</para>
435
436<screen><userinput>echo 'main(){}' &gt; dummy.c
437cc dummy.c
438readelf -l a.out | grep ': /lib'</userinput></screen>
439
440<para>If everything is working correctly, there should be no errors, and the
441output of the last command will be (allowing for platform specific differences
442in dynamic linker name):</para>
443
444<blockquote><screen>[Requesting program interpreter: /lib/ld-linux.so.2]</screen></blockquote>
445
446<para>Note especially that <filename class="directory">/lib</filename> is now
447the prefix of our dynamic linker.</para>
448
449<para> If you did not receive the output
450as shown above, or received no output at all, then something is seriously wrong.
451You will need to investigate and retrace your steps to find out where the
452problem is and correct it. There is no point in continuing until this is done.
453Most likely something went wrong with the specs file amendment above.</para>
454
455<para>Once you are satisfied that all is well, clean up the test files:</para>
456
457<screen><userinput>rm dummy.c a.out</userinput></screen>
458</caution>
459
460<!-- HACK - Force some whitespace to appease tidy -->
461<literallayout></literallayout>
462
463</sect1>
464
465
466&c6-binutils;
467&c6-gcc;
468
469&c6-coreutils;
470&c6-zlib;
471&c6-lfs-utils;
472&c6-findutils;
473&c6-gawk;
474&c6-ncurses;
475&c6-vim;
476&c6-m4;
477&c6-bison;
478&c6-less;
479&c6-groff;
480&c6-sed;
481&c6-flex;
482&c6-gettext;
483&c6-nettools;
484&c6-inetutils;
485&c6-perl;
486&c6-texinfo;
487&c6-autoconf;
488&c6-automake;
489&c6-bash;
490&c6-file;
491&c6-libtool;
492&c6-bzip2;
493&c6-diffutils;
494&c6-ed;
495&c6-kbd;
496&c6-e2fsprogs;
497&c6-grep;
498&c6-grub;
499&c6-gzip;
500&c6-man;
501&c6-make;
502&c6-modutils;
503&c6-patch;
504&c6-procinfo;
505&c6-procps;
506&c6-psmisc;
507&c6-shadow;
508&c6-sysklogd;
509&c6-sysvinit;
510&c6-tar;
511&c6-utillinux;
512&c6-gcc-2953;
513
514
515<sect1 id="ch-system-aboutdebug">
516<title>About debugging symbols</title>
517<?dbhtml filename="aboutdebug.html" dir="chapter06"?>
518
519<para>Most programs and libraries are, by default, compiled with debugging
520symbols included (with <command>gcc</command>'s <emphasis>-g</emphasis>
521option). This means that, when debugging a program or library that was compiled
522with debugging information included, the debugger can give you not only memory
523addresses but also the names of the routines and variables.</para>
524
525<para>The inclusion of these debugging symbols, however, enlarges a program or
526library significantly. To get an idea of the amount of space these symbols
527occupy, have a look at the following:</para>
528
529<itemizedlist>
530
531<listitem><para>a bash binary
532with debugging symbols: 1200 KB</para></listitem>
533
534<listitem><para>a bash binary
535without debugging symbols: 480 KB</para></listitem>
536
537<listitem><para>Glibc and GCC files (/lib and /usr/lib)
538with debugging symbols: 87 MB</para></listitem>
539
540<listitem><para>Glibc and GCC files
541without debugging symbols: 16 MB</para></listitem>
542
543</itemizedlist>
544
545<para>Sizes may vary somewhat, depending on which compiler was used and which C
546library, but when comparing programs with and without debugging symbols the
547difference will generally be a factor between 2 and 5.</para>
548
549<para>As most people will probably never use a debugger on their system
550software, a lot of disk space can be regained by removing these symbols. For
551your convenience, the next section shows how to strip all debugging symbols
552from all programs and libraries. Information on other ways of optimizing your
553system can be found in the hint at <ulink
554url="&hints-root;optimization.txt"/>.</para>
555
556</sect1>
557
558
559<sect1 id="ch-system-strippingagain">
560<title>Stripping again</title>
561<?dbhtml filename="strippingagain.html" dir="chapter06"?>
562
563<para>If you are not a programmer and don't plan to do any debugging on your
564system software, you can shrink your system by about 200 MB by removing the
565debugging symbols from binaries and libraries. This causes no inconvenience
566other than not being able to debug the software fully any more.</para>
567
568<para>Most people who use the command mentioned below don't experience any
569problems. But it is easy to make a typo and render your new system unusable, so
570before running the strip command it is probably a good idea to make a backup of
571the current situation.</para>
572
573<para>If you are going to perform the stripping, special care is needed to
574ensure you're not running any of the binaries that are about to be stripped.
575If you're not sure whether you entered chroot with the command given in
576<xref linkend="ch-system-chroot"/>, then first exit from chroot:</para>
577
578<screen><userinput>logout</userinput></screen>
579
580<para>Then reenter it with:</para>
581
582<screen><userinput>chroot $LFS /tools/bin/env -i \
583&nbsp;&nbsp;&nbsp;&nbsp;TERM=$TERM PS1='\u:\w\$ ' \
584&nbsp;&nbsp;&nbsp;&nbsp;PATH=/bin:/usr/bin:/sbin:/usr/sbin \
585&nbsp;&nbsp;&nbsp;&nbsp;/tools/bin/bash</userinput></screen>
586
587<para>Now you can safely strip the binaries and libraries:</para>
588
589<screen><userinput>/tools/bin/find /{,usr/}{bin,lib,sbin} -type f \
590&nbsp;&nbsp;&nbsp;-exec /tools/bin/strip --strip-debug '{}' ';'</userinput></screen>
591
592<para>A large number of files will be reported as having their file format not
593recognized. These warnings can be safely ignored, they just mean that those
594files are scripts instead of binaries, no harm is done.</para>
595
596<para>If you are really tight on disk space, you may want to use
597<emphasis>--strip-all</emphasis> on the binaries in
598<filename>/{,usr/}{bin,sbin}</filename> to gain several more megabytes. But do
599<emphasis>not</emphasis> use this option on libraries: they would be
600destroyed.</para>
601
602</sect1>
603
604
605<sect1 id="ch-system-revisedchroot">
606<title>Cleaning up</title>
607<?dbhtml filename="revisedchroot.html" dir="chapter06"?>
608
609<para>From now on, when you exit the chroot environment and wish to reenter
610it, you should use the following modified chroot command:</para>
611
612<screen><userinput>chroot $LFS /usr/bin/env -i \
613&nbsp;&nbsp;&nbsp;&nbsp;TERM=$TERM PS1='\u:\w\$ ' \
614&nbsp;&nbsp;&nbsp;&nbsp;PATH=/bin:/usr/bin:/sbin:/usr/sbin \
615&nbsp;&nbsp;&nbsp;&nbsp;/bin/bash</userinput></screen>
616
617<para>The reason for this is that, since the programs in <filename
618class="directory">/tools</filename> are no longer needed, you may want to
619delete the whole directory and regain the space. Before actually deleting the
620directory, exit from chroot and reenter it with the above command. Also, before
621removing <filename class="directory">/tools</filename>, you may want to tar it
622up and store it in a safe place, in case you want to build another LFS system
623soon.</para>
624
625<note><para>Removing <filename class="directory">/tools</filename> will also
626remove the temporary copies of Tcl, Expect and DejaGnu, which were used for
627running the toolchain tests. If you want to use these programs later on, you
628will need to recompile and re-install them. The installation instructions are
629the same as in <xref linkend="chapter-temporary-tools"/>, apart from changing
630the prefix from <emphasis>/tools</emphasis> to <emphasis>/usr</emphasis>. The
631BLFS book discusses a slightly different approach to installing Tcl, see <ulink
632url="&blfs-root;"/>.</para></note>
633
634<para>You may also want to move the packages and patches stored in <filename
635class="directory">/sources</filename> to a more usual location, such as
636<filename class="directory">/usr/src/packages</filename>, and remove the
637directory -- or simply delete the whole directory if you've burned its contents
638on a CD).</para>
639
640</sect1>
641
642</chapter>
643
Note: See TracBrowser for help on using the repository browser.