Changeset 3a5d53a

02/26/2022 04:01:39 PM (7 months ago)
Xi Ruoyao <xry111@…>
Xi Ruoyao <xry111@…> (02/26/2022 03:20:14 PM)
Xi Ruoyao <xry111@…> (02/26/2022 04:01:39 PM)

cross-ng: adjust backup & restore for cross build

2 edited


  • chapter06/grub-cfg.xml

    r9673470 r3a5d53a  
    165165Syncing disks.</literal></screen>
     167     <para>In <xref linkend="ch-tools-cleanup"/> it's optional to make a
     168     backup for the temporary system.  If you'd like to do so, prepare
     169     another parition (1 GB should be enough) and make an
     170     <systemitem class="filesystem">ext4</systemitem> filesystem to hold
     171     the backup:</para>
     173<screen><userinput role='nodump'>mkfs.ext4 /dev/<replaceable>sdx4</replaceable></userinput></screen>
    167175     <para><replaceable>sdx</replaceable> should be replaced with the name
    168176     of the device node corresponding to your moveable device. Then mount
  • chapter07/cleanup.xml

    r9673470 r3a5d53a  
    2121    <para>Second, the libtool .la files are only useful when linking with static
    2222    libraries. They are unneeded and potentially harmful when using dynamic
    23     shared libraries, especially when using non-autotools build systems.
    24     While still in chroot, remove those files now:</para>
     23    shared libraries, specially when using non-autotools build systems.
     24    While still on the target machine, remove those files now:</para>
    2626<screen><userinput>find /usr/{lib,libexec} -name \*.la -delete</userinput></screen>
    5959    <para>
    60       The following steps are performed from outside the chroot
    61       environment. That means, you have to leave the chroot environment
    62       first before continuing. The reason for that is to
    63       get access to file system locations outside of the chroot
    64       environment to store/read the backup archive which should
    65       not be placed within the
    66       <filename class="directory">$LFS</filename> hierarchy for
    67       safety reasons.
     60       If you are making a backup, mount the partition for backup:
    6861    </para>
    70     <para>
    71        If you have decided to make a backup, leave the chroot environment:
    72     </para>
    74 <screen role="nodump"><userinput>exit</userinput></screen>
    76     <important>
    77       <para>
    78         All of the following instructions are executed by
    79         <systemitem class="username">root</systemitem> on your host system.
    80         Take extra care about the commands you're going to run as mistakes
    81         here can modify your host system. Be aware that the
    82         environment variable <envar>LFS</envar>
    83         is set for user <systemitem class="username">lfs</systemitem> by default
    84         but may <emphasis>not</emphasis> be set for
    85         <systemitem class="username">root</systemitem>.
    86      </para>
    87      <para>
    88         Whenever commands are to be executed by <systemitem class="username">root</systemitem>,
    89         make sure you have set <envar>LFS</envar>.
    90      </para>
    91      <para>
    92         This has been discussed in <xref linkend='ch-partitioning-aboutlfs'/>.
    93       </para>
    94     </important>
    96     <para>Before making a backup, unmount the virtual file systems:</para>
    98 <screen role="nodump"><userinput>umount $LFS/dev/pts
    99 umount $LFS/{sys,proc,run,dev}</userinput></screen>
     63<screen role="nodump"><userinput>mount -v /dev/sda<replaceable>4</replaceable> /mnt</userinput></screen>
    10165    <para>
    10266      Make sure you have at least 1 GB free disk space (the source tarballs
    103       will be included in the backup archive) on the filesystem containing
    104       directory where you create the backup archive.
     67      will be included in the backup archive) in the partition prepared for
     68      backup.
    10569    </para>
    12892    </note>
    130 <screen role="nodump"><userinput>cd $LFS
    131 tar -cJpf $HOME/lfs-temp-tools-&version;.tar.xz .</userinput></screen>
     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>
     100    <para>Unmount the partition containing the backup:</para>
     102<screen role="nodump"><userinput>umount /mnt</userinput></screen>
    133104    <note>
    146117      In case some mistakes have been made and you need to start over, you can
    147118      use this backup to restore the system and save some recovery time.
    148       Since the sources are located under
    149       <filename class="directory">$LFS</filename>, they are included in the
    150       backup archive as well, so they do not need to be downloaded again. After
    151       checking that <envar>$LFS</envar> is set properly,
    152       restore the backup by executing the following commands:
     119      Since the sources are included in the
     120      backup archive as well, so they do not need to be downloaded again.
    153121    </para>
     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>
     134    <para>Mount the LFS partition and the backup partition on
     135    <emphasis role="bold">the host system</emphasis>:</para>
    155137<!-- Make the following look different so users don't blindly run the
    156138     restore when they don't need to. -->
     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>
    158145    <warning><para>The following commands are extremely dangerous.  If
    159146    you run <command>rm -rf ./*</command> as the root user and you
    160     do not change to the $LFS directory or the <envar>LFS</envar>
    161     environment variable is not set for the root user, it will destroy
    162     your entire host system.  YOU ARE WARNED.</para></warning>
     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>
    164 <screen role="nodump"><computeroutput>cd $LFS
     151<screen role="nodump"><computeroutput>cd /mnt/lfs-target
    165152rm -rf ./*
    166 tar -xpf $HOME/lfs-temp-tools-&version;.tar.xz</computeroutput></screen>
     153tar -xpf /mnt/lfs-backup/lfs-temp-tools-&version;.tar.xz</computeroutput></screen>
    168155    <para>
    169        Again, double check that the environment has been setup properly
    170        and continue building the rest of the system.
     156       Again, unmount the two partitions, reconnect the device to the target
     157       machine, boot it and continue building the rest of system:
    171158    </para>
     160<screen role="nodump"><computeroutput>umount /mnt/lfs-{target,backup}</computeroutput></screen>
    173162    <important>
    174163      <para>
    175          If you left the chroot environment to create a backup or restart
    176          building using a restore, remember to check that the virtual
    177          filesystems are still mounted (<command>findmnt | grep
    178          $LFS</command>).  If they are not mounted, remount them now as
    179          described in <xref linkend='ch-tools-kernfs'/> and re-enter the chroot
     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
    180167         environment (see <xref linkend='ch-tools-chroot'/>) before continuing.
    181168       </para>
Note: See TracChangeset for help on using the changeset viewer.