source: chapter07/cleanup.xml@ c7c614de

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

Merge remote-tracking branch 'origin/trunk' into xry111/clfs-ng

  • Property mode set to 100644
File size: 6.0 KB
RevLine 
[7152faa]1<?xml version="1.0" encoding="UTF-8"?>
[02b2631]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
[ebecd08]16 <para>First, remove the currently installed documentation files to prevent them
[02b2631]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
[3d65730e]21 <para>Second, on a modern Linux system, the libtool .la files are only
[ebecd08]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>
[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
[ebecd08]45 (more carefully) is the best way to recover. Unfortunately, all the
[beb80e2]46 temporary files will be removed, too. To avoid spending extra time to
[ebecd08]47 redo something which has been done successfully, creating a backup of
[beb80e2]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
[ebecd08]74 typically found on the root file system.
[beb80e2]75 Replace <envar>$HOME</envar> by a directory of your choice if you
[c6f58f47]76 do not want to have the backup stored in <systemitem
[beb80e2]77 class="username">root</systemitem>'s home directory.
78 </para>
[02b2631]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
[bcb20b4]87 long time (over 10 minutes) even on a reasonably fast system.
[02b2631]88 </para>
89 </note>
90
[3a5d53a]91<screen role="nodump"><userinput>cd /
92tar -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>
[02b2631]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.
[3a5d53a]109 Since the sources are included in the
110 backup archive as well, so they do not need to be downloaded again.
[02b2631]111 </para>
112
[3a5d53a]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
[02b2631]127<!-- Make the following look different so users don't blindly run the
128 restore when they don't need to. -->
129
[3a5d53a]130<screen role="nodump"><computeroutput>mkdir -pv /mnt/lfs-{target,backup}
131mount -v -t ext4 <replaceable>/dev/sdx</replaceable>3 /mnt/lfs-target
132mount -v -t ext4 <replaceable>/dev/sdx4</replaceable> /mnt/lfs-backup</computeroutput></screen>
133
134
[9904ecb]135 <warning><para>The following commands are extremely dangerous. If
[e286d8db]136 you run <command>rm -rf ./*</command> as the &root; user and you
[3a5d53a]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>
[02b2631]140
[3a5d53a]141<screen role="nodump"><computeroutput>cd /mnt/lfs-target
[2198b5e]142rm -rf ./*
[3a5d53a]143tar -xpf /mnt/lfs-backup/lfs-temp-tools-&version;.tar.xz</computeroutput></screen>
[02b2631]144
145 <para>
[3a5d53a]146 Again, unmount the two partitions, reconnect the device to the target
147 machine, boot it and continue building the rest of system:
[02b2631]148 </para>
149
[3a5d53a]150<screen role="nodump"><computeroutput>umount /mnt/lfs-{target,backup}</computeroutput></screen>
151
[02b2631]152 <important>
153 <para>
[3a5d53a]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
[02b2631]157 environment (see <xref linkend='ch-tools-chroot'/>) before continuing.
158 </para>
159 </important>
[2c8fdfc]160
[02b2631]161 </sect2>
162
163</sect1>
Note: See TracBrowser for help on using the repository browser.