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 files 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, on a modern Linux system, the libtool .la files are only
|
---|
22 | useful for libltdl. No libraries in LFS are loaded by
|
---|
23 | libltdl, and it's known that some .la files can cause BLFS package
|
---|
24 | failures. 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 way to recover. Unfortunately, all the
|
---|
46 | temporary files will be removed, too. To avoid spending extra time to
|
---|
47 | redo something which has been done 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 | If you are making a backup, mount the partition for backup:
|
---|
61 | </para>
|
---|
62 |
|
---|
63 | <screen role="nodump"><userinput>mount -v /dev/sda<replaceable>4</replaceable> /mnt</userinput></screen>
|
---|
64 |
|
---|
65 | <para>
|
---|
66 | Make sure you have at least 1 GB free disk space (the source tarballs
|
---|
67 | will be included in the backup archive) in the partition prepared for
|
---|
68 | backup.
|
---|
69 | </para>
|
---|
70 |
|
---|
71 | <para>
|
---|
72 | Note that the instructions below specify the home directory of the host
|
---|
73 | system's <systemitem class="username">root</systemitem> user, which is
|
---|
74 | typically found on the root file system.
|
---|
75 | Replace <envar>$HOME</envar> by a directory of your choice if you
|
---|
76 | do not want to have the backup stored in <systemitem
|
---|
77 | class="username">root</systemitem>'s home directory.
|
---|
78 | </para>
|
---|
79 |
|
---|
80 | <para>
|
---|
81 | Create the backup archive by running the following command:
|
---|
82 | </para>
|
---|
83 |
|
---|
84 | <note>
|
---|
85 | <para>
|
---|
86 | Because the backup archive is compressed, it takes a relatively
|
---|
87 | long time (over 10 minutes) even on a reasonably fast system.
|
---|
88 | </para>
|
---|
89 | </note>
|
---|
90 |
|
---|
91 | <screen role="nodump"><userinput>cd /
|
---|
92 | tar -cJpf /mnt/lfs-temp-tools-&version;.tar.xz . \
|
---|
93 | --exclude="dev/*" --exclude="proc/*"
|
---|
94 | --exclude="sys/*" --exclude="run/*"
|
---|
95 | --exclude="mnt/*"</userinput></screen>
|
---|
96 |
|
---|
97 | <para>Unmount the partition containing the backup:</para>
|
---|
98 |
|
---|
99 | <screen role="nodump"><userinput>umount /mnt</userinput></screen>
|
---|
100 |
|
---|
101 | </sect2>
|
---|
102 |
|
---|
103 | <sect2>
|
---|
104 | <title>Restore</title>
|
---|
105 |
|
---|
106 | <para>
|
---|
107 | In case some mistakes have been made and you need to start over, you can
|
---|
108 | use this backup to restore the system and save some recovery time.
|
---|
109 | Since the sources are included in the
|
---|
110 | backup archive as well, so they do not need to be downloaded again.
|
---|
111 | </para>
|
---|
112 |
|
---|
113 | <warning><para>
|
---|
114 | Power off the target system and reconnect the disk containing LFS
|
---|
115 | temporary system to the host for restoring the backup. It's necessary
|
---|
116 | to avoid overwriting some binaries being used. Because the package
|
---|
117 | providing <command>shutdown</command> command is not built yet, the
|
---|
118 | system can't be shut down cleanly. Issue <command>sync</command> to
|
---|
119 | ensure all filesystem writes cached in memory to be really written
|
---|
120 | into the disk, then power off the system physically (for example,
|
---|
121 | unplug the AC cord).
|
---|
122 | </para></warning>
|
---|
123 |
|
---|
124 | <para>Mount the LFS partition and the backup partition on
|
---|
125 | <emphasis role="bold">the host system</emphasis>:</para>
|
---|
126 |
|
---|
127 | <!-- Make the following look different so users don't blindly run the
|
---|
128 | restore when they don't need to. -->
|
---|
129 |
|
---|
130 | <screen role="nodump"><computeroutput>mkdir -pv /mnt/lfs-{target,backup}
|
---|
131 | mount -v -t ext4 <replaceable>/dev/sdx</replaceable>3 /mnt/lfs-target
|
---|
132 | mount -v -t ext4 <replaceable>/dev/sdx4</replaceable> /mnt/lfs-backup</computeroutput></screen>
|
---|
133 |
|
---|
134 |
|
---|
135 | <warning><para>The following commands are extremely dangerous. If
|
---|
136 | you run <command>rm -rf ./*</command> as the &root; user and you
|
---|
137 | do not change to the <filename>lfs-target</filename> directory,
|
---|
138 | it will destroy your entire host system.
|
---|
139 | YOU ARE WARNED.</para></warning>
|
---|
140 |
|
---|
141 | <screen role="nodump"><computeroutput>cd /mnt/lfs-target
|
---|
142 | rm -rf ./*
|
---|
143 | tar -xpf /mnt/lfs-backup/lfs-temp-tools-&version;.tar.xz</computeroutput></screen>
|
---|
144 |
|
---|
145 | <para>
|
---|
146 | Again, unmount the two partitions, reconnect the device to the target
|
---|
147 | machine, boot it and continue building the rest of system:
|
---|
148 | </para>
|
---|
149 |
|
---|
150 | <screen role="nodump"><computeroutput>umount /mnt/lfs-{target,backup}</computeroutput></screen>
|
---|
151 |
|
---|
152 | <important>
|
---|
153 | <para>
|
---|
154 | If you reboot your target machine and restart
|
---|
155 | building using a restore, remount the virtual filesystems now as
|
---|
156 | described in <xref linkend='ch-tools-kernfs'/> and re-enter the build
|
---|
157 | environment (see <xref linkend='ch-tools-chroot'/>) before continuing.
|
---|
158 | </para>
|
---|
159 | </important>
|
---|
160 |
|
---|
161 | </sect2>
|
---|
162 |
|
---|
163 | </sect1>
|
---|