[原创]制作LFS过程中各个阶段恢复工作状态的方法
时间:2006-02-16
来源:互联网
2006年8月22日:修改错字一处
前提:
对于做过一两次LFS的朋友,想必对LFS的漫长制作时间印象深刻,特别是对机器不太好的朋友,有时候LFS的制作时间真是“可怕”,有时候不得以必须关机然后重新启动并恢复到工作状态,但对一些不太清楚LFS的工作原理的朋友,可能一时无法正确的恢复到工作状态,因此为了能成功的完成LFS,有的会开个一两天的机器不关,本人特别针对这个问题写了一些自己的经验,以下的过程全部经过测试,应该是正确的,希望能给还在LFS制作中的朋友减轻一些“痛苦”。
为了说明方便,例子采用VMWare5.0的环境下开始的,但也同样适合使用真实机器的情况,只是用真实的机器需要在相应的磁盘设备名上修改成实际的设备名。(用VMWare只是为了说明方便,VMware本身就具有暂停的功能,所以不必计较这个问题)
文章使用VMWare5.0虚拟的SCSI设备,并使用sda设备名,sda1用于swap,而sda2用于目标系统的根目录。
以下是按照LFS6.1.1-3里面的章节数写的,如果你使用的LFS-Book与下面的章节数有出入,以章节数后面的标题为准。
开始~4.4. Setting Up the Environment
从头开始好了,没什么好可惜的。
4.5. About SBUs~5.33. Stripping
从现在开始一直到第五章结束,也就是完成Stripping中间的步骤中如果重新启动的恢复步骤:
1.重新启动计算机,并从LiveCD启动
2.加载分区
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3.加载交换分区(如果不想用交换分区或者没有交换分区可跳过此步骤)
swapon /dev/sda1
4.建立工具链的链接
ln -sv $LFS/tools /
5.创建lfs用户
groupadd lfs
useradd -s /bin/bash -g lfs -m -k /dev/null lfs
passwd lfs
chown -v lfs $LFS/tools
chown -v lfs $LFS/sources
su - lfs
6.建立lfs用户的环境
cat > ~/.bash_profile << "EOF"
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
EOF
cat > ~/.bashrc << "EOF"
set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
PATH=/tools/bin:/bin:/usr/bin
export LFS LC_ALL PATH
EOF
source ~/.bash_profile
7.检查一下
export命令查看输出,应该是
declare -x HOME="/home/lfs"
declare -x LC_ALL="POSIX"
declare -x LFS="/mnt/lfs"
declare -x OLDPWD
declare -x PATH="/tools/bin:/bin:/usr/bin"
declare -x PS1="\\u:\\w\\\$ "
declare -x PWD="/home/lfs"
declare -x SHLVL="1"
declare -x TERM="linux"
基本上就恢复工作状态了。
6.1. Introduction
这个时候也许你想睡觉关机了,那么重新开机后回到工作状态的步骤是:
1.重新启动计算机,并从LiveCD启动
2.加载分区
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3.加载交换分区(如果不想用交换分区或者没有交换分区可跳过此步骤)
swapon /dev/sda1
相关知识点:
这时候已经制作好了工具链,因此可以不需要建立根目录下的tools链接了。
6.2. Mounting Virtual Kernel File Systems~6.8. Populating /dev
这个时候如果你关机或重新启动,那么重新开机后回到工作状态的步骤是:
1.重新启动计算机,并从LiveCD启动
2.加载分区
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3.加载交换分区(如果不想用交换分区或者没有交换分区可跳过此步骤)
swapon /dev/sda1
4.加载必要的文件系统
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
5.Chroot到目标系统下
chroot "$LFS" /tools/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
/tools/bin/bash --login +h
6.9. Linux-Libc-Headers-2.6.11.2~6.37. Bash-3.0
从现在开始一直到第六章的File-4.13之前,也就是Bash-3.0结束后,这个阶段如果你关机或重新启动,那么重新开机后回到工作状态的步骤是:
1.重新启动计算机,并从LiveCD启动
2.加载分区
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3.加载交换分区(如果不想用交换分区或者没有交换分区可跳过此步骤)
swapon /dev/sda1
4.加载必要的文件系统
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
5.Chroot到目标系统下
chroot "$LFS" /tools/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
/tools/bin/bash --login +h
6.创建/dev下的设备文件
mount -nvt tmpfs none /dev
mknod -m 622 /dev/console c 5 1
mknod -m 666 /dev/null c 1 3
mknod -m 666 /dev/zero c 1 5
mknod -m 666 /dev/ptmx c 5 2
mknod -m 666 /dev/tty c 5 0
mknod -m 444 /dev/random c 1 8
mknod -m 444 /dev/urandom c 1 9
chown -v root:tty /dev/{console,ptmx,tty}
ln -sv /proc/self/fd /dev/fd
ln -sv /proc/self/fd/0 /dev/stdin
ln -sv /proc/self/fd/1 /dev/stdout
ln -sv /proc/self/fd/2 /dev/stderr
ln -sv /proc/kcore /dev/core
mkdir -v /dev/pts
mkdir -v /dev/shm
mount -vt devpts -o gid=4,mode=620 none /dev/pts
mount -vt tmpfs none /dev/shm
6.进入编译目录
cd /sources
6.38. File-4.13~6.58. Udev-056
从现在开始一直到第六章的Udev-056完成之前,这个阶段如果你关机或重新启动,那么重新开机后回到工作状态的步骤是:
1.重新启动计算机,并从LiveCD启动
2.加载分区
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3.加载交换分区(如果不想用交换分区或者没有交换分区可跳过此步骤)
swapon /dev/sda1
4.加载必要的文件系统
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
5.Chroot到目标系统下
chroot "$LFS" /tools/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
/bin/bash --login +h
6.创建/dev下的设备文件
mount -nvt tmpfs none /dev
mknod -m 622 /dev/console c 5 1
mknod -m 666 /dev/null c 1 3
mknod -m 666 /dev/zero c 1 5
mknod -m 666 /dev/ptmx c 5 2
mknod -m 666 /dev/tty c 5 0
mknod -m 444 /dev/random c 1 8
mknod -m 444 /dev/urandom c 1 9
chown -v root:tty /dev/{console,ptmx,tty}
ln -sv /proc/self/fd /dev/fd
ln -sv /proc/self/fd/0 /dev/stdin
ln -sv /proc/self/fd/1 /dev/stdout
ln -sv /proc/self/fd/2 /dev/stderr
ln -sv /proc/kcore /dev/core
mkdir -v /dev/pts
mkdir -v /dev/shm
mount -vt devpts -o gid=4,mode=620 none /dev/pts
mount -vt tmpfs none /dev/shm
6.进入编译目录
cd /sources
6.59. Util-linux-2.12q~6.60. About Debugging Symbols
从现在开始一直到第六章的Stripping Again之前,这个阶段如果你关机或重新启动,那么重新开机后回到工作状态的步骤是:
1.重新启动计算机,并从LiveCD启动
2.加载分区
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3.加载交换分区(如果不想用交换分区或者没有交换分区可跳过此步骤)
swapon /dev/sda1
4.加载必要的文件系统
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
5.Chroot到目标系统下
chroot "$LFS" /tools/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
/bin/bash --login +h
6.创建/dev下的设备文件
mount -nvt tmpfs none /dev
/sbin/udevstart
mkdir -v /dev/pts
mkdir -v /dev/shm
mount -vt devpts -o gid=4,mode=620 none /dev/pts
mount -vt tmpfs none /dev/shm
6.进入编译目录
cd /sources
6.61. Stripping Again
如果现在重新启动,那么重新开机后回到工作状态的步骤是:
1.重新启动计算机,并从LiveCD启动
2.加载分区
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3.加载交换分区(如果不想用交换分区或者没有交换分区可跳过此步骤)
swapon /dev/sda1
4.加载必要的文件系统
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
5.Chroot到目标系统下
chroot $LFS /tools/bin/env -i \
HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin \
/tools/bin/bash --login
6.创建/dev下的设备文件
mount -nvt tmpfs none /dev
/sbin/udevstart
mkdir -v /dev/pts
mkdir -v /dev/shm
mount -vt devpts -o gid=4,mode=620 none /dev/pts
mount -vt tmpfs none /dev/shm
6.进入编译目录
cd /sources
6.62. Cleaning Up~结束
从现在开始一直到制作结束,重新开机后回到工作状态的步骤是:
1.重新启动计算机,并从LiveCD启动
2.加载分区
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3.加载交换分区(如果不想用交换分区或者没有交换分区可跳过此步骤)
swapon /dev/sda1
4.加载必要的文件系统
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
5.Chroot到目标系统下
chroot "$LFS" /usr/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin \
/bin/bash --login
6.创建/dev下的设备文件
mount -nvt tmpfs none /dev
/sbin/udevstart
mkdir -v /dev/pts
mkdir -v /dev/shm
mount -vt devpts -o gid=4,mode=620 none /dev/pts
mount -vt tmpfs none /dev/shm
6.进入编译目录
cd /sources
(转载请保持文章的完整性,请注明作者和出处)
作者:冲天飞豹(youbest)
Email:[email protected]
2006年2月16日
更新日志:
2006年8月22日:
印象深刻误写为影象深刻,已改正
由Linuxsir上的青铜镜发现并报告
作者: youbest 发布时间: 2006-02-16
希望以后多多看到兄弟的精彩文章。
作者: 晨想 发布时间: 2006-02-18
这篇是从我另外一篇文章上节选的几个部分,因能独立成篇,所以就专门拿出来变成了一篇完整的。
其内容是经过测试的,如果有发现什么问题的,还望及时指出,及时改正。
中间有几个靠的比较近的几个章节,建议一次通过比较好。
作者: youbest 发布时间: 2006-02-18
大家使用的时候,就是最好的测试了:)。
作者: 晨想 发布时间: 2006-02-18
这个帖子想必是解决了许多弟兄的头痛之事,下一版LFS手册要把这些内容加进去,如何?
作者: csfrank 发布时间: 2006-02-18
作者: 晨想 发布时间: 2006-02-18
作者: 终极幻想
下一版?。。你是说 6.X 中文版?
|
作者: csfrank 发布时间: 2006-02-18
正式版,马虎不得,看你的了,我们等着你的好消息!
期待中……
作者: youbest 发布时间: 2006-02-18
作者: d00m3d 发布时间: 2006-02-24
作者: d00m3d
youbest 不如把此精文写成 hints,相信被接立的机会必定很高。
|
作者: youbest 发布时间: 2006-02-24
从开始到第6章,
只要能够保证:PATH="/tools/bin:xxxx就可以了
其他的条件基本都没什么用:)
作者: good02xaut 发布时间: 2006-02-25

作者: soloforce 发布时间: 2006-02-25
作者: good02xaut
补充一下:
从开始到第6章, 只要能够保证:PATH="/tools/bin:xxxx就可以了 其他的条件基本都没什么用:) |
作者: youbest 发布时间: 2006-02-25
而且每次开机后,就设置这一个参数。也没建立lfs用户,就是默认的,应该是root,或者0吧
发现问题还没有,会有什么问题啊?
我进行中多次用:
gcc -v 查看当前用的gcc
ldd /tools/bin/xx 查看刚刚编译出来的程序使用的lib是否正确
发现没有受开关机的影响,只要PATH,ok。
作者: good02xaut 发布时间: 2006-02-25
作者: 晨想 发布时间: 2006-02-25
我保证!
作者: good02xaut 发布时间: 2006-02-25
作者: youbest
我不太清楚写成hints的要求或者有什么条件,而且我英文非常的菜,如果有人愿意帮忙我不胜感激.谢谢.
|
作者: d00m3d 发布时间: 2006-02-26
我来翻译,尽快给出结果。上次的那个,是我提交的。借花献佛。活活。
作者: 晨想 发布时间: 2006-02-26
~~~~~~~~~~
(VMWare的部份散略了)
AUTHOR: youbest <youbest at sina.com>
DATE: 2006-02-16
LICENSE: ????
SYNOPSIS: The continuity and recovery of building environment in various LFS stages
DESCRIPTION: This hint will assist you to resume your building environment while you
are building your LFS system in various stages using LFS LiveCD as host system
PRIMARY URI: http://www.linuxsir.org/bbs/showthread.php?t=242880
PREREQUISITES: LFS LiveCD-6.1.1-3
HINT:
Foreword
========
For those who have built their own LFS system more than once, they must be very "impressed" with the extremely long building time. In particular, if the computer configuration is not powerful, it is quite scary to learn about such lengthy building time.
Sometimes, you may be forced to shutdown or reboot the computer, which you may have to resume the previous working conditions before continuing the job. However, it is often panic to those who are not very familiar with the principles of LFS and find difficulties in resuming their previous building environment. To avoid this from happening, they are often keep the computer running for several days until the whole LFS task is finished.
I have studied this problem and intended to share my works on how to keep the continuity of the building process based on my own experiences. Every steps are verified carefully and should be correct. Hope that this hint may assist those who are building their own LFS system and relief some of their "pains".
Throughout the article, sda is block device being used. sda1 is being used as swap and sda2 is the partition for building LFS.
The following procedures are based on sections in LFS6.1.1-3, if you use a different version of LFS-Book, the section number may be also different, please refer to the sub-heading of each section in such case.
From beginning to Section 4.4 Setting up the Environment
========================================================
There is nothing valuable, you may simply restart the process from the very beginning.
From section 4.5 About SBUs to section 5.33 Stripping
=====================================================
Below are the steps to resume the building environment during any steps from section 4.5 till the end of Chapter 5:
1. Restart computer and boot from LiveCD
2. Mount your lfs partition
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3. Mount your swap partition (skip this step if you do not use any swap partitions)
swapon /dev/sda1
4. Establish symbolic link for toolchain
ln -sv $LFS/tools /
5. Create lfs account
groupadd lfs
useradd -s /bin/bash -g lfs -m -k /dev/null lfs
passwd lfs
chown -v lfs $LFS/tools
chown -v lfs $LFS/sources
su - lfs
6. Define the lfs user profile
cat > ~/.bash_profile << "EOF"
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
EOF
cat > ~/.bashrc << "EOF"
set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
PATH=/tools/bin:/bin:/usr/bin
export LFS LC_ALL PATH
EOF
source ~/.bash_profile
7. Verify the environment variables
export //the export command should output the following:
declare -x HOME="/home/lfs"
declare -x LC_ALL="POSIX"
declare -x LFS="/mnt/lfs"
declare -x OLDPWD
declare -x PATH="/tools/bin:/bin:/usr/bin"
declare -x PS1="\\u:\\w\\\$ "
declare -x PWD="/home/lfs"
declare -x SHLVL="1"
declare -x TERM="linux"
If you get these variables correct, then you have already resumed your building environment.
Section 6.1 Introduction
========================
At this point, you are probably tired and prefer to shutdown your computer for a rest. Steps to resume the building environment are:
1. Restart computer and boot from LiveCD
2. Mount your lfs partition
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3. Mount your swap partition (skip this step if you do not use any swap partitions)
swapon /dev/sda1
Remark:
At this point, the toolchain is already built up in the previous chapters, it is not
necessary to create the symbolic link for the /tools directory again.
From section 6.2. Mounting Virtual Kernel File Systems to section 6.8. Populating /dev
======================================================================================
At this point, if you reboot or shutdown your computer. Steps to resume the building environment are:
1. Restart computer and boot from LiveCD
2. Mount your lfs partition
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3. Mount your swap partition (skip this step if you do not use any swap partitions)
swapon /dev/sda1
4. Mount the virtual kernel filesystems
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
5. Entering the chroot environment
chroot "$LFS" /tools/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
/tools/bin/bash --login +h
From section 6.9. Linux-Libc-Headers-2.6.11.2 to section 6.37. Bash-3.0
=======================================================================
From this point to the end of Bash-3.0 (before File-4.13) in Chapter 6, at any moment if you reboot or shutdown your computer. Steps to resume the building environment are:
1. Restart computer and boot from LiveCD
2. Mount your lfs partition
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3. Mount your swap partition (skip this step if you do not use any swap partitions)
swapon /dev/sda1
4. Mount the virtual kernel filesystems
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
5. Entering the chroot environment
chroot "$LFS" /tools/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
/tools/bin/bash --login +h
6. Populating /dev
mount -nvt tmpfs none /dev
mknod -m 622 /dev/console c 5 1
mknod -m 666 /dev/null c 1 3
mknod -m 666 /dev/zero c 1 5
mknod -m 666 /dev/ptmx c 5 2
mknod -m 666 /dev/tty c 5 0
mknod -m 444 /dev/random c 1 8
mknod -m 444 /dev/urandom c 1 9
chown -v root:tty /dev/{console,ptmx,tty}
ln -sv /proc/self/fd /dev/fd
ln -sv /proc/self/fd/0 /dev/stdin
ln -sv /proc/self/fd/1 /dev/stdout
ln -sv /proc/self/fd/2 /dev/stderr
ln -sv /proc/kcore /dev/core
mkdir -v /dev/pts
mkdir -v /dev/shm
mount -vt devpts -o gid=4,mode=620 none /dev/pts
mount -vt tmpfs none /dev/shm
7. Entering your working directory
cd /sources
From 6.38. File-4.13 to section 6.58. Udev-056
==============================================
From this point to Udev-056 in Chapter 6, at any moment if you reboot or shutdown your computer. Steps to resume the building environment are:
1. Restart computer and boot from LiveCD
2. Mount your lfs partition
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3. Mount your swap partition (skip this step if you do not use any swap partitions)
swapon /dev/sda1
4. Mount the virtual kernel filesystems
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
5. Entering the chroot environment
chroot "$LFS" /tools/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
/bin/bash --login +h
6. Populating /dev
mount -nvt tmpfs none /dev
mknod -m 622 /dev/console c 5 1
mknod -m 666 /dev/null c 1 3
mknod -m 666 /dev/zero c 1 5
mknod -m 666 /dev/ptmx c 5 2
mknod -m 666 /dev/tty c 5 0
mknod -m 444 /dev/random c 1 8
mknod -m 444 /dev/urandom c 1 9
chown -v root:tty /dev/{console,ptmx,tty}
ln -sv /proc/self/fd /dev/fd
ln -sv /proc/self/fd/0 /dev/stdin
ln -sv /proc/self/fd/1 /dev/stdout
ln -sv /proc/self/fd/2 /dev/stderr
ln -sv /proc/kcore /dev/core
mkdir -v /dev/pts
mkdir -v /dev/shm
mount -vt devpts -o gid=4,mode=620 none /dev/pts
mount -vt tmpfs none /dev/shm
7. Entering your working directory
cd /sources
From section 6.59. Util-linux-2.12q to section 6.60. About Debugging Symbols
============================================================================
From this point to Stripping Again in Chapter 6, at any moment if you reboot or
shutdown your computer. Steps to resume the building environment are:
1. Restart computer and boot from LiveCD
2. Mount your lfs partition
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3. Mount your swap partition (skip this step if you do not use any swap partitions)
swapon /dev/sda1
4. Mount the virtual kernel filesystems
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
5. Entering the chroot environment
chroot "$LFS" /tools/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
/bin/bash --login +h
6. Populating /dev
mount -nvt tmpfs none /dev
/sbin/udevstart
mkdir -v /dev/pts
mkdir -v /dev/shm
mount -vt devpts -o gid=4,mode=620 none /dev/pts
mount -vt tmpfs none /dev/shm
7. Entering your working directory
cd /sources
Section 6.61. Stripping Again
=============================
If you reboot your computer at this moment, steps to resume the building
environment are:
1. Restart computer and boot from LiveCD
2. Mount your lfs partition
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3. Mount your swap partition (skip this step if you do not use any swap partitions)
swapon /dev/sda1
4. Mount the virtual kernel filesystems
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
5. Entering the chroot environment
chroot $LFS /tools/bin/env -i \
HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin \
/tools/bin/bash --login
6. Populating /dev
mount -nvt tmpfs none /dev
/sbin/udevstart
mkdir -v /dev/pts
mkdir -v /dev/shm
mount -vt devpts -o gid=4,mode=620 none /dev/pts
mount -vt tmpfs none /dev/shm
7. Entering your working directory
cd /sources
From section 6.62. Cleaning Up to The End
=========================================
From this point till the end of the whole LFS build. Steps to resume the building
environment are:
1. Restart computer and boot from LiveCD
2. Mount your lfs partition
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3. Mount your swap partition (skip this step if you do not use any swap partitions)
swapon /dev/sda1
4. Mount the virtual kernel filesystems
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
5. Entering the chroot environment
chroot "$LFS" /usr/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin \
/bin/bash --login
6. Populating /dev
mount -nvt tmpfs none /dev
/sbin/udevstart
mkdir -v /dev/pts
mkdir -v /dev/shm
mount -vt devpts -o gid=4,mode=620 none /dev/pts
mount -vt tmpfs none /dev/shm
7. Entering your working directory
cd /sources
作者: d00m3d 发布时间: 2006-03-04
AUTHOR: youbest <youbest at sina dot com>
TRANSLATOR: d00m3d <doom3d at sina dot com>
DATE: 2006-02-16
LICENSE: GPL
SYNOPSIS: How to resume from a break during different LFS stages.
DESCRIPTION: This hint helps you setting up your building environment at different stages. LFS LiveCD is used as the host system.
PRIMARY URI: http://www.linuxsir.org/bbs/showthread.php?t=242880
PREREQUISITES: LFS LiveCD-6.1.1-3
HINT:
Foreword
========
For those who have built their own LFS systems more than once, they must be very "impressed" with the extremely long building time. In particular, if the computer is not a powerful one. It is quite scary to learn about such lengthy building time.
Sometimes, you may be forced to shutdown or reboot the computer, which you have to resume your previous working conditions before continuing the job. However, this process would be quite confusing to those who are not familiar with the principles of LFS and they are likely to have difficulties in resuming their previous building environment. To avoid this from happening, they often keep the computer running for several days until the whole LFS is finished.
Thus it is very useful to know how to have a smooth connection after a reboot/shutdown. Based on my own experiences I did a research on this topic and would like to share my results. Every steps are carefully verified and should be correct. Hope this hint may assist those who are building their own LFS system and relief some of their "pains".
Throughout the article, sda is block device being used. sda1 is being used as swap and sda2 is the partition for building LFS.
The following procedures are based on LFS6.1.1-3. If a different book version is used, the section number may be different as well, please refer to the sub-heading of each section in such case.
From beginning to Section 4.4 Setting up the Environment
========================================================
You may simply restart the process from the very beginning.
From section 4.5 About SBUs to section 5.33 Stripping
=====================================================
Following are the steps for resuming the building environment from any stages starting from section 4.5 till the end of Chapter 5:
1. Restart computer and boot from LiveCD
2. Mount your lfs partition
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3. Mount your swap partition (skip this step if you do not use any swap partitions)
swapon /dev/sda1
4. Establish symbolic link for toolchain
ln -sv $LFS/tools /
5. Create lfs account
groupadd lfs
useradd -s /bin/bash -g lfs -m -k /dev/null lfs
passwd lfs
chown -v lfs $LFS/tools
chown -v lfs $LFS/sources
su - lfs
6. Define the lfs user profile
cat > ~/.bash_profile << "EOF"
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
EOF
cat > ~/.bashrc << "EOF"
set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
PATH=/tools/bin:/bin:/usr/bin
export LFS LC_ALL PATH
EOF
source ~/.bash_profile
7. Verify the environment variables
export //the export command should output the following:
declare -x HOME="/home/lfs"
declare -x LC_ALL="POSIX"
declare -x LFS="/mnt/lfs"
declare -x OLDPWD
declare -x PATH="/tools/bin:/bin:/usr/bin"
declare -x PS1="\\u:\\w\\\$ "
declare -x PWD="/home/lfs"
declare -x SHLVL="1"
declare -x TERM="linux"
If you get these variables correct, then you have already resumed your building environment.
Section 6.1 Introduction
========================
At this point, you are probably tired and prefer to shutdown your computer for a rest. Steps to resume the building environment are:
1. Restart computer and boot from LiveCD
2. Mount your lfs partition
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3. Mount your swap partition (skip this step if you do not use any swap partitions)
swapon /dev/sda1
Remark:
At this point, the toolchain is already built up in the previous chapters, it is not
necessary to create the symbolic link for the /tools directory again.
From section 6.2. Mounting Virtual Kernel File Systems to section 6.8. Populating /dev
======================================================================================
At this point, if you reboot or shutdown your computer. Steps to resume the building environment are:
1. Restart computer and boot from LiveCD
2. Mount your lfs partition
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3. Mount your swap partition (skip this step if you do not use any swap partitions)
swapon /dev/sda1
4. Mount the virtual kernel filesystems
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
5. Entering the chroot environment
chroot "$LFS" /tools/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
/tools/bin/bash --login +h
From section 6.9. Linux-Libc-Headers-2.6.11.2 to section 6.37. Bash-3.0
=======================================================================
From this point to the end of Bash-3.0 (before File-4.13) in Chapter 6, at any moment if you reboot or shutdown your computer. Steps to resume the building environment are:
1. Restart computer and boot from LiveCD
2. Mount your lfs partition
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3. Mount your swap partition (skip this step if you do not use any swap partitions)
swapon /dev/sda1
4. Mount the virtual kernel filesystems
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
5. Entering the chroot environment
chroot "$LFS" /tools/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
/tools/bin/bash --login +h
6. Populating /dev
mount -nvt tmpfs none /dev
mknod -m 622 /dev/console c 5 1
mknod -m 666 /dev/null c 1 3
mknod -m 666 /dev/zero c 1 5
mknod -m 666 /dev/ptmx c 5 2
mknod -m 666 /dev/tty c 5 0
mknod -m 444 /dev/random c 1 8
mknod -m 444 /dev/urandom c 1 9
chown -v root:tty /dev/{console,ptmx,tty}
ln -sv /proc/self/fd /dev/fd
ln -sv /proc/self/fd/0 /dev/stdin
ln -sv /proc/self/fd/1 /dev/stdout
ln -sv /proc/self/fd/2 /dev/stderr
ln -sv /proc/kcore /dev/core
mkdir -v /dev/pts
mkdir -v /dev/shm
mount -vt devpts -o gid=4,mode=620 none /dev/pts
mount -vt tmpfs none /dev/shm
7. Entering your working directory
cd /sources
From 6.38. File-4.13 to section 6.58. Udev-056
==============================================
From this point to Udev-056 in Chapter 6, at any moment if you reboot or shutdown your computer. Steps to resume the building environment are:
1. Restart computer and boot from LiveCD
2. Mount your lfs partition
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3. Mount your swap partition (skip this step if you do not use any swap partitions)
swapon /dev/sda1
4. Mount the virtual kernel filesystems
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
5. Entering the chroot environment
chroot "$LFS" /tools/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
/bin/bash --login +h
6. Populating /dev
mount -nvt tmpfs none /dev
mknod -m 622 /dev/console c 5 1
mknod -m 666 /dev/null c 1 3
mknod -m 666 /dev/zero c 1 5
mknod -m 666 /dev/ptmx c 5 2
mknod -m 666 /dev/tty c 5 0
mknod -m 444 /dev/random c 1 8
mknod -m 444 /dev/urandom c 1 9
chown -v root:tty /dev/{console,ptmx,tty}
ln -sv /proc/self/fd /dev/fd
ln -sv /proc/self/fd/0 /dev/stdin
ln -sv /proc/self/fd/1 /dev/stdout
ln -sv /proc/self/fd/2 /dev/stderr
ln -sv /proc/kcore /dev/core
mkdir -v /dev/pts
mkdir -v /dev/shm
mount -vt devpts -o gid=4,mode=620 none /dev/pts
mount -vt tmpfs none /dev/shm
7. Entering your working directory
cd /sources
From section 6.59. Util-linux-2.12q to section 6.60. About Debugging Symbols
============================================================================
From this point to Stripping Again in Chapter 6, at any moment if you reboot or
shutdown your computer. Steps to resume the building environment are:
1. Restart computer and boot from LiveCD
2. Mount your lfs partition
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3. Mount your swap partition (skip this step if you do not use any swap partitions)
swapon /dev/sda1
4. Mount the virtual kernel filesystems
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
5. Entering the chroot environment
chroot "$LFS" /tools/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
/bin/bash --login +h
6. Populating /dev
mount -nvt tmpfs none /dev
/sbin/udevstart
mkdir -v /dev/pts
mkdir -v /dev/shm
mount -vt devpts -o gid=4,mode=620 none /dev/pts
mount -vt tmpfs none /dev/shm
7. Entering your working directory
cd /sources
Section 6.61. Stripping Again
=============================
If you reboot your computer at this moment, steps to resume the building
environment are:
1. Restart computer and boot from LiveCD
2. Mount your lfs partition
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3. Mount your swap partition (skip this step if you do not use any swap partitions)
swapon /dev/sda1
4. Mount the virtual kernel filesystems
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
5. Entering the chroot environment
chroot $LFS /tools/bin/env -i \
HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin \
/tools/bin/bash --login
6. Populating /dev
mount -nvt tmpfs none /dev
/sbin/udevstart
mkdir -v /dev/pts
mkdir -v /dev/shm
mount -vt devpts -o gid=4,mode=620 none /dev/pts
mount -vt tmpfs none /dev/shm
7. Entering your working directory
cd /sources
From section 6.62. Cleaning Up to The End
=========================================
From this point till the end of the whole LFS build. Steps to resume the building
environment are:
1. Restart computer and boot from LiveCD
2. Mount your lfs partition
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3. Mount your swap partition (skip this step if you do not use any swap partitions)
swapon /dev/sda1
4. Mount the virtual kernel filesystems
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
5. Entering the chroot environment
chroot "$LFS" /usr/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin \
/bin/bash --login
6. Populating /dev
mount -nvt tmpfs none /dev
/sbin/udevstart
mkdir -v /dev/pts
mkdir -v /dev/shm
mount -vt devpts -o gid=4,mode=620 none /dev/pts
mount -vt tmpfs none /dev/shm
7. Entering your working directory
cd /sources
Changelog:
1.0. Initial Version
作者: 晨想 发布时间: 2006-03-04

如果在翻译的过程中觉得哪个步骤有问题一定要告诉我啊,好及时改正。
(我自己觉得应该是没问题的,我自己测试过的)
作者: youbest 发布时间: 2006-03-05
更正:我的電郵是 d00m3d 在 sina 的 com
另外,我看 linuxfromscratch.org 上的 hints 都是用 GNU Free Documentation License Version 1.2,我對此不熟識,所以沒有填上,幻想老大請 study 一下
作者: d00m3d 发布时间: 2006-03-05
那个 license 我已经改了,不过这边没更新。。谢谢提醒。
作者: 晨想 发布时间: 2006-03-05
作者: 晨想 发布时间: 2006-04-21
youbest,you made us proud!
中国人以你为傲!
作者: d00m3d 发布时间: 2006-04-21
作者: d00m3d
嘿嘿,大家的心血总算没有白费了,谢谢幻想老大把 Hint 提交,现在全世界的 LFS 爱好者都能阅读了
youbest,you made us proud! 中国人以你为傲! |
这是大家一起努力的结果!
大家还要继续努力啊。
作者: youbest 发布时间: 2006-04-21
我们要加油。^_^。
作者: 晨想 发布时间: 2006-04-22
这样我编译更有信心了。哈哈!!!
作者: sccdyuebo 发布时间: 2006-04-27
作者: 6hzzz 发布时间: 2006-05-06
原文中是有/tools这个路径的。
作者: xiaoma 发布时间: 2006-06-11
作者: 晨想 发布时间: 2006-06-11
另外也介绍了一个名为 hibernate (win 下的"休眠"?)功能,也是同样的目的,有空可试试
作者: d00m3d 发布时间: 2006-08-08
作者: d00m3d
刚下了新的 LFS-6.2-1 LiveCD,按习惯第一件事就是看看 README,发现 README 内有一个 Section 是 "RESUMING THE BUILD",这里首先是介绍了 youbest 这篇大作 http://www.linuxfromscratch.org/hint...and-resume.txt
|
有点成就感了噻~~~

作者: youbest 发布时间: 2006-08-08
可管用了!
作者: 青铜镜 发布时间: 2006-08-22
作者: Robot5 发布时间: 2006-09-06
作者: 晨想 发布时间: 2006-09-06
作者: d00m3d 发布时间: 2006-09-06
作者: 终极幻想
有变化,你也可以根据相应文档去搞定,光靠抄,是没意义的。还不如去用发行版好了。
|
我的方法如下(工作太忙,只做到第6章):
从6.1. Introduction到6.6. 创建必需的文件与符号连接(不知道对不对

export LFS=/mnt/lfs mkdir -pv $LFS mount /dev/hda1 $LFS swapon /dev/hda2 mount --bind /dev $LFS/dev mount -vt devpts devpts $LFS/dev/pts mount -vt tmpfs shm $LFS/dev/shm mount -vt proc proc $LFS/proc mount -vt sysfs sysfs $LFS/sys chroot "$LFS" /tools/bin/env -i \ HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \ PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \ /tools/bin/bash --login +h
作者: Robot5 发布时间: 2006-09-06
作者: Robot5
就知道会这么说!
我的方法如下(工作太忙,只做到第6章): . . . |
作者: 晨想 发布时间: 2006-09-06
作者: 终极幻想
难道我说错了么?
|
作者: Robot5 发布时间: 2006-09-06
我就是这样做的。
Take snapshot of Virtual Machine.
第二天,恢复就行了,肯定是好的,不论什么版本。
作者: kk526 发布时间: 2006-09-06
作者: kk526
呵呵,虚拟机用户其实有更简单的办法。
我就是这样做的。 Take snapshot of Virtual Machine. 第二天,恢复就行了,肯定是好的,不论什么版本。 |
作者: Robot5 发布时间: 2006-09-07
作者: lenshion 发布时间: 2006-09-07
作者: fjchenq 发布时间: 2007-01-11
作者: youbest 发布时间: 2007-01-12
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28