source: chapter07/cleanup.xml@ c6f58f47

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

Merge branch 'trunk' of git.linuxfromscratch.org:lfs into trunk

  • Property mode set to 100644
File size: 7.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, especially 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 <para>
41 At this point the essential programs and libraries have been created
42 and your current LFS system is in a good state. Your system can now be
43 backed up for later reuse. In case of fatal failures in the subsequent
44 chapters, it often turns out that removing everything and starting over
45 (more carefully) is the best option to recover. Unfortunately, all the
46 temporary files will be removed, too. To avoid spending extra time to
47 redo something which has been built successfully, creating a backup of
48 the current LFS system may prove useful.
49 </para>
50
51 <note><para>
52 All the remaining steps in this section are optional. Nevertheless,
53 as soon as you begin installing packages in <xref
54 linkend="chapter-building-system"/>, the temporary files will be
55 overwritten. So it may be a good idea to do a backup of the current
56 system as described below.
57 </para></note>
58
59 <para>
60 The following steps are performed from outside the chroot
61 environment. That means, you have to leave the chroot environment
62 first before continuing. The reason for that is to
63 get access to file system locations outside of the chroot
64 environment to store/read the backup archive which should
65 not be placed within the
66 <filename class="directory">$LFS</filename> hierarchy for
67 safety reasons.
68 </para>
69
70 <para>
71 If you have decided to make a backup, leave the chroot environment:
72 </para>
73
74<screen role="nodump"><userinput>exit</userinput></screen>
75
76 <important>
77 <para>
78 All of the following instructions are executed by
79 <systemitem class="username">root</systemitem> on your host system.
80 Take extra care about the commands you're going to run as mistakes
81 here can modify your host system. Be aware that the
82 environment variable <envar>LFS</envar>
83 is set for user <systemitem class="username">lfs</systemitem> by default
84 but may <emphasis>not</emphasis> be set for
85 <systemitem class="username">root</systemitem>.
86 </para>
87 <para>
88 Whenever commands are to be executed by <systemitem class="username">root</systemitem>,
89 make sure you have set <envar>LFS</envar>.
90 </para>
91 <para>
92 This has been discussed in <xref linkend='ch-partitioning-aboutlfs'/>.
93 </para>
94 </important>
95
96 <para>Before making a backup, unmount the virtual file systems:</para>
97
98<screen role="nodump"><userinput>umount $LFS/dev/pts
99umount $LFS/{sys,proc,run,dev}</userinput></screen>
100
101 <para>
102 Make sure you have at least 1 GB free disk space (the source tarballs
103 will be included in the backup archive) on the filesystem containing
104 directory where you create the backup archive.
105 </para>
106
107 <para>
108<<<<<<< HEAD
109 Make sure you have at least 1 GB free disk space (the source tarballs
110 will be included in the backup archive) in the home directory of user
111 <systemitem class="username">root</systemitem>.
112=======
113 Note that the instructions below specify the home directory of the host
114 system's <systemitem class="username">root</systemitem> user, which is
115 typically found on the root filesystem.
116>>>>>>> 8e6babecd0d75542a01eedfde32556879733f842
117 </para>
118
119 <para>
120 Replace <envar>$HOME</envar> by a directory of your choice if you
121 do not want to have the backup stored in <systemitem
122 class="username">root</systemitem>'s home directory.
123 </para>
124
125 <para>
126 Create the backup archive by running the following command:
127 </para>
128
129 <note>
130 <para>
131 Because the backup archive is compressed, it takes a relatively
132 long time (over 10 minutes) even on a resonably fast system.
133 </para>
134<<<<<<< HEAD
135
136 <para>
137 Also, ensure the <envar>LFS</envar> environment variable is set
138 for the root user.
139 </para>
140=======
141>>>>>>> 8e6babecd0d75542a01eedfde32556879733f842
142 </note>
143
144<screen role="nodump" revision="sysv"><userinput>cd $LFS
145tar -cJpf $HOME/lfs-temp-tools-&version;.tar.xz .</userinput></screen>
146
147<screen role="nodump" revision="systemd"><userinput>cd $LFS
148tar -cJpf $HOME/lfs-temp-tools-&versiond;.tar.xz .</userinput></screen>
149
150<<<<<<< HEAD
151 <para>
152 Replace <envar>$HOME</envar> by a directory of your choice if you
153 do not want to have the backup stored in <systemitem
154 class="username">root</systemitem>'s home directory.
155 </para>
156=======
157>>>>>>> 8e6babecd0d75542a01eedfde32556879733f842
158 </sect2>
159
160 <sect2>
161 <title>Restore</title>
162
163 <para>
164 In case some mistakes have been made and you need to start over, you can
165 use this backup to restore the system and save some recovery time.
166 Since the sources are located under
167 <filename class="directory">$LFS</filename>, they are included in the
168 backup archive as well, so they do not need to be downloaded again. After
169 checking that <envar>$LFS</envar> is set properly,
170 restore the backup by executing the following commands:
171 </para>
172
173<!-- Make the following look different so users don't blindly run the
174 restore when they don't need to. -->
175
176 <warning><para>The following commands are extremly dangerous. If
177 you run <command>rm -rf ./*</command> as the root user and you
178 do not change to the $LFS directory or the <envar>LFS</envar>
179 environment variable is not set for the root user, it will destroy
180 your entire host system. YOU ARE WARNED.</para></warning>
181
182<screen role="nodump" revision="sysv"><computeroutput>cd $LFS
183rm -rf ./*
184tar -xpf $HOME/lfs-temp-tools-&version;.tar.xz</computeroutput></screen>
185
186<screen role="nodump" revision="systemd"><computeroutput>cd $LFS
187rm -rf ./*
188tar -xpf $HOME/lfs-temp-tools-&versiond;.tar.xz</computeroutput></screen>
189
190 <para>
191 Again, double check that the environment has been setup properly
192 and continue building the rest of the system.
193 </para>
194
195 <important>
196 <para>
197 If you left the chroot environment to create a backup or restart
198 building using a restore, remember to check that the virtual
199 filesystems are still mounted (<command>findmnt | grep
200 $LFS</command>). If they are not mounted, remount them now as
201 described in <xref linkend='ch-tools-kernfs'/> and re-enter the chroot
202 environment (see <xref linkend='ch-tools-chroot'/>) before continuing.
203 </para>
204 </important>
205
206 </sect2>
207
208</sect1>
Note: See TracBrowser for help on using the repository browser.