1、通过虚拟机增加一个20G的硬盘 /dev/sdb
2、创建分区 fdisk /dev/sdb
swap /dev/sdb1 1024M
ext3 /dev/sdb2 10240M
ext3 /dev/sdb3 9216M
3、创建文件系统
mkswap /dev/sdb1
mkfs–t ext3 –c /dev/sdb2
mkfs–t ext3 –c /dev/sdb3
4、挂载文件系统
cd /mnt
mkdir sdb2
mkdir sdb3
mount /dev/sdb2sdb2
mount /dev/sdb3sdb3
5、查看系统磁盘情况
df –h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 19G 4.3G 14G 24% /
udev 494M 4.0K 494M 1% /dev
tmpfs 201M 776K 200M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 501M 180K 501M 1% /run/shm
.host:/ 40G 31G 9.4G 77% /mnt/hgfs
/dev/sdb2 9.9G 151M 9.2G 2% /mnt/sdb2
/dev/sdb3 8.9G 149M 8.3G 2% /mnt/sdb3
6、建立源代码目录
exportLFS=/mnt/sdb2
mkdir –v$LFS/sources
chmod –v a+wt$LFS/sources
7、下载文件
http://ftp.gnu.org/gnu/autoconf/autoconf-2.64.tar.bz2
http://ftp.gnu.org/gnu/automake/automake-1.11.tar.bz2
http://ftp.gnu.org/gnu/bash/bash-4.0.tar.gz
http://ftp.gnu.org/gnu/binutils/binutils-2.19.1.tar.bz2
http://ftp.gnu.org/gnu/bison/bison-2.4.1.tar.bz2
http://www.bzip.org/1.0.5/bzip2-1.0.5.tar.gz
http://ftp.gnu.org/gnu/coreutils/coreutils-7.4.tar.gz
http://ftp.gnu.org/gnu/dejagnu/dejagnu-1.4.4.tar.gz
http://ftp.gnu.org/gnu/diffutils/diffutils-2.8.1.tar.gz
http://prdownloads.sourceforge.net/e2fsprogs/e2fsprogs-1.41.8.tar.gz
http://expect.nist.gov/src/expect-5.43.0.tar.gz
ftp://ftp.astron.com/pub/file/file-5.03.tar.gz
http://ftp.gnu.org/gnu/findutils/findutils-4.4.2.tar.gz
http://prdownloads.sourceforge.net/flex/flex-2.5.35.tar.bz2
http://ftp.gnu.org/gnu/gawk/gawk-3.1.7.tar.bz2
http://ftp.gnu.org/gnu/gcc/gcc-4.4.1/gcc-4.4.1.tar.bz2
http://ftp.gnu.org/gnu/gdbm/gdbm-1.8.3.tar.gz
http://ftp.gnu.org/gnu/gettext/gettext-0.17.tar.gz
http://ftp.gnu.org/gnu/glibc/glibc-2.10.1.tar.bz2
http://ftp.gnu.org/gnu/glibc/glibc-libidn-2.10.1.tar.bz2
http://ftp.gnu.org/gnu/gmp/gmp-4.3.1.tar.bz2
http://ftp.gnu.org/gnu/grep/grep-2.5.4.tar.bz2
http://ftp.gnu.org/gnu/groff/groff-1.20.1.tar.gz
ftp://alpha.gnu.org/gnu/grub/grub-0.97.tar.gz
http://ftp.gnu.org/gnu/gzip/gzip-1.3.12.tar.gz
http://sethwklein.net/iana-etc-2.30.tar.bz2
http://ftp.gnu.org/gnu/inetutils/inetutils-1.6.tar.gz
http://developer.osdl.org/dev/iproute2/download/iproute2-2.6.29-1.tar.bz2
http://ftp.altlinux.com/pub/people/legion/kbd/kbd-1.15.tar.gz
http://www.greenwoodsoftware.com/less/less-429.tar.gz
http://www.linuxfromscratch.org/lfs/downloads/6.5/lfs-bootscripts-20090812.tar.bz2
http://ftp.gnu.org/gnu/libtool/libtool-2.2.6a.tar.gz
http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.30.2.tar.bz2
http://ftp.gnu.org/gnu/m4/m4-1.4.13.tar.bz2
http://ftp.gnu.org/gnu/make/make-3.81.tar.bz2
http://download.savannah.gnu.org/releases/man-db/man-db-2.5.5.tar.gz
http://www.kernel.org/pub/linux/docs/manpages/Archive/man-pages-3.22.tar.bz2
http://www.kernel.org/pub/linux/utils/kernel/module-init-tools/module-init-tools-3.10.tar.bz2
http://www.mpfr.org/mpfr-2.4.1/mpfr-2.4.1.tar.bz2
ftp://ftp.gnu.org/gnu/ncurses/ncurses-5.7.tar.gz
ftp://alpha.gnu.org/gnu/diffutils/patch-2.5.9.tar.gz
http://cpan.org/src/perl-5.10.0.tar.gz
http://pkgconfig.freedesktop.org/releases/pkg-config-0.23.tar.gz
http://procps.sourceforge.net/procps-3.2.8.tar.gz
http://prdownloads.sourceforge.net/psmisc/psmisc-22.8.tar.gz
http://ftp.gnu.org/gnu/readline/readline-6.0.tar.gz
http://ftp.gnu.org/gnu/sed/sed-4.2.1.tar.bz2
ftp://pkg-shadow.alioth.debian.org/pub/pkg-shadow/shadow-4.1.4.2.tar.bz2
http://www.infodrom.org/projects/sysklogd/download/sysklogd-1.5.tar.gz
ftp://ftp.cistron.nl/pub/people/miquels/sysvinit/sysvinit-2.86.tar.gz
http://ftp.gnu.org/gnu/tar/tar-1.22.tar.bz2
http://prdownloads.sourceforge.net/tcl/tcl8.5.7-src.tar.gz
http://ftp.gnu.org/gnu/texinfo/texinfo-4.13a.tar.gz
http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev-145.tar.bz2
http://www.linuxfromscratch.org/lfs/downloads/6.5/udev-config-20090523.tar.bz2
http://www.kernel.org/pub/linux/utils/util-linux-ng/v2.16/util-linux-ng-2.16.tar.bz2
ftp://ftp.vim.org/pub/vim/unix/vim-7.2.tar.bz2
ftp://ftp.vim.org/pub/vim/extra/vim-7.2-lang.tar.gz
http://www.zlib.net/zlib-1.2.3.tar.bz2
补丁包如下:
http://www.linuxfromscratch.org/patches/lfs/6.5/bash-4.0-fixes-3.patch
http://www.linuxfromscratch.org/patches/lfs/6.5/bzip2-1.0.5-install_docs-1.patch
http://www.linuxfromscratch.org/patches/lfs/6.5/coreutils-7.4-i18n-1.patch
http://www.linuxfromscratch.org/patches/lfs/6.5/coreutils-7.4-uname-1.patch
http://www.linuxfromscratch.org/patches/lfs/6.5/diffutils-2.8.1-i18n-1.patch
http://www.linuxfromscratch.org/patches/lfs/6.5/expect-5.43.0-spawn-1.patch
http://www.linuxfromscratch.org/patches/lfs/6.5/expect-5.43.0-tcl_8.5.5_fix-1.patch
http://www.linuxfromscratch.org/patches/lfs/6.5/flex-2.5.35-gcc44-1.patch
http://www.linuxfromscratch.org/patches/lfs/6.5/gcc-4.4.1-startfiles_fix-1.patch
http://www.linuxfromscratch.org/patches/lfs/6.5/gettext-0.17-upstream_fixes-2.patch
http://www.linuxfromscratch.org/patches/lfs/6.5/grep-2.5.4-debian_fixes-1.patch
http://www.linuxfromscratch.org/patches/lfs/6.5/grub-0.97-disk_geometry-1.patch
http://www.linuxfromscratch.org/patches/lfs/6.5/grub-0.97-256byte_inode-1.patch
http://www.linuxfromscratch.org/patches/lfs/6.5/inetutils-1.6-no_server_man_pages-1.patch
http://www.linuxfromscratch.org/patches/lfs/6.5/kbd-1.15-backspace-1.patch
http://www.linuxfromscratch.org/patches/lfs/6.5/man-db-2.5.5-fix_testsuite-1.patch
http://www.linuxfromscratch.org/patches/lfs/6.5/patch-2.5.9-fixes-1.patch
http://www.linuxfromscratch.org/patches/lfs/6.5/perl-5.10.0-consolidated-1.patch
http://www.linuxfromscratch.org/patches/lfs/6.5/procps-3.2.8-watch_unicode-1.patch
http://www.linuxfromscratch.org/patches/lfs/6.5/readline-6.0-fixes-1.patch
http://www.linuxfromscratch.org/patches/lfs/6.5/vim-7.2-fixes-5.patch
建立soft.txt包含所有软件,patch.txt包含所有补丁,然后下载
wget –i soft.txt
wget –ipatch.txt
8、环境准备
mkdir $LFS/tools
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 使用lfs登录
建立环境
cat >~/.bash_profile << "EOF"
exec env -iHOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
EOF
cat >~/.bashrc << "EOF"
set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
LFS_TGT=$(uname-m)-lfs-linux-gnu
PATH=$LFS/tools/bin:/bin:/usr/bin
export LFSLC_ALL LFS_TGT PATH
EOF
source~/.bash_profile