source: chapter07/cleanup.xml@ 940c9ebd

xry111/clfs-ng
Last change on this file since 940c9ebd was 940c9ebd, checked in by Xi Ruoyao <xry111@…>, 2 years ago

cross-ng: Revert "Add a note telling to reenter chroot after making a backup"

This reverts commit 7fba0753d1a4511a3aa631982623afa001f846d9.

  • Property mode set to 100644
File size: 6.1 KB
RevLine 
[02b2631]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
[8a269ec]8<sect1 id="ch-tools-cleanup">
9 <?dbhtml filename="cleanup.html"?>
[02b2631]10
11 <title>Cleaning up and Saving the Temporary System</title>
[2c8fdfc]12
[02b2631]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
[3a5d53a]23 shared libraries, specially when using non-autotools build systems.
24 While still on the target machine, remove those files now:</para>
[02b2631]25
26<screen><userinput>find /usr/{lib,libexec} -name \*.la -delete</userinput></screen>
27
28 <para>
[2c8fdfc]29 The current system size is now about 3 GB, however
[02b2631]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
[beb80e2]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
[02b2631]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
[2c8fdfc]56 system as described below.
[02b2631]57 </para></note>
[2c8fdfc]58
[02b2631]59 <para>
[3a5d53a]60 If you are making a backup, mount the partition for backup:
[02b2631]61 </para>
62
[3a5d53a]63<screen role="nodump"><userinput>mount -v /dev/sda<replaceable>4</replaceable> /mnt</userinput></screen>
[02b2631]64
65 <para>
[beb80e2]66 Make sure you have at least 1 GB free disk space (the source tarballs
[3a5d53a]67 will be included in the backup archive) in the partition prepared for
68 backup.
[02b2631]69 </para>
70
71 <para>
[beb80e2]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.
[02b2631]75 </para>
76
[beb80e2]77 <para>
78 Replace <envar>$HOME</envar> by a directory of your choice if you
[c6f58f47]79 do not want to have the backup stored in <systemitem
[beb80e2]80 class="username">root</systemitem>'s home directory.
81 </para>
[02b2631]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
[3a5d53a]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>
[02b2631]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.
[3a5d53a]112 Since the sources are included in the
113 backup archive as well, so they do not need to be downloaded again.
[02b2631]114 </para>
115
[3a5d53a]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
[02b2631]130<!-- Make the following look different so users don't blindly run the
131 restore when they don't need to. -->
132
[3a5d53a]133<screen role="nodump"><computeroutput>mkdir -pv /mnt/lfs-{target,backup}
134mount -v -t ext4 <replaceable>/dev/sdx</replaceable>3 /mnt/lfs-target
135mount -v -t ext4 <replaceable>/dev/sdx4</replaceable> /mnt/lfs-backup</computeroutput></screen>
136
137
[9904ecb]138 <warning><para>The following commands are extremely dangerous. If
[2c8fdfc]139 you run <command>rm -rf ./*</command> as the root user and you
[3a5d53a]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>
[02b2631]143
[3a5d53a]144<screen role="nodump"><computeroutput>cd /mnt/lfs-target
[2198b5e]145rm -rf ./*
[3a5d53a]146tar -xpf /mnt/lfs-backup/lfs-temp-tools-&version;.tar.xz</computeroutput></screen>
[02b2631]147
148 <para>
[3a5d53a]149 Again, unmount the two partitions, reconnect the device to the target
150 machine, boot it and continue building the rest of system:
[02b2631]151 </para>
152
[3a5d53a]153<screen role="nodump"><computeroutput>umount /mnt/lfs-{target,backup}</computeroutput></screen>
154
[02b2631]155 <important>
156 <para>
[3a5d53a]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
[02b2631]160 environment (see <xref linkend='ch-tools-chroot'/>) before continuing.
161 </para>
162 </important>
[2c8fdfc]163
[02b2631]164 </sect2>
165
166</sect1>
Note: See TracBrowser for help on using the repository browser.