Clarify chapter 7 stripping and backup

In chapter 7 we do not need to unmount file systems to strip binaries.
Move unmounting to the backup/restore sections.

Also make sure the stripping commands are valid.
This commit is contained in:
Bruce Dubbs 2021-08-03 21:35:39 -05:00
parent adcaf07efb
commit c649743dd6

View File

@ -55,28 +55,27 @@
</para> </para>
<para> <para>
Leave the chroot environment and unmount the kernel virtual file Now, if you are stripping installed files or making a backup,
systems: leave the chroot environment:
</para> </para>
<note> <screen role="nodump"><userinput>exit</userinput></screen>
<important>
<para>All of the following instructions are executed by <para>All of the following instructions are executed by
<systemitem class="username">root</systemitem>. Take extra <systemitem class="username">root</systemitem>. Take extra
care about the commands you're going to run as mistakes care about the commands you're going to run as mistakes
here can modify your host system. Be aware that the here can modify your host system. Be aware that the
environment variable <envar>LFS</envar> is set for user environment variables <envar>LFS</envar> and <envar>LFS_TGT</envar>
<systemitem class="username">lfs</systemitem> by default are set for user <systemitem class="username">lfs</systemitem> by default
but it might <emphasis>not</emphasis> be set for but may <emphasis>not</emphasis> be set for
<systemitem class="username">root</systemitem>. Whenever <systemitem class="username">root</systemitem>. Whenever
commands are to be executed by <systemitem class="username">root</systemitem>, commands are to be executed by <systemitem class="username">root</systemitem>,
make sure you have set <envar>LFS</envar> accordingly. make sure you have set <envar>LFS</envar> and <envar>LFS_TGT</envar> accordingly.
This has been discussed in <xref linkend='ch-partitioning-aboutlfs'/>. This has been discussed in <xref linkend='ch-partitioning-aboutlfs'/>.
</para> </para>
</note> </important>
<screen role="nodump"><userinput>exit
umount $LFS/dev{/pts,}
umount $LFS/{sys,proc,run}</userinput></screen>
<sect2> <sect2>
<title>Stripping</title> <title>Stripping</title>
@ -87,15 +86,15 @@ umount $LFS/{sys,proc,run}</userinput></screen>
symbols.</para> symbols.</para>
<para>Strip off debugging symbols from binaries:</para> <para>Strip off debugging symbols from binaries:</para>
<screen role="nodump"><userinput>$LFS_TGT-strip --strip-unneeded $LFS/usr/lib/*
$LFS_TGT-strip --strip-unneeded $LFS/usr/{,s}bin/* <screen role="nodump"><userinput>cd $LFS/tools/$LFS_TGT
$LFS_TGT-strip --strip-unneeded $LFS/tools/bin/*</userinput></screen> bin/strip --strip-unneeded $LFS/usr/lib/*
bin/strip --strip-unneeded $LFS/usr/{,s}bin/*
bin/strip --strip-unneeded $LFS/tools/bin/*</userinput></screen>
<para>These commands will skip a number of files reporting that it does not <para>These commands will skip a number of files reporting that it does not
recognize their file format. Most of these are scripts instead of binaries. recognize their file format. Most of these are scripts instead of binaries.
<!--Note that we use the <command>strip</command> program built in </para>
<quote>Binutils pass 2</quote>, since it is the one that knows how to strip
our cross-compiled programs.--></para>
<para>At this point, you should have at least 5 GB of free space on the <para>At this point, you should have at least 5 GB of free space on the
chroot partition that can be used to build and install Glibc and GCC in chroot partition that can be used to build and install Glibc and GCC in
@ -125,14 +124,19 @@ $LFS_TGT-strip --strip-unneeded $LFS/tools/bin/*</userinput></screen>
<systemitem class="username">root</systemitem>. <systemitem class="username">root</systemitem>.
</para> </para>
<para>Before we make a backup, unmount the virtual file systems:</para>
<screen role="nodump"><userinput>umount $LFS/dev{/pts,}
umount $LFS/{sys,proc,run}</userinput></screen>
<para> <para>
Create the backup archive by running the following command: Create the backup archive by running the following command:
</para> </para>
<screen role="nodump" revision="sysv"><userinput>cd $LFS &amp;&amp; <screen role="nodump" revision="sysv"><userinput>cd $LFS
tar -cJpf $HOME/lfs-temp-tools-&version;.tar.xz .</userinput></screen> tar -cJpf $HOME/lfs-temp-tools-&version;.tar.xz .</userinput></screen>
<screen role="nodump" revision="systemd"><userinput>cd $LFS &amp;&amp; <screen role="nodump" revision="systemd"><userinput>cd $LFS
tar -cJpf $HOME/lfs-temp-tools-&versiond;.tar.xz .</userinput></screen> tar -cJpf $HOME/lfs-temp-tools-&versiond;.tar.xz .</userinput></screen>
<para> <para>
@ -158,12 +162,12 @@ tar -cJpf $HOME/lfs-temp-tools-&versiond;.tar.xz .</userinput></screen>
<!-- Make the following look different so users don't blindly run the <!-- Make the following look different so users don't blindly run the
restore when they don't need to. --> restore when they don't need to. -->
<screen role="nodump" revision="sysv"><computeroutput>cd $LFS &amp;&amp; <screen role="nodump" revision="sysv"><computeroutput>cd $LFS
rm -rf ./* &amp;&amp; rm -rf ./*
tar -xpf $HOME/lfs-temp-tools-&version;.tar.xz</computeroutput></screen> tar -xpf $HOME/lfs-temp-tools-&version;.tar.xz</computeroutput></screen>
<screen role="nodump" revision="systemd"><computeroutput>cd $LFS &amp;&amp; <screen role="nodump" revision="systemd"><computeroutput>cd $LFS
rm -rf ./* &amp;&amp; rm -rf ./*
tar -xpf $HOME/lfs-temp-tools-&versiond;.tar.xz</computeroutput></screen> tar -xpf $HOME/lfs-temp-tools-&versiond;.tar.xz</computeroutput></screen>
<para> <para>
@ -173,8 +177,8 @@ tar -xpf $HOME/lfs-temp-tools-&versiond;.tar.xz</computeroutput></screen>
<important> <important>
<para> <para>
If you left the chroot environment either to strip off debug If you left the chroot environment
symbols, create a backup, or restart building using a restore, to create a backup or restart building using a restore,
remember to check that the virtual filesystems are still remember to check that the virtual filesystems are still
mounted (<command>findmnt | grep $LFS</command>). mounted (<command>findmnt | grep $LFS</command>).
If they are not mounted, remount them now as If they are not mounted, remount them now as