diff --git a/chapter06/grub-cfg.xml b/chapter06/grub-cfg.xml index dd6207319..9272f8353 100644 --- a/chapter06/grub-cfg.xml +++ b/chapter06/grub-cfg.xml @@ -164,6 +164,14 @@ Command (m for help): w Calling ioctl() to re-read partition table. Syncing disks. + In it's optional to make a + backup for the temporary system. If you'd like to do so, prepare + another parition (1 GB should be enough) and make an + ext4 filesystem to hold + the backup: + +mkfs.ext4 /dev/sdx4 + sdx should be replaced with the name of the device node corresponding to your moveable device. Then mount the filesystems: diff --git a/chapter07/cleanup.xml b/chapter07/cleanup.xml index e5bdd1c04..a1d3d6f15 100644 --- a/chapter07/cleanup.xml +++ b/chapter07/cleanup.xml @@ -20,8 +20,8 @@ Second, the libtool .la files are only useful when linking with static libraries. They are unneeded and potentially harmful when using dynamic - shared libraries, especially when using non-autotools build systems. - While still in chroot, remove those files now: + shared libraries, specially when using non-autotools build systems. + While still on the target machine, remove those files now: find /usr/{lib,libexec} -name \*.la -delete @@ -57,51 +57,15 @@ - The following steps are performed from outside the chroot - environment. That means, you have to leave the chroot environment - first before continuing. The reason for that is to - get access to file system locations outside of the chroot - environment to store/read the backup archive which should - not be placed within the - $LFS hierarchy for - safety reasons. + If you are making a backup, mount the partition for backup: - - If you have decided to make a backup, leave the chroot environment: - - -exit - - - - All of the following instructions are executed by - root on your host system. - Take extra care about the commands you're going to run as mistakes - here can modify your host system. Be aware that the - environment variable LFS - is set for user lfs by default - but may not be set for - root. - - - Whenever commands are to be executed by root, - make sure you have set LFS. - - - This has been discussed in . - - - - Before making a backup, unmount the virtual file systems: - -umount $LFS/dev/pts -umount $LFS/{sys,proc,run,dev} +mount -v /dev/sda4 /mnt Make sure you have at least 1 GB free disk space (the source tarballs - will be included in the backup archive) on the filesystem containing - directory where you create the backup archive. + will be included in the backup archive) in the partition prepared for + backup. @@ -127,8 +91,15 @@ umount $LFS/{sys,proc,run,dev} -cd $LFS -tar -cJpf $HOME/lfs-temp-tools-&version;.tar.xz . +cd / +tar -cJpf /mnt/lfs-temp-tools-&version;.tar.xz . \ + --exclude="dev/*" --exclude="proc/*" + --exclude="sys/*" --exclude="run/*" + --exclude="mnt/*" + + Unmount the partition containing the backup: + +umount /mnt @@ -145,38 +116,54 @@ tar -cJpf $HOME/lfs-temp-tools-&version;.tar.xz . In case some mistakes have been made and you need to start over, you can use this backup to restore the system and save some recovery time. - Since the sources are located under - $LFS, they are included in the - backup archive as well, so they do not need to be downloaded again. After - checking that $LFS is set properly, - restore the backup by executing the following commands: + Since the sources are included in the + backup archive as well, so they do not need to be downloaded again. + + Power off the target system and reconnect the disk containing LFS + temporary system to the host for restoring the backup. It's necessary + to avoid overwriting some binaries being used. Because the package + providing shutdown command is not built yet, the + system can't be shut down cleanly. Issue sync to + ensure all filesystem writes cached in memory to be really written + into the disk, then power off the system physically (for example, + unplug the AC cord). + + + Mount the LFS partition and the backup partition on + the host system: + +mkdir -pv /mnt/lfs-{target,backup} +mount -v -t ext4 /dev/sdx3 /mnt/lfs-target +mount -v -t ext4 /dev/sdx4 /mnt/lfs-backup + + The following commands are extremely dangerous. If you run rm -rf ./* as the root user and you - do not change to the $LFS directory or the LFS - environment variable is not set for the root user, it will destroy - your entire host system. YOU ARE WARNED. + do not change to the lfs-target directory, + it will destroy your entire host system. + YOU ARE WARNED. -cd $LFS +cd /mnt/lfs-target rm -rf ./* -tar -xpf $HOME/lfs-temp-tools-&version;.tar.xz +tar -xpf /mnt/lfs-backup/lfs-temp-tools-&version;.tar.xz - Again, double check that the environment has been setup properly - and continue building the rest of the system. + Again, unmount the two partitions, reconnect the device to the target + machine, boot it and continue building the rest of system: +umount /mnt/lfs-{target,backup} + - If you left the chroot environment to create a backup or restart - building using a restore, remember to check that the virtual - filesystems are still mounted (findmnt | grep - $LFS). If they are not mounted, remount them now as - described in and re-enter the chroot + If you reboot your target machine and restart + building using a restore, remount the virtual filesystems now as + described in and re-enter the build environment (see ) before continuing.