source: chapter07/cleanup.xml@ 69d280f

ml-11.0 multilib
Last change on this file since 69d280f was 69d280f, checked in by Thomas Trepl (Moody) <thomas@…>, 3 years ago

Automatic merge of trunk into multilib

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