source: chapter07/cleanup.xml@ 3a5d53a

xry111/clfs-ng
Last change on this file since 3a5d53a was 3a5d53a, checked in by Xi Ruoyao <xry111@…>, 9 months ago

cross-ng: adjust backup & restore for cross build

  • Property mode set to 100644
File size: 6.3 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 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 /
95tar -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 <note>
105 <para>
106 If continuing to chapter 8, don't forget to reenter the chroot
107 environment as explained in the <quote>Important</quote> box below.
108 </para>
109 </note>
110
111 </sect2>
112
113 <sect2>
114 <title>Restore</title>
115
116 <para>
117 In case some mistakes have been made and you need to start over, you can
118 use this backup to restore the system and save some recovery time.
119 Since the sources are included in the
120 backup archive as well, so they do not need to be downloaded again.
121 </para>
122
123 <warning><para>
124 Power off the target system and reconnect the disk containing LFS
125 temporary system to the host for restoring the backup. It's necessary
126 to avoid overwriting some binaries being used. Because the package
127 providing <command>shutdown</command> command is not built yet, the
128 system can't be shut down cleanly. Issue <command>sync</command> to
129 ensure all filesystem writes cached in memory to be really written
130 into the disk, then power off the system physically (for example,
131 unplug the AC cord).
132 </para></warning>
133
134 <para>Mount the LFS partition and the backup partition on
135 <emphasis role="bold">the host system</emphasis>:</para>
136
137<!-- Make the following look different so users don't blindly run the
138 restore when they don't need to. -->
139
140<screen role="nodump"><computeroutput>mkdir -pv /mnt/lfs-{target,backup}
141mount -v -t ext4 <replaceable>/dev/sdx</replaceable>3 /mnt/lfs-target
142mount -v -t ext4 <replaceable>/dev/sdx4</replaceable> /mnt/lfs-backup</computeroutput></screen>
143
144
145 <warning><para>The following commands are extremely dangerous. If
146 you run <command>rm -rf ./*</command> as the root user and you
147 do not change to the <filename>lfs-target</filename> directory,
148 it will destroy your entire host system.
149 YOU ARE WARNED.</para></warning>
150
151<screen role="nodump"><computeroutput>cd /mnt/lfs-target
152rm -rf ./*
153tar -xpf /mnt/lfs-backup/lfs-temp-tools-&version;.tar.xz</computeroutput></screen>
154
155 <para>
156 Again, unmount the two partitions, reconnect the device to the target
157 machine, boot it and continue building the rest of system:
158 </para>
159
160<screen role="nodump"><computeroutput>umount /mnt/lfs-{target,backup}</computeroutput></screen>
161
162 <important>
163 <para>
164 If you reboot your target machine and restart
165 building using a restore, remount the virtual filesystems now as
166 described in <xref linkend='ch-tools-kernfs'/> and re-enter the build
167 environment (see <xref linkend='ch-tools-chroot'/>) before continuing.
168 </para>
169 </important>
170
171 </sect2>
172
173</sect1>
Note: See TracBrowser for help on using the repository browser.