source: chapter07/cleanup.xml@ b649e6b

11.0 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 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 b649e6b was b649e6b, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

Typo (double "the") Spotted by Rainer Fiebig

  • Property mode set to 100644
File size: 6.7 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-tools-cleanup">
9 <?dbhtml filename="cleanup.html"?>
10
11 <title>Cleaning up and Saving the Temporary System</title>
12
13 <sect2>
14 <title>Cleaning</title>
15
16 <para>First, remove the currently installed documentation to prevent them
17 from ending up in the final system, and to save about 35 MB:</para>
18
19<screen><userinput>rm -rf /usr/share/{info,man,doc}/*</userinput></screen>
20
21 <para>Second, the libtool .la files are only useful when linking with static
22 libraries. They are unneeded and potentially harmful when using dynamic
23 shared libraries, specially when using non-autotools build systems.
24 While still in chroot, remove those files now:</para>
25
26<screen><userinput>find /usr/{lib,libexec} -name \*.la -delete</userinput></screen>
27
28 <para>
29 The current system size is now about 3 GB, however
30 the /tools directory is no longer needed. It uses about
31 1 GB of disk space. Delete it now:
32 </para>
33
34<screen><userinput>rm -rf /tools</userinput></screen>
35 </sect2>
36
37 <sect2>
38 <title>Backup</title>
39
40 <note><para>
41 All the remaining steps in this section are optional. Nevertheless,
42 as soon as you begin installing packages in <xref
43 linkend="chapter-building-system"/>, the temporary files will be
44 overwritten. So it may be a good idea to do a backup of the current
45 system as described below.
46 </para></note>
47
48 <para>
49 The following steps are performed from outside the chroot
50 environment. That means, you have to leave the chroot environment
51 first before continuing. The reason for that is to
52 get access to file system locations outside of the chroot
53 environment to store/read the backup archive which should
54 not be placed within the
55 <filename class="directory">$LFS</filename> hierarchy for
56 safety reasons.
57 </para>
58
59 <important>
60 <para>All of the following instructions are executed by
61 <systemitem class="username">root</systemitem>. Take extra
62 care about the commands you're going to run as mistakes
63 here can modify your host system. Be aware that the
64 environment variable <envar>LFS</envar>
65 is set for user <systemitem class="username">lfs</systemitem> by default
66 but may <emphasis>not</emphasis> be set for
67 <systemitem class="username">root</systemitem>. Whenever
68 commands are to be executed by <systemitem class="username">root</systemitem>,
69 make sure you have set <envar>LFS</envar>.
70 This has been discussed in <xref linkend='ch-partitioning-aboutlfs'/>.
71 </para>
72 </important>
73
74 <para>
75 Now, if you are making a backup, leave the chroot environment:
76 </para>
77
78<screen role="nodump"><userinput>exit</userinput></screen>
79
80 <para>
81 At this point the essential programs and libraries have been created
82 and your current system is in a good state. Your system can now be
83 backed up for later reuse. In case of fatal failures in the subsequent
84 chapters, it often turns out that removing everything and starting over
85 (more carefully) is the best option to recover. Unfortunately, all the
86 temporary files will be removed, too. To avoid spending extra time to
87 redo something which has been built successfully, prepare a backup.
88 </para>
89
90 <para>
91 Make sure you have at least 1 GB free disk space (the source tarballs
92 will be included in the backup archive) in the home directory of user
93 <systemitem class="username">root</systemitem>.
94 </para>
95
96 <para>Before we make a backup, unmount the virtual file systems:</para>
97
98<screen role="nodump"><userinput>umount $LFS/dev{/pts,}
99umount $LFS/{sys,proc,run}</userinput></screen>
100
101 <para>
102 Create the backup archive by running the following command:
103 </para>
104
105 <note>
106 <para>
107 Because the backup archive is compressed, it takes a relatively
108 long time (over 10 minutes) even on a resonably fast system.
109 </para>
110
111 <para>
112 Also, ensure the <envar>LFS</envar> environment variable is set
113 for the root user.
114 </para>
115 </note>
116
117<screen role="nodump" revision="sysv"><userinput>cd $LFS
118tar -cJpf $HOME/lfs-temp-tools-&version;.tar.xz .</userinput></screen>
119
120<screen role="nodump" revision="systemd"><userinput>cd $LFS
121tar -cJpf $HOME/lfs-temp-tools-&versiond;.tar.xz .</userinput></screen>
122
123 <para>
124 Replace <envar>$HOME</envar> by a directory of your choice if you
125 do not want to have the backup stored in <systemitem
126 class="username">root</systemitem>'s home directory.
127 </para>
128 </sect2>
129
130 <sect2>
131 <title>Restore</title>
132
133 <para>
134 In case some mistakes have been made and you need to start over, you can
135 use this backup to restore the system and save some recovery time.
136 Since the sources are located under
137 <filename class="directory">$LFS</filename>, they are included in the
138 backup archive as well, so they do not need to be downloaded again. After
139 checking that <envar>$LFS</envar> is set properly,
140 restore the backup by executing the following commands:
141 </para>
142
143<!-- Make the following look different so users don't blindly run the
144 restore when they don't need to. -->
145
146 <warning><para>The following commands are extremly dangerous. If
147 you run <command>rm -rf ./*</command> as the root user and you
148 do not change to the $LFS directory or the <envar>LFS</envar>
149 environment variable is not set for the root user, it will destroy
150 your entire host system. YOU ARE WARNED.</para></warning>
151
152<screen role="nodump" revision="sysv"><computeroutput>cd $LFS
153rm -rf ./*
154tar -xpf $HOME/lfs-temp-tools-&version;.tar.xz</computeroutput></screen>
155
156<screen role="nodump" revision="systemd"><computeroutput>cd $LFS
157rm -rf ./*
158tar -xpf $HOME/lfs-temp-tools-&versiond;.tar.xz</computeroutput></screen>
159
160 <para>
161 Again, double check that the environment has been setup properly
162 and continue building the rest of the system.
163 </para>
164
165 <important>
166 <para>
167 If you left the chroot environment to create a backup or restart
168 building using a restore, remember to check that the virtual
169 filesystems are still mounted (<command>findmnt | grep
170 $LFS</command>). If they are not mounted, remount them now as
171 described in <xref linkend='ch-tools-kernfs'/> and re-enter the chroot
172 environment (see <xref linkend='ch-tools-chroot'/>) before continuing.
173 </para>
174 </important>
175
176 </sect2>
177
178</sect1>
Note: See TracBrowser for help on using the repository browser.