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