SlideShare a Scribd company logo
1 of 55
Download to read offline
Linux       LFS




2006     9   11              tar xvf
2006     9   11
2006     8   11
2006-03-27
2006-03-25
2006-03-24
2006-03-20           linux-Lib-Headers-2.6.11.2           linux-lib-headers-2.6.11.2
2006-03-17
2006-03-14



LFS                                                        LFS                                                         Linux


             LFS
                   VMWare Workstation 5.0


      WMWare                                        VMWare
                                                 VMWare


                                                                                     LFS




                                                                                           LFS



      www.linuxsir.org         LFS                   Blog
linuxsir     http://www.linuxsir.org/bbs/showthread.php?t=244052
      Blog     http://youbest.cublog.cn
                                       youbest



      LiveCD    ISO      (                                   6.1.1-3       )    http://ftp.osuosl.org/pub/lfs-livecd...86-6.1.1-3.iso
      ISO                                                                        VMWare                       ISO
 VMWare Workstation 5.0
      File->New->Virtual Machine...
      Custom                 Guest operating system              Linux     Version         Other Linux
                                                         128M            256M


            128M        GCC3.x                               GCC4.0.x                  swap                   256M
 swap
Network connection              Use network address translation(NAT)
SCSI Adpters                   Buslogic
      Create a new virtual disk
 Virtual Disk Type                                 IDE             SCSI
SCSI            B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«                                                   h t t p : / / b l o g . b y p a t . c o m




          IDE                                                                            SCSI                                                         SCSI Adpters
  Buslogic                                                           Buslogic
                                                          4G         LFS                         BLFS
                                                               Edit virtual machine settings    CD-ROM    Use ISO image                                              LiveCD   ISO


  Start this virtual machine
                                                                        LiveCD
                                                                                                  Asia/Shanghai
         LiveCD                                                   LFS


                          LiveCD
/usr/share/LFS-BOOK-6.1.1-HTML                                                    LFS
/lfs-sources                                                   LFS




    cfdisk




                                                                                                                                                         512M


/dev/sda1 swap
/dev/sda2
B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«                   h t t p : / / b l o g . b y p a t . c o m




   mkswap /dev/sda1
   mkfs.xfs /dev/sda2




mkswap
          /dev/sda2                                      Xfs




   VMWare                                                              VMWare

swapon /dev/sda1


swapon
swapoff
          free


   LFS      “                      ”

   export LFS=/mnt/lfs
   mkdir -pv $LFS




export LFS=/mnt/lfs                                            “   ”                                                 LFS
/dev/sda2         “
                     B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«
                                                              ”                                    h t t p : / / b l o g . b y p a t . c o m




   mount /dev/sda2 $LFS




   mkdir -v $LFS/sources
   chmod -v a+wt $LFS/sources




chmod a+wt                                                                777


   mkdir -v $LFS/tools
   ln -sv $LFS/tools /




                                                             /tools


   lfs

   groupadd lfs
   useradd -s /bin/bash -g lfs -m -k /dev/null lfs



   lfs

   passwd lfs



 tools     sources                                                lfs           lfs

   chown -v lfs $LFS/tools
   chown -v lfs $LFS/sources



     lfs

   su - lfs



                                                                      #   $


               lfs             root                                                   root
         LFS                                                                                 lfs


   lfs

   cat > ~/.bash_profile << "EOF"
exec env -i HOME=$HOME TERM=$TERM PS1='u:w$ ' /bin/bash
                    B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«                                         h t t p : / / b l o g . b y p a t . c o m




     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

         bash                                                             lfs
                            PATH                                                                                                              /tools/bin
             /bin                  /usr/bin                                     /bin   /usr/bin                                                   /tools/bin



                                                                                LFS




                                                                           Stripping
1.                                                          LiveCD
              VMWare                                                                                                                               F2          BIOS
      BOOT                                                       CD-ROM
2.                   B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«   h t t p : / / b l o g . b y p a t . c o m




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"
8.
cd $LFS/sources




     LFS

     cd $LFS/sources



Binutils-2.15.94.0.2.2 - Pass 1

     tar xvf /lfs-sources/binutils-2.15.94.0.2.2.tar.bz2
cd binutils-2.15.94.0.2.2
                B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«                                                              h t t p : / / b l o g . b y p a t . c o m




                                                                               tar xvf                            bz2                                          gz               tar
                                                                                                                                                               tar
                                                              bz2       j   gz      z           binutils   tar xvjf /lfs-sources/binutils-2.15.94.0.2.2.tar.bz2
 LFS   LiveCD                                           tar                               tar
                                                                                                                 tar xvf



                                       GCC4                                              GCC4                  LFS-6.1.1-3                                           LiveCD   GCC   3.4.3


   patch -Np1 -i /lfs-sources/binutils-2.15.94.0.2.2-gcc4-1.patch



                                                                    binutils

   mkdir -v ../binutils-build
   cd ../binutils-build
   ../binutils-2.15.94.0.2.2/configure --prefix=/tools --disable-nls
   make
   make install
   make -C ld clean
   make -C ld LIB_PATH=/tools/lib
   cd ..



                                                                       binutils-build                                                                                           binutils-
build

                        binutils                                                                           binutils-2.16.1
                                                        binutils-2.15.94.0.2.2


GCC-3.4.3 - Pass 1

   tar xvf /lfs-sources/gcc-3.4.3.tar.bz2
   mkdir -v gcc-build
   cd gcc-build
   ../gcc-3.4.3/configure --prefix=/tools --libexecdir=/tools/lib 
            --with-local-prefix=/tools --disable-nls 
            --enable-shared --enable-languages=c
   make bootstrap
   make install
   ln -vs gcc /tools/bin/cc
   cd ..
   rm -rf gcc-build
   rm -rf gcc-3.4.3



                                                                                 gcc-3.4.3
B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«                                                          h t t p : / / b l o g . b y p a t . c o m




              gcc-3.4.4                                       gcc-3.4.5   gcc-3.4.3                     GCC4.0.x                                                         gcc-3.4.x
                                                                          GCC4.0.x             LFS


Linux-Libc-Headers-2.6.11.2

    tar xvf /lfs-sources/linux-libc-headers-2.6.11.2.tar.bz2
    cd linux-libc-headers-2.6.11.2
    cp -Rv include/asm-i386 /tools/include/asm
    cp -Rv include/linux /tools/include
    cd ..
    rm -rf linux-libc-headers-2.6.11.2




Glibc-2.3.4

    tar xvf /lfs-sources/glibc-2.3.4.tar.bz2
    cd glibc-2.3.4
    patch -Np1 -i /lfs-sources/glibc-2.3.4-fix_test-1.patch
    mkdir -v ../glibc-build
    cd ../glibc-build
    ../glibc-2.3.4/configure --prefix=/tools 
        --disable-profile --enable-add-ons 
        --enable-kernel=2.6.0 --with-binutils=/tools/bin 
        --without-gd --with-headers=/tools/include 
        --without-selinux
    make
    mkdir -v /tools/etc
    touch /tools/etc/ld.so.conf
    make install
    make localedata/install-locales
    cd ..
    rm -rf glibc-build
    rm -rf glibc-2.3.4




glibc-2.3.4                                                        GCC4                     gcc-3.4.x                                                                    glibc-2.3.6
    GCC4


           --enable-kernel=2.6.0                                                   kernel                                                                       kernel                 linux-
2.6.15             2.6.0
make localedata/install-locales                                           locale                        locale                                               localedef        LFS
                                                          locale
mkdir -pv /tools/lib/locale
localedef -i zh_CN -f GB18030 zh_CN
localedef -i zh_CN -f GBK zh_CN
localedef -i zh_CN -f UTF-8 zh_CN
localedef -i zh_CN -f GB2312 zh_CN
localedef -i zh_HK -f UTF-8 zh_CN
localedef -i zh_HK -f BIG5-HKSCS zh_CN
localedef -i zh_TW -f EUC-TW zh_CN
localedef -i zh_TW -f UTF-8 zh_CN
                  B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«                                      h t t p : / / b l o g . b y p a t . c o m




localedef -i zh_TW -f BIG5 zh_CN




    cd binutils-build
    make -C ld install
    cd ..
    rm -rf binutils-build
    rm -rf binutils-2.15.94.0.2.2
    SPECFILE=$(gcc --print-file specs) &&
    sed 's@ /lib/ld-linux.so.2@ /tools/lib/ld-linux.so.2@g' $SPECFILE > tempspecfile &&
    mv -f tempspecfile $SPECFILE &&
    unset SPECFILE
    rm -vf /tools/lib/gcc/*/*/include/{pthread.h,bits/sigthread.h}




                 binutils-build                                                   make -C ld install
                                                                 GCC   specs                                          specs                      /lib/ld-linux.so.2
  /tools/lib/ld-linux.so.2                                                             LFS
  specs                                                   GCC4.0.x             specs                                                     specs
    GCC4.0.1                LFS



echo 'main(){}' > dummy.c
cc dummy.c
readelf -l a.out | grep ': /tools'


[Requesting program interpreter: /tools/lib/ld-linux.so.2]
                                       /tools/lib
rm -rf a.out dummy.c



                          3                                                                                              make check                            3


Tcl-8.4.9 Expect-5.43.0 DejaGNU-1.4.4

    tar xvf /lfs-sources/tcl8.4.9-src.tar.bz2
    cd tcl8.4.9/unix
    ./configure --prefix=/tools
    make
    make install
    cd ..
    export TCLPATH=$(pwd)
    ln -sv tclsh8.4 /tools/bin/tclsh
    cd ..
    tar xvf /lfs-sources/expect-5.43.0.tar.bz2
    cd expect-5.43
    patch -Np1 -i /lfs-sources/expect-5.43.0-spawn-1.patch
    ./configure --prefix=/tools --with-tcl=/tools/lib --with-tclinclude=$TCLPATH --with-
    x=no
    make
    make SCRIPTS="" install
    unset TCLPATH
cd ..       B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«                    h t t p : / / b l o g . b y p a t . c o m




   tar xvf /lfs-sources/dejagnu-1.4.4.tar.bz2
   cd dejagnu-1.4.4
   ./configure --prefix=/tools
   make install
   cd ..
   rm -rf tcl8.4.9
   rm -rf expect-5.43




GCC-3.4.3 - Pass 2

   tar xvf /lfs-sources/gcc-3.4.3.tar.bz2
   cd gcc-3.4.3
   patch -Np1 -i /lfs-sources/gcc-3.4.3-no_fixincludes-1.patch
   patch -Np1 -i /lfs-sources/gcc-3.4.3-specs-2.patch
   mkdir -v ../gcc-build
   cd ../gcc-build
   ../gcc-3.4.3/configure --prefix=/tools 
       --libexecdir=/tools/lib --with-local-prefix=/tools 
       --enable-clocale=gnu --enable-shared 
       --enable-threads=posix --enable-__cxa_atexit 
       --enable-languages=c,c++ --disable-libstdcxx-pch
   make
   make install
   cd ..
   rm -rf gcc-build
   rm -rf gcc-3.4.3




Binutils-2.15.94.0.2.2 - Pass 2

   tar xvf /lfs-sources/binutils-2.15.94.0.2.2.tar.bz2
   mkdir -v binutils-build
   cd binutils-build
   ../binutils-2.15.94.0.2.2/configure --prefix=/tools --disable-nls 
         --enable-shared --with-lib-path=/tools/lib
   make
   make install
   make -C ld clean
   make -C ld LIB_PATH=/usr/lib:/lib
   cd ..




                                                       binutils-build
Gawk-3.1.4

   tar xvf /lfs-sources/gawk-3.1.4.tar.bz2
   cd gawk-3.1.4
   ./configure --prefix=/tools
   make
   make install
cd ..          B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«        h t t p : / / b l o g . b y p a t . c o m




   rm -rf gawk-3.1.4




Coreutils-5.2.1

   tar xvf /lfs-sources/coreutils-5.2.1.tar.bz2
   cd coreutils-5.2.1
   DEFAULT_POSIX2_VERSION=199209 ./configure --prefix=/tools
   make
   make install
   cd ..
   rm -rf coreutils-5.2.1




Bzip2-1.0.3

   tar xvf /lfs-sources/bzip2-1.0.3.tar.bz2
   cd bzip2-1.0.3
   make
   make PREFIX=/tools install
   cd ..
   rm -rf bzip2-1.0.3




Gzip-1.3.5

   tar xvf /lfs-sources/gzip-1.3.5.tar.bz2
   cd gzip-1.3.5
   ./configure --prefix=/tools
   make
   make install
   cd ..
   rm -rf gzip-1.3.5




Diffutils-2.8.1

   tar xvf /lfs-sources/diffutils-2.8.1.tar.bz2
   cd diffutils-2.8.1
   ./configure --prefix=/tools
   make
   make install
   cd ..
   rm -rf diffutils-2.8.1




Findutils-4.2.23
tar xvf /lfs-sources/findutils-4.2.23.tar.bz2
                 B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«       h t t p : / / b l o g . b y p a t . c o m




   cd findutils-4.2.23
   ./configure --prefix=/tools
   make
   make install
   cd ..
   rm -rf findutils-4.2.23




Make-3.80

   tar xvf /lfs-sources/make-3.80.tar.bz2
   cd make-3.80
   ./configure --prefix=/tools
   make
   make install
   cd ..
   rm -rf make-3.80




Grep-2.5.1a

   tar xvf /lfs-sources/grep-2.5.1a.tar.bz2
   cd grep-2.5.1a
   ./configure --prefix=/tools --disable-perl-regexp
   make
   make install
   cd ..
   rm -rf grep-2.5.1a




Sed-4.1.4

   tar xvf /lfs-sources/sed-4.1.4.tar.bz2
   cd sed-4.1.4
   ./configure --prefix=/tools
   make
   make install
   cd ..
   rm -rf sed-4.1.4




Gettext-0.14.3

   tar xvf /lfs-sources/gettext-0.14.3.tar.bz2
   cd gettext-0.14.3
   ./configure --prefix=/tools --disable-libasprintf --without-csharp
   make
   make install
cd ..      B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«          h t t p : / / b l o g . b y p a t . c o m




   rm -rf gettext-0.14.3




Ncurses-5.4

   tar xvf /lfs-sources/ncurses-5.4.tar.bz2
   cd ncurses-5.4
   ./configure --prefix=/tools --with-shared --without-debug --without-ada --enable-
   overwrite
   make
   make install
   cd ..
   rm -rf ncurses-5.4




Patch-2.5.4

   tar xvf /lfs-sources/patch-2.5.4.tar.bz2
   cd patch-2.5.4
   CPPFLAGS=-D_GNU_SOURCE ./configure --prefix=/tools
   make
   make install
   cd ..
   rm -rf patch-2.5.4




Tar-1.15.1

   tar xvf /lfs-sources/tar-1.15.1.tar.bz2
   cd tar-1.15.1
   ./configure --prefix=/tools
   make
   make install
   cd ..
   rm -rf tar-1.15.1




Texinfo-4.8

   tar xvf /lfs-sources/texinfo-4.8.tar.bz2
   cd texinfo-4.8
   ./configure --prefix=/tools
   make
   make install
   cd ..
   rm -rf texinfo-4.8
Bash-3.0      B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«          h t t p : / / b l o g . b y p a t . c o m




   tar xvf /lfs-sources/bash-3.0.tar.bz2
   cd bash-3.0
   patch -Np1 -i /lfs-sources/bash-3.0-avoid_WCONTINUED-1.patch
   ./configure --prefix=/tools --without-bash-malloc
   make
   make install
   ln -vs bash /tools/bin/sh
   cd ..
   rm -rf bash-3.0




M4-1.4.3

   tar xvf /lfs-sources/m4-1.4.3.tar.bz2
   cd m4-1.4.3
   ./configure --prefix=/tools
   make
   make install
   cd ..
   rm -rf m4-1.4.3




Bison-2.0

   tar xvf /lfs-sources/bison-2.0.tar.bz2
   cd bison-2.0
   ./configure --prefix=/tools
   make
   make install
   cd ..
   rm -rf bison-2.0




Flex-2.5.31

   tar xvf /lfs-sources/flex-2.5.31.tar.bz2
   cd flex-2.5.31
   patch -Np1 -i /lfs-sources/flex-2.5.31-debian_fixes-3.patch
   touch doc/flex.1
   ./configure --prefix=/tools
   make
   make install
   cd ..
   rm -rf flex-2.5.31




Util-linux-2.12q
tar xvf /lfs-sources/util-linux-2.12q.tar.bz2
                    B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«                    h t t p : / / b l o g . b y p a t . c o m




       cd util-linux-2.12q
       sed -i 's@/usr/include@/tools/include@g' configure
       ./configure
       make -C lib
       make -C mount mount umount
       make -C text-utils more
       cp mount/{,u}mount text-utils/more /tools/bin
       cd ..
       rm -rf util-linux-2.12q



             util-linux-2.12q                                 GCC4                                                       cfdisk
       util-linux-2.12r


Perl-5.8.7

       tar xvf /lfs-sources/perl-5.8.7.tar.bz2
       cd perl-5.8.7
       patch -Np1 -i /lfs-sources/perl-5.8.7-libc-1.patch
       ./configure.gnu --prefix=/tools -Dstatic_ext='IO Fcntl POSIX'
       make perl utilities
       cp -v perl pod/pod2man /tools/bin
       mkdir -pv /tools/lib/perl5/5.8.7
       cp -Rv lib/* /tools/lib/perl5/5.8.7
       cd ..
       rm -rf perl-5.8.7




Stripping
                                                            /tools   strip
         Strip

       strip --strip-debug /tools/lib/*
       strip --strip-unneeded /tools/{,s}bin/*




info     man
rm -rf /tools/{info,man}


       lfs

       exit




                    root                                             #
B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«                                      h t t p : / / b l o g . b y p a t . c o m




      mkdir -pv $LFS/{proc,sys}




1.                                                      LiveCD
2.
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/sda2 $LFS
3.
swapon /dev/sda1


                                                                         tools




      mount -vt proc proc $LFS/proc
      mount -vt sysfs sysfs $LFS/sys




LFS

      mount -vft tmpfs tmpfs $LFS/dev
      mount -vft tmpfs tmpfs $LFS/dev/shm
      mount -vft devpts -o gid=4,mode=620 devpts $LFS/dev/pts




mount



mkdir $LFS/cdrom
mount /dev/cdrom $LFS/cdrom


                                                           lfs-sources      $LFS/sources

      cp -a /lfs-sources/* $LFS/sources




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
B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«                   h t t p : / / b l o g . b y p a t . c o m




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



             lfs                                                    root
         0            root

     chown -R 0:0 /tools




     install -dv /{bin,boot,dev,etc/opt,home,lib,mnt}
     install -dv /{sbin,srv,usr/local,var,opt}
     install -dv /root -m 0750
     install -dv /tmp /var/tmp -m 1777
     install -dv /media/{floppy,cdrom}
     install -dv /usr/{bin,include,lib,sbin,share,src}
     ln -sv share/{man,doc,info} /usr
     install -dv /usr/share/{doc,info,locale,man}
     install -dv /usr/share/{misc,terminfo,zoneinfo}
     install -dv /usr/share/man/man{1,2,3,4,5,6,7,8}
     install -dv /usr/local/{bin,etc,include,lib,sbin,share,src}
     ln -sv share/{man,doc,info} /usr/local
     install -dv /usr/local/share/{doc,info,locale,man}
     install -dv /usr/local/share/{misc,terminfo,zoneinfo}
     install -dv /usr/local/share/man/man{1,2,3,4,5,6,7,8}
     install -dv /var/{lock,log,mail,run,spool}
     install -dv /var/{opt,cache,lib/{misc,locate},local}
     install -dv /opt/{bin,doc,include,info}
     install -dv /opt/{lib,man/man{1,2,3,4,5,6,7,8}}




     ln -sv /tools/bin/{bash,cat,pwd,stty} /bin
ln -sv /tools/bin/perl /usr/bin
          B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«                   h t t p : / / b l o g . b y p a t . c o m




ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib
ln -sv bash /bin/sh




root

cat > /etc/passwd << "EOF"
root:x:0:0:root:/root:/bin/bash
EOF


cat > /etc/group << "EOF"
root:x:0:
bin:x:1:
sys:x:2:
kmem:x:3:
tty:x:4:
tape:x:5:
daemon:x:6:
floppy:x:7:
disk:x:8:
lp:x:9:
dialout:x:10:
audio:x:11:
video:x:12:
utmp:x:13:
usb:x:14:
cdrom:x:15:
EOF




   bash                 root                      “I have no name!”

exec /tools/bin/bash --login +h




touch /var/run/utmp /var/log/{btmp,lastlog,wtmp}
chgrp -v utmp /var/run/utmp /var/log/lastlog
chmod -v 664 /var/run/utmp /var/log/lastlog
mknod -m 600 /dev/console c 5 1
                     B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«                                             h t t p : / / b l o g . b y p a t . c o m




     mknod -m 666 /dev/null c 1 3




                             /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




     cd /sources




               LFS                                                        /cdrom              /cdrom/lfs-sources
     sources
export LFS=/cdrom/lfs-sources
                          sources

     export LFS=/sources




                                                              File-4.13            Bash-3.0


1.                                                           LiveCD
2.
export LFS=/mnt/lfs
                B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«         h t t p : / / b l o g . b y p a t . c o m




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
export LFS=/sources


Linux-Libc-Headers-2.6.11.2

    tar xvf $LFS/linux-libc-headers-2.6.11.2.tar.bz2
    cd linux-libc-headers-2.6.11.2
    cp -Rv include/asm-i386 /usr/include/asm
    cp -Rv include/linux /usr/include
    chown -Rv root:root /usr/include/{asm,linux}
    find /usr/include/{asm,linux} -type d -exec chmod -v 755 {} ;
    find /usr/include/{asm,linux} -type f -exec chmod -v 644 {} ;
    cd ..
    rm -rf linux-libc-headers-2.6.11.2




Man-pages-2.01

    tar xvf $LFS/man-pages-2.01.tar.bz2
    cd man-pages-2.01
make install
              B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«                               h t t p : / / b l o g . b y p a t . c o m




   cd ..
   rm -rf man-pages-2.01




man-pages                                                2.01


Glibc-2.3.4
                                                      glibc-2.3.4   glibc-build

   tar xvf $LFS/glibc-2.3.4.tar.bz2
   cd glibc-2.3.4
   tar -xjvf $LFS/glibc-linuxthreads-2.3.4.tar.bz2
   patch -Np1 -i $LFS/glibc-2.3.4-rtld_search_dirs-1.patch
   patch -Np1 -i $LFS/glibc-2.3.4-fix_test-1.patch
   patch -Np1 -i $LFS/glibc-2.3.4-tls_assert-1.patch
   mkdir -v ../glibc-build
   cd ../glibc-build
   ../glibc-2.3.4/configure --prefix=/usr 
       --disable-profile --enable-add-ons 
       --enable-kernel=2.6.0 --libexecdir=/usr/lib/glibc
   make
   make -k check >glibc-check-log 2>&1
   grep Error glibc-check-log
   touch /etc/ld.so.conf
   make install
   make localedata/install-locales
   make -C ../glibc-2.3.4/linuxthreads/man
   make -C ../glibc-2.3.4/linuxthreads/man install




   cat > /etc/nsswitch.conf << "EOF"
   # Begin /etc/nsswitch.conf


   passwd: files
   group: files
   shadow: files


   hosts: files dns
   networks: files


   protocols: files
   services: files
   ethers: files
   rpc: files


   # End /etc/nsswitch.conf
   EOF


   cp -v --remove-destination /usr/share/zoneinfo/Asia/Shanghai /etc/localtime


   cat > /etc/ld.so.conf << "EOF"
/usr/local/lib
                 B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«                h t t p : / / b l o g . b y p a t . c o m




      /opt/lib
      EOF




      cd ..
      rm -rf glibc-build
      rm -rf glibc-2.3.4




glibc                                                                                                             LFS




      cd binutils-build
      make -C ld INSTALL=/tools/bin/install install
      cd ..
      rm -rf binutils-build
      rm -rf binutils-2.15.94.0.2.2




                         binutils
LFS                                                      binutils



tar xvf $LFS/binutils-2.15.94.0.2.2.tar.bz2
mkdir binutils-build
cd binutils-build
../binutils-2.15.94.0.2.2/configure --prefix=/tools --disable-nls 
--enable-shared --with-lib-path=/tools/lib
make
make -C ld clean
make -C ld LIB_PATH=/usr/lib:/lib
make -C ld INSTALL=/tools/bin/install install
cd ..
rm -rf binutils-build
rm -rf binutils-2.15.94.0.2.2


      specs

      perl -pi -e 's@ /tools/lib/ld-linux.so.2@ /lib/ld-linux.so.2@g;' 
          -e 's@*startfile_prefix_spec:n@$_/usr/lib/ @g;' 
              $(gcc --print-file specs)
B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«         h t t p : / / b l o g . b y p a t . c o m




echo 'main(){}' > dummy.c
cc dummy.c
readelf -l a.out | grep ': /lib'
        [Requesting program interpreter: /lib/ld-linux.so.2]                                               /lib
rm -v dummy.c a.out



Binutils-2.15.94.0.2.2

    tar xvf $LFS/binutils-2.15.94.0.2.2.tar.bz2
    mkdir binutils-build
    cd binutils-build
    ../binutils-2.15.94.0.2.2/configure --prefix=/usr --enable-shared
    make tooldir=/usr




    make check



   check




    make tooldir=/usr install
    cp -v ../binutils-2.15.94.0.2.2/include/libiberty.h /usr/include
    cd ..
    rm -rf binutils-build
    rm -rf binutils-2.15.94.0.2.2




GCC-3.4.3

    tar xvf $LFS/gcc-3.4.3.tar.bz2
    cd gcc-3.4.3
    patch -Np1 -i $LFS/gcc-3.4.3-no_fixincludes-1.patch
    patch -Np1 -i $LFS/gcc-3.4.3-linkonce-1.patch
    sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in
    mkdir -v ../gcc-build
    cd ../gcc-build
    ../gcc-3.4.3/configure --prefix=/usr 
        --libexecdir=/usr/lib --enable-shared 
        --enable-threads=posix --enable-__cxa_atexit 
        --enable-clocale=gnu --enable-languages=c,c++
    make
make -k check  B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«       h t t p : / / b l o g . b y p a t . c o m




   check




   make install
   ln -sv ../usr/bin/cpp /lib
   ln -sv gcc /usr/bin/cc
   cd ..
   rm -rf gcc-build
   rm -rf gcc-3.4.3




Coreutils-5.2.1

   tar xvf $LFS/coreutils-5.2.1.tar.bz2
   cd coreutils-5.2.1
   patch -Np1 -i $LFS/coreutils-5.2.1-uname-2.patch
   patch -Np1 -i $LFS/coreutils-5.2.1-suppress_uptime_kill_su-1.patch
   DEFAULT_POSIX2_VERSION=199209 ./configure --prefix=/usr
   make




   echo "dummy1:x:1000:" >> /etc/group
   echo "dummy2:x:1001:dummy" >> /etc/group
   echo "dummy:x:1000:1000:::/bin/bash" >> /etc/passwd
   make NON_ROOT_USERNAME=dummy check-root
   src/su dummy -c "make RUN_EXPENSIVE_TESTS=yes check"




   sed -i '/dummy/d' /etc/passwd /etc/group




   make install
   mv -v /usr/bin/{cat,chgrp,chmod,chown,cp,date,dd,df,echo} /bin
   mv -v /usr/bin/{false,hostname,ln,ls,mkdir,mknod,mv,pwd,rm} /bin
   mv -v /usr/bin/{rmdir,stty,sync,true,uname} /bin
   mv -v /usr/bin/chroot /usr/sbin
   mv -v /usr/bin/{head,sleep} /bin
   cd ..
rm -rf coreutils-5.2.1
                B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«   h t t p : / / b l o g . b y p a t . c o m




Zlib-1.2.3

   tar xvf $LFS/zlib-1.2.3.tar.bz2
   cd zlib-1.2.3
   ./configure --prefix=/usr --shared --libdir=/lib
   make




   make check




   check




   make install
   rm -v /lib/libz.so
   ln -sfv ../../lib/libz.so.1.2.3 /usr/lib/libz.so
   make clean
   ./configure --prefix=/usr
   make




   make check



   check




   make install
   chmod -v 644 /usr/lib/libz.a
   cd ..
   rm -rf zlib-1.2.3




Mktemp-1.5

   tar xvf $LFS/mktemp-1.5.tar.bz2
   cd mktemp-1.5
patch -Np1 -i $LFS/mktemp-1.5-add_tempfile-2.patch
                B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«         h t t p : / / b l o g . b y p a t . c o m




   ./configure --prefix=/usr --with-libc
   make
   make install
   make install-tempfile
   cd ..
   rm -rf mktemp-1.5




Iana-Etc-1.04

   tar xvf $LFS/iana-etc-1.04.tar.bz2
   cd iana-etc-1.04
   make
   make install
   cd ..
   rm -rf iana-etc-1.04




Findutils-4.2.23

   tar xvf $LFS/findutils-4.2.23.tar.bz2
   cd findutils-4.2.23
   ./configure --prefix=/usr --libexecdir=/usr/lib/locate 
       --localstatedir=/var/lib/locate
   make




   make check




   check




   make install
   cd ..
   rm -rf findutils-4.2.23




Gawk-3.1.4

   tar xvf $LFS/gawk-3.1.4.tar.bz2
   cd gawk-3.1.4
   ./configure --prefix=/usr --libexecdir=/usr/lib
   make
B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«           h t t p : / / b l o g . b y p a t . c o m




   make check



   check




   make install
   cd ..
   rm -rf gawk-3.1.4




Ncurses-5.4

   tar xvf $LFS/ncurses-5.4.tar.bz2
   cd ncurses-5.4
   ./configure --prefix=/usr --with-shared --without-debug
   make
   make install
   chmod -v 755 /usr/lib/*.5.4
   chmod -v 644 /usr/lib/libncurses++.a
   mv -v /usr/lib/libncurses.so.5* /lib
   ln -sfv ../../lib/libncurses.so.5 /usr/lib/libncurses.so
   ln -sfv libncurses.so /usr/lib/libcurses.so
   cd ..
   rm -rf ncurses-5.4




Readline-5.0

   tar xvf $LFS/readline-5.0.tar.bz2
   cd readline-5.0
   patch -Np1 -i $LFS/readline-5.0-fixes-1.patch
   ./configure --prefix=/usr --libdir=/lib
   make SHLIB_XLDFLAGS=-lncurses
   make install
   chmod -v 755 /lib/lib{readline,history}.so*
   mv -v /lib/lib{readline,history}.a /usr/lib
   rm -v /lib/lib{readline,history}.so
   ln -sfv ../../lib/libreadline.so.5 /usr/lib/libreadline.so
   ln -sfv ../../lib/libhistory.so.5 /usr/lib/libhistory.so
   cd ..
   rm -rf readline-5.0




Vim-6.3
B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«             h t t p : / / b l o g . b y p a t . c o m




   tar xvf $LFS/vim-6.3.tar.bz2
   tar xvf $LFS/vim-6.3-lang.tar.gz
   cd vim63
   echo '#define SYS_VIMRC_FILE "/etc/vimrc"' >> src/feature.h
   patch -Np1 -i $LFS/vim-6.3-security_fix-2.patch
   ./configure --prefix=/usr --enable-multibyte
   make




   make test



   test




   make install
   ln -sv vim /usr/bin/vi




   vim

   cat > /etc/vimrc << "EOF"
   " Begin /etc/vimrc


   set nocompatible
   set backspace=2
   syntax on
   if (&term == "iterm") || (&term == "putty")
     set background=dark
   endif


   " End /etc/vimrc
   EOF




   cd ..
   rm -rf vim63




M4-1.4.3

   tar xvf $LFS/m4-1.4.3.tar.bz2
   cd m4-1.4.3
./configure --prefix=/usr
                B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«          h t t p : / / b l o g . b y p a t . c o m




   make




   make check



   check




   make install
   cd ..
   rm -rf m4-1.4.3




Bison-2.0

   tar xvf $LFS/bison-2.0.tar.bz2
   cd bison-2.0
   ./configure --prefix=/usr
   make




   make check



   check




   make install
   cd ..
   rm -rf bison-2.0




Less-382

   tar xvf $LFS/less-382.tar.bz2
   cd less-382
   ./configure --prefix=/usr --bindir=/bin --sysconfdir=/etc
   make
make install B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«    h t t p : / / b l o g . b y p a t . c o m




   cd ..
   rm -rf less-382




Groff-1.19.1

   tar xvf $LFS/groff-1.19.1.tar.bz2
   cd groff-1.19.1
   PAGE=A4 ./configure --prefix=/usr
   make
   make install
   ln -sv soelim /usr/bin/zsoelim
   ln -sv eqn /usr/bin/geqn
   ln -sv tbl /usr/bin/gtbl
   cd ..
   rm -rf groff-1.19.1




Sed-4.1.4

   tar xvf $LFS/sed-4.1.4.tar.bz2
   cd sed-4.1.4
   sed -i 's@/doc@&/sed-4.1.4@' doc/Makefile.in
   ./configure --prefix=/usr --bindir=/bin
   make




   make check




   check




   make install
   cd ..
   rm -rf sed-4.1.4




Flex-2.5.31

   tar xvf $LFS/flex-2.5.31.tar.bz2
   cd flex-2.5.31
   patch -Np1 -i $LFS/flex-2.5.31-debian_fixes-3.patch
touch doc/flex.1
                 B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«   h t t p : / / b l o g . b y p a t . c o m




   ./configure --prefix=/usr
   make




   make check



   check




   make install
   ln -sv libfl.a /usr/lib/libl.a




      lex

   cat > /usr/bin/lex << "EOF"
   #!/bin/sh
   # Begin /usr/bin/lex


   exec /usr/bin/flex -l "$@"


   # End /usr/bin/lex
   EOF
   chmod -v 755 /usr/bin/lex




   cd ..
   rm -rf flex-2.5.31




Gettext-0.14.3

   tar xvf $LFS/gettext-0.14.3.tar.bz2
   cd gettext-0.14.3
   ./configure --prefix=/usr
   make
make check     B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«      h t t p : / / b l o g . b y p a t . c o m




   check




   make install
   cd ..
   rm -rf gettext-0.14.3




Inetutils-1.4.2

   tar xvf $LFS/inetutils-1.4.2.tar.bz2
   cd inetutils-1.4.2
   patch -Np1 -i $LFS/inetutils-1.4.2-kernel_headers-1.patch
   patch -Np1 -i $LFS/inetutils-1.4.2-no_server_man_pages-1.patch
   ./configure --prefix=/usr --libexecdir=/usr/sbin 
       --sysconfdir=/etc --localstatedir=/var 
       --disable-logger --disable-syslogd 
       --disable-whois --disable-servers
   make
   make install
   mv -v /usr/bin/ping /bin
   cd ..
   rm -rf inetutils-1.4.2




IPRoute2-2.6.11-050330

   tar xvf $LFS/iproute2-2.6.11-050330.tar.bz2
   cd iproute2-2.6.11
   sed -i '/^TARGETS/s@arpd@@g' misc/Makefile
   ./configure
   make SBINDIR=/sbin
   make SBINDIR=/sbin install
   cd ..
   rm -rf iproute2-2.6.11




Perl-5.8.7

   tar xvf $LFS/perl-5.8.7.tar.bz2
   cd perl-5.8.7
   ./configure.gnu --prefix=/usr -Dpager="/bin/less -isR"
   make
B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«    h t t p : / / b l o g . b y p a t . c o m




   echo "127.0.0.1 localhost $(hostname)" > /etc/hosts
   make test




   test




   make install
   cd ..
   rm -rf perl-5.8.7




Texinfo-4.8

   tar xvf $LFS/texinfo-4.8.tar.bz2
   cd texinfo-4.8
   patch -Np1 -i $LFS/texinfo-4.8-tempfile_fix-1.patch
   ./configure --prefix=/usr
   make




   make check



   check




   make install
   make TEXMF=/usr/share/texmf install-tex




   cd /usr/share/info
   rm dir
   for f in *
   do install-info $f dir 2>/dev/null
   done
B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«   h t t p : / / b l o g . b y p a t . c o m




   cd /sources
   rm -rf texinfo-4.8




Autoconf-2.59

   tar xvf $LFS/autoconf-2.59.tar.bz2
   cd autoconf-2.59
   ./configure --prefix=/usr
   make




   make check




   check




   make install
   cd ..
   rm -rf autoconf-2.59




Automake-1.9.5

   tar xvf $LFS/automake-1.9.5.tar.bz2
   cd automake-1.9.5
   ./configure --prefix=/usr
   make




   make check




   check                   3




   make install
cd ..        B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«               h t t p : / / b l o g . b y p a t . c o m




     rm -rf automake-1.9.5




Bash-3.0

     tar xvf $LFS/bash-3.0.tar.bz2
     cd bash-3.0
     tar -xvf $LFS/bash-doc-3.0.tar.bz2 &&
     sed -i "s|htmldir = @htmldir@|htmldir = /usr/share/doc/bash-3.0|" Makefile.in
     patch -Np1 -i $LFS/bash-3.0-fixes-3.patch
     patch -Np1 -i $LFS/bash-3.0-avoid_WCONTINUED-1.patch
     ./configure --prefix=/usr --bindir=/bin --without-bash-malloc --with-installed-readline
     make




     make check



     check




     make install
     cd ..
     rm -rf bash-3.0




             /bin/bash

     exec /bin/bash --login +h




                                                           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
                 B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«   h t t p : / / b l o g . b y p a t . c o m




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
export LFS=/sources


File-4.13

    tar xvf $LFS/file-4.13.tar.bz2
    cd file-4.13
    ./configure --prefix=/usr
    make
    make install
    cd ..
    rm -rf file-4.13




Libtool-1.5.14

    tar xvf $LFS/libtool-1.5.14.tar.bz2
    cd libtool-1.5.14
    ./configure --prefix=/usr
    make




    make check
B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«     h t t p : / / b l o g . b y p a t . c o m




   check




   make install
   cd ..
   rm -rf libtool-1.5.14




Bzip2-1.0.3

   tar xvf $LFS/bzip2-1.0.3.tar.bz2
   cd bzip2-1.0.3
   patch -Np1 -i $LFS/bzip2-1.0.3-install_docs-1.patch
   patch -Np1 -i $LFS/bzip2-1.0.3-bzgrep_security-1.patch
   make -f Makefile-libbz2_so
   make clean
   make
   make install
   cp -v bzip2-shared /bin/bzip2
   cp -av libbz2.so* /lib
   ln -sv ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so
   rm -v /usr/bin/{bunzip2,bzcat,bzip2}
   ln -sv bzip2 /bin/bunzip2
   ln -sv bzip2 /bin/bzcat
   cd ..
   rm -rf bzip2-1.0.3




Diffutils-2.8.1

   tar xvf $LFS/diffutils-2.8.1.tar.bz2
   cd diffutils-2.8.1
   ./configure --prefix=/usr
   make
   make install
   cd ..
   rm -rf diffutils-2.8.1




Kbd-1.12

   tar xvf $LFS/kbd-1.12.tar.bz2
   cd kbd-1.12
   ./configure
   make
   make install
cd ..        B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«          h t t p : / / b l o g . b y p a t . c o m




   rm -rf kbd-1.12




E2fsprogs-1.37

   tar xvf $LFS/e2fsprogs-1.37.tar.bz2
   cd e2fsprogs-1.37
   sed -i -e 's/-DTEST/$(ALL_CFLAGS) &/' lib/e2p/Makefile.in
   mkdir -v build
   cd build
   ../configure --prefix=/usr --with-root-prefix="" 
       --enable-elf-shlibs --disable-evms
   make




   make check



   check




   make install
   make install-libs
   cd ../..
   rm -rf e2fsprogs-1.37




Grep-2.5.1a

   tar xvf $LFS/grep-2.5.1a.tar.bz2
   cd grep-2.5.1a
   ./configure --prefix=/usr --bindir=/bin
   make




   make check




   check
B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«     h t t p : / / b l o g . b y p a t . c o m




   make install
   cd ..
   rm -rf grep-2.5.1a




GRUB-0.96

   tar xvf $LFS/grub-0.96.tar.bz2
   cd grub-0.96
   ./configure --prefix=/usr
   make




   make check




   check        “ufs2_stage1_5 is too big”




   make install
   mkdir -v /boot/grub
   cp -v /usr/lib/grub/i386-pc/stage{1,2} /boot/grub
   cd ..
   rm -rf grub-0.96




Gzip-1.3.5

   tar xvf $LFS/gzip-1.3.5.tar.bz2
   cd gzip-1.3.5
   patch -Np1 -i $LFS/gzip-1.3.5-security_fixes-1.patch
   ./configure --prefix=/usr
   sed -i 's@"BINDIR"@/bin@g' gzexe.in
   make
   make install
   mv -v /usr/bin/gzip /bin
   rm -v /usr/bin/{gunzip,zcat}
   ln -sv gzip /bin/gunzip
   ln -sv gzip /bin/zcat
   ln -sv gzip /bin/compress
   ln -sv gunzip /bin/uncompress
   cd ..
   rm -rf gzip-1.3.5
B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«   h t t p : / / b l o g . b y p a t . c o m




Hotplug-2004_09_23

   tar xvf $LFS/hotplug-2004_09_23.tar.bz2
   cd hotplug-2004_09_23
   make install
   cp -v etc/hotplug/pnp.distmap /etc/hotplug
   rm -rfv /etc/init.d
   rm -fv /etc/hotplug/net.agent
   mkdir -v /lib/firmware
   cd ..
   rm -rf hotplug-2004_09_23




Man-1.5p

   tar xvf $LFS/man-1.5p.tar.bz2
   cd man-1.5p
   sed -i 's@-is@&R@g' configure
   sed -i 's@MANPATH./usr/man@#&@g' src/man.conf.in
   ./configure -confdir=/etc
   make
   make install
   cd ..
   rm -rf man-1.5p




Make-3.80

   tar xvf $LFS/make-3.80.tar.bz2
   cd make-3.80
   ./configure --prefix=/usr
   make




   make check



   check




   make install
   cd ..
   rm -rf make-3.80
B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«      h t t p : / / b l o g . b y p a t . c o m




Module-Init-Tools-3.1

   tar xvf $LFS/module-init-tools-3.1.tar.bz2
   tar xvf $LFS/module-init-tools-testsuite-3.1.tar.bz2
   cd module-init-tools-3.1
   touch modprobe.conf.5
   ./configure
   make check
   make distclean
   ./configure --prefix="" --enable-zlib
   make
   make install
   cd ..
   rm -rf module-init-tools-3.1




Patch-2.5.4

   tar xvf $LFS/patch-2.5.4.tar.bz2
   cd patch-2.5.4
   CPPFLAGS=-D_GNU_SOURCE ./configure --prefix=/usr
   make
   make install
   cd ..
   rm -rf patch-2.5.4




Procps-3.2.5

   tar xvf $LFS/procps-3.2.5.tar.bz2
   cd procps-3.2.5
   make
   make install
   cd ..
   rm -rf procps-3.2.5




Psmisc-21.6

   tar xvf $LFS/psmisc-21.6.tar.bz2
   cd psmisc-21.6
   ./configure --prefix=/usr --exec-prefix=""
   make
   make install
   mv -v /bin/pstree* /usr/bin
   ln -sv killall /bin/pidof
cd ..         B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«      h t t p : / / b l o g . b y p a t . c o m




   rm -rf psmisc-21.6




Shadow-4.0.9

   tar xvf $LFS/shadow-4.0.9.tar.bz2
   cd shadow-4.0.9
   ./configure --libdir=/lib --enable-shared
   sed -i 's/groups$(EXEEXT) //' src/Makefile
   sed -i '/groups/d' man/Makefile
   make
   make install
   cp -v etc/{limits,login.access} /etc
   sed -e's@#MD5_CRYPT_ENAB.no@MD5_CRYPT_ENAB yes@' 
       -e 's@/var/spool/mail@/var/mail@' 
       etc/login.defs.linux > /etc/login.defs
   mv -v /usr/bin/passwd /bin
   mv -v /lib/libshadow.*a /usr/lib
   rm -v /lib/libshadow.so
   ln -sfv ../../lib/libshadow.so.0 /usr/lib/libshadow.so
   mkdir -v /etc/default
   pwconv
   grpconv
   passwd root


        root

   cd ..
   rm -rf shadow-4.0.9




Sysklogd-1.4.1

   tar xvf $LFS/sysklogd-1.4.1.tar.bz2
   cd sysklogd-1.4.1
   patch -Np1 -i $LFS/sysklogd-1.4.1-fixes-1.patch
   make
   make install




   syslog

   cat > /etc/syslog.conf << "EOF"
   # Begin /etc/syslog.conf


   auth,authpriv.* -/var/log/auth.log
   *.*;auth,authpriv.none -/var/log/sys.log
   daemon.* -/var/log/daemon.log
kern.* -/var/log/kern.log
                B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«        h t t p : / / b l o g . b y p a t . c o m




   mail.* -/var/log/mail.log
   user.* -/var/log/user.log
   *.emerg *


   # log the bootscript output:
   local2.* -/var/log/boot.log


   # End /etc/syslog.conf
   EOF




   cd ..
   rm -rf sysklogd-1.4.1




Sysvinit-2.86

   tar xvf $LFS/sysvinit-2.86.tar.bz2
   cd sysvinit-2.86
   sed -i 's@Sending processes@& started by init@g' src/init.c
   make -C src
   make -C src install




   cat > /etc/inittab << "EOF"
   # Begin /etc/inittab


   id:3:initdefault:


   si::sysinit:/etc/rc.d/init.d/rc sysinit


   l0:0:wait:/etc/rc.d/init.d/rc 0
   l1:S1:wait:/etc/rc.d/init.d/rc 1
   l2:2:wait:/etc/rc.d/init.d/rc 2
   l3:3:wait:/etc/rc.d/init.d/rc 3
   l4:4:wait:/etc/rc.d/init.d/rc 4
   l5:5:wait:/etc/rc.d/init.d/rc 5
   l6:6:wait:/etc/rc.d/init.d/rc 6


   ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now


   su:S016:once:/sbin/sulogin


   1:2345:respawn:/sbin/agetty -I '033(K' tty1 9600
   2:2345:respawn:/sbin/agetty -I '033(K' tty2 9600
   3:2345:respawn:/sbin/agetty -I '033(K' tty3 9600
4:2345:respawn:/sbin/agetty -I '033(K' tty4 9600
                B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«        h t t p : / / b l o g . b y p a t . c o m




   5:2345:respawn:/sbin/agetty -I '033(K' tty5 9600
   6:2345:respawn:/sbin/agetty -I '033(K' tty6 9600


   # End /etc/inittab
   EOF


   cd ..
   rm -rf sysvinit-2.86




Tar-1.15.1

   tar xvf $LFS/tar-1.15.1.tar.bz2
   cd tar-1.15.1
   patch -Np1 -i $LFS/tar-1.15.1-sparse_fix-1.patch
   ./configure --prefix=/usr --bindir=/bin --libexecdir=/usr/sbin
   make




   make check




   check




   make install
   cd ..
   rm -rf tar-1.15.1




Udev-056

   tar xvf $LFS/udev-056.tar.bz2
   cd udev-056
   make udevdir=/dev




   make test
B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«                      h t t p : / / b l o g . b y p a t . c o m




     test




     make DESTDIR=/ udevdir=/dev install
     cp -v $LFS/udev-config-4.rules /etc/udev/rules.d/25-lfs.rules
     /sbin/udevstart
     cd ..
     rm -rf udev-056




                                                         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
export LFS=/sources


Util-linux-2.12q

     tar xvf $LFS/util-linux-2.12q.tar.bz2
     cd util-linux-2.12q
     sed -i 's@etc/adjtime@var/lib/hwclock/adjtime@g' 
         hwclock/hwclock.c
     mkdir -p /var/lib/hwclock
     patch -Np1 -i $LFS/util-linux-2.12q-cramfs-1.patch
     patch -Np1 -i $LFS/util-linux-2.12q-umount_fix-1.patch
     ./configure
make HAVE_KILL=yes HAVE_SLN=yes
                 B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«                      h t t p : / / b l o g . b y p a t . c o m




     make HAVE_KILL=yes HAVE_SLN=yes install
     mv /usr/bin/logger /bin
     cd ..
     rm -rf util-linux-2.12q




util-linux-2.12q                                          GCC4    Bug   util-linux-2.12r


     chroot

     logout




  Strip       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




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
export LFS=/sources
B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«            h t t p : / / b l o g . b y p a t . c o m




Strip

     /tools/bin/find /{,usr/}{bin,lib,sbin} -type f 
        -exec /tools/bin/strip --strip-debug '{}' ';'




     chroot

     logout




               chroot

     chroot "$LFS" /usr/bin/env -i 
         HOME=/root TERM="$TERM" PS1='u:w$ ' 
         PATH=/bin:/usr/bin:/sbin:/usr/sbin 
         /bin/bash --login




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
export LFS=/sources


LFS-Bootscripts-3.2.1
B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«                                  h t t p : / / b l o g . b y p a t . c o m




tar xvf lfs-bootscripts-3.2.1.tar.bz2
cd lfs-bootscripts-3.2.1
make install
cd ..
rm -rf lfs-bootscripts-3.2.1




       Configuring the setclock Script

cat > /etc/sysconfig/clock << "EOF"
# Begin /etc/sysconfig/clock


UTC=1


# End /etc/sysconfig/clock
EOF




bash

cat > /etc/inputrc << "EOF"
set horizontal-scroll-mode Off
set meta-flag On
set input-meta On
set convert-meta Off
set output-meta On
set bell-style none
"eOd": backward-word
"eOc": forward-word
"e[1~": beginning-of-line
"e[4~": end-of-line
"e[5~": beginning-of-history
"e[6~": end-of-history
"e[3~": delete-char
"e[2~": quoted-insert
"eOH": beginning-of-line
"eOF": end-of-line
"e[H": beginning-of-line
"e[F": end-of-line
EOF




Bash Shell                                           The Bash Shell Startup Files

cat > /etc/profile << "EOF"
# Begin /etc/profile


export LANG=zh_CN.GB18030
export INPUTRC=/etc/inputrc


# End /etc/profile
EOF




echo "HOSTNAME=mylinux" > /etc/sysconfig/network




hosts

cat > /etc/hosts << "EOF"
# Begin /etc/hosts (no network card version)


127.0.0.1 mylinux localhost


# End /etc/hosts (no network card version)
EOF




cd /etc/sysconfig/network-devices &&
mkdir -v ifconfig.eth0 &&
cat > ifconfig.eth0/ipv4 << "EOF"
ONBOOT=yes
SERVICE=ipv4-static
IP=192.168.1.1
GATEWAY=192.168.1.2
PREFIX=24
BROADCAST=192.168.1.255
EOF




 IP     GATEWAY   BROADCAST


DNS

cat > /etc/resolv.conf << "EOF"
# Begin /etc/resolv.conf


nameserver        DNS
nameserver        DNS


# End /etc/resolv.conf
EOF          B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«                                                       h t t p : / / b l o g . b y p a t . c o m




 fstab

  cat > /etc/fstab << "EOF"
  # Begin /etc/fstab


  # file system                                        mount-point    type   options            dump     fsck
  #                                                                                                    order


  /dev/sda2     /                                                    xfs defaults         1     1
  /dev/sda1     swap                                                 swap   pri=1           0     0
  proc           /proc                                                proc   defaults        0     0
  sysfs          /sys                                                 sysfs defaults          0     0
  devpts         /dev/pts                                             devpts gid=4,mode=620 0       0
  shm            /dev/shm                                             tmpfs defaults          0     0
  # End /etc/fstab
  EOF




        Linux-2.6.11.12

  cd /sources
  tar xvf linux-2.6.11.12.tar.bz2
  cd linux-2.6.11.12
  make mrproper
  make menuconfig




                                                                                    VMWare5.0                                                          loop
Device Drivers->Block devices                                        Loopback device support   Cryptoloop Support
SCSI                Device Drivers->SCSI device support->SCSI low-level drivers
BusLogic SCSI support                                initrd




                Device Drivers->Networking support->Ethernet (10 or 100Mbit)   AMD PCnet32 PCI support
B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«                                                   h t t p : / / b l o g . b y p a t . c o m




                                                      Device Drivers->Sound->Advanced Linux Sound Architecture->PCI devices                                (Creative)
Ensoniq AudioPCI 1371/1373


 Xfs                                         File Systems->XFS support           XFS                                                              initrd




   make
   make modules_install
cp -v arch/i386/boot/bzImage /boot/lfskernel-2.6.11.12
                      B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N«     h t t p : / / b l o g . b y p a t . c o m




       cp -v System.map /boot/System.map-2.6.11.12
       cp -v .config /boot/config-2.6.11.12




       Grub



       grub




       root (hd0,1)
       setup (hd0)
quit


       grub

       cat > /boot/grub/menu.lst << "EOF"
       # Begin /boot/grub/menu.lst


       # By default boot the first menu entry.
       default 0


       # Allow 30 seconds before booting the default.
       timeout 30


       # Use prettier colors.
       color green/black light-green/black


       # The first entry is for LFS.
       title LFS 6.1.1
       root (hd0,1)
       kernel /boot/lfskernel-2.6.11.12 root=/dev/sda2
       EOF



              root


  menu.lst                  /etc

       mkdir -v /etc/grub
       ln -sv /boot/grub/menu.lst /etc/grub




       logout
lfs


Grub
Bypat博客出品-手把手教你如何建立自己的linux系统lfs速成手册

More Related Content

What's hot

How to mount and unmount filesystem
How to mount and unmount filesystemHow to mount and unmount filesystem
How to mount and unmount filesystemCOMSATS
 
Make container without_docker_7
Make container without_docker_7Make container without_docker_7
Make container without_docker_7Sam Kim
 
Using Puppet on Linux, Windows, and Mac OSX
Using Puppet on Linux, Windows, and Mac OSXUsing Puppet on Linux, Windows, and Mac OSX
Using Puppet on Linux, Windows, and Mac OSXPuppet
 
Text mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformaticsText mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformaticsBITS
 
Archlinux install
Archlinux installArchlinux install
Archlinux installsambismo
 
The daemon in puppets
The daemon in puppetsThe daemon in puppets
The daemon in puppetsEdward
 
Welcome to the Symfony2 World - FOSDEM 2013
 Welcome to the Symfony2 World - FOSDEM 2013 Welcome to the Symfony2 World - FOSDEM 2013
Welcome to the Symfony2 World - FOSDEM 2013Lukas Smith
 
Install Archlinux in 10 Steps (Sort of) :)
Install Archlinux in 10 Steps (Sort of) :)Install Archlinux in 10 Steps (Sort of) :)
Install Archlinux in 10 Steps (Sort of) :)Sian Lerk Lau
 
Introduction to linux
Introduction to linuxIntroduction to linux
Introduction to linuxQIANG XU
 
FUSE Developing Fillesystems in userspace
FUSE Developing Fillesystems in userspaceFUSE Developing Fillesystems in userspace
FUSE Developing Fillesystems in userspaceelliando dias
 
Building File Systems with FUSE
Building File Systems with FUSEBuilding File Systems with FUSE
Building File Systems with FUSEelliando dias
 
Linux basic for CADD biologist
Linux basic for CADD biologistLinux basic for CADD biologist
Linux basic for CADD biologistAjay Murali
 
Part 2 of 'Introduction to Linux for bioinformatics': Installing software
Part 2 of 'Introduction to Linux for bioinformatics': Installing softwarePart 2 of 'Introduction to Linux for bioinformatics': Installing software
Part 2 of 'Introduction to Linux for bioinformatics': Installing softwareJoachim Jacob
 
Linux: A Getting Started Presentation
Linux: A Getting Started PresentationLinux: A Getting Started Presentation
Linux: A Getting Started PresentationNap Ramirez
 

What's hot (19)

PHP selber bauen
PHP selber bauenPHP selber bauen
PHP selber bauen
 
How to mount and unmount filesystem
How to mount and unmount filesystemHow to mount and unmount filesystem
How to mount and unmount filesystem
 
Make container without_docker_7
Make container without_docker_7Make container without_docker_7
Make container without_docker_7
 
Using Puppet on Linux, Windows, and Mac OSX
Using Puppet on Linux, Windows, and Mac OSXUsing Puppet on Linux, Windows, and Mac OSX
Using Puppet on Linux, Windows, and Mac OSX
 
Text mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformaticsText mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformatics
 
Archlinux install
Archlinux installArchlinux install
Archlinux install
 
The daemon in puppets
The daemon in puppetsThe daemon in puppets
The daemon in puppets
 
Run wordcount job (hadoop)
Run wordcount job (hadoop)Run wordcount job (hadoop)
Run wordcount job (hadoop)
 
Welcome to the Symfony2 World - FOSDEM 2013
 Welcome to the Symfony2 World - FOSDEM 2013 Welcome to the Symfony2 World - FOSDEM 2013
Welcome to the Symfony2 World - FOSDEM 2013
 
Install Archlinux in 10 Steps (Sort of) :)
Install Archlinux in 10 Steps (Sort of) :)Install Archlinux in 10 Steps (Sort of) :)
Install Archlinux in 10 Steps (Sort of) :)
 
Introduction to linux
Introduction to linuxIntroduction to linux
Introduction to linux
 
Hp ux-security-check
Hp ux-security-checkHp ux-security-check
Hp ux-security-check
 
FUSE Developing Fillesystems in userspace
FUSE Developing Fillesystems in userspaceFUSE Developing Fillesystems in userspace
FUSE Developing Fillesystems in userspace
 
Building File Systems with FUSE
Building File Systems with FUSEBuilding File Systems with FUSE
Building File Systems with FUSE
 
Linux basic for CADD biologist
Linux basic for CADD biologistLinux basic for CADD biologist
Linux basic for CADD biologist
 
Introduction to Modern U-Boot
Introduction to Modern U-BootIntroduction to Modern U-Boot
Introduction to Modern U-Boot
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Part 2 of 'Introduction to Linux for bioinformatics': Installing software
Part 2 of 'Introduction to Linux for bioinformatics': Installing softwarePart 2 of 'Introduction to Linux for bioinformatics': Installing software
Part 2 of 'Introduction to Linux for bioinformatics': Installing software
 
Linux: A Getting Started Presentation
Linux: A Getting Started PresentationLinux: A Getting Started Presentation
Linux: A Getting Started Presentation
 

Viewers also liked

Bypat博客出品-利用cent os快速构建自己的发行版
Bypat博客出品-利用cent os快速构建自己的发行版Bypat博客出品-利用cent os快速构建自己的发行版
Bypat博客出品-利用cent os快速构建自己的发行版redhat9
 
ByPat博客出品-高性能Web服务器nginx及相关新技术的应用
ByPat博客出品-高性能Web服务器nginx及相关新技术的应用ByPat博客出品-高性能Web服务器nginx及相关新技术的应用
ByPat博客出品-高性能Web服务器nginx及相关新技术的应用redhat9
 
Bypat博客出品-服务器运维集群方法总结3
Bypat博客出品-服务器运维集群方法总结3Bypat博客出品-服务器运维集群方法总结3
Bypat博客出品-服务器运维集群方法总结3redhat9
 
Bypat博客出品-利用cent os快速构建自己的发行版-进阶版v1.1
Bypat博客出品-利用cent os快速构建自己的发行版-进阶版v1.1Bypat博客出品-利用cent os快速构建自己的发行版-进阶版v1.1
Bypat博客出品-利用cent os快速构建自己的发行版-进阶版v1.1redhat9
 
高性能Web服务器nginx及相关新技术的应用
高性能Web服务器nginx及相关新技术的应用高性能Web服务器nginx及相关新技术的应用
高性能Web服务器nginx及相关新技术的应用redhat9
 
Bypat博客出品-服务器运维集群方法总结2
Bypat博客出品-服务器运维集群方法总结2Bypat博客出品-服务器运维集群方法总结2
Bypat博客出品-服务器运维集群方法总结2redhat9
 
高性能Web服务器nginx及相关新技术的应用
高性能Web服务器nginx及相关新技术的应用高性能Web服务器nginx及相关新技术的应用
高性能Web服务器nginx及相关新技术的应用redhat9
 
ByPat博客出品Lvs+keepalived
ByPat博客出品Lvs+keepalivedByPat博客出品Lvs+keepalived
ByPat博客出品Lvs+keepalivedredhat9
 
Bypat博客出品-linux+apache+mysql+php之linux系统安装
Bypat博客出品-linux+apache+mysql+php之linux系统安装Bypat博客出品-linux+apache+mysql+php之linux系统安装
Bypat博客出品-linux+apache+mysql+php之linux系统安装redhat9
 

Viewers also liked (9)

Bypat博客出品-利用cent os快速构建自己的发行版
Bypat博客出品-利用cent os快速构建自己的发行版Bypat博客出品-利用cent os快速构建自己的发行版
Bypat博客出品-利用cent os快速构建自己的发行版
 
ByPat博客出品-高性能Web服务器nginx及相关新技术的应用
ByPat博客出品-高性能Web服务器nginx及相关新技术的应用ByPat博客出品-高性能Web服务器nginx及相关新技术的应用
ByPat博客出品-高性能Web服务器nginx及相关新技术的应用
 
Bypat博客出品-服务器运维集群方法总结3
Bypat博客出品-服务器运维集群方法总结3Bypat博客出品-服务器运维集群方法总结3
Bypat博客出品-服务器运维集群方法总结3
 
Bypat博客出品-利用cent os快速构建自己的发行版-进阶版v1.1
Bypat博客出品-利用cent os快速构建自己的发行版-进阶版v1.1Bypat博客出品-利用cent os快速构建自己的发行版-进阶版v1.1
Bypat博客出品-利用cent os快速构建自己的发行版-进阶版v1.1
 
高性能Web服务器nginx及相关新技术的应用
高性能Web服务器nginx及相关新技术的应用高性能Web服务器nginx及相关新技术的应用
高性能Web服务器nginx及相关新技术的应用
 
Bypat博客出品-服务器运维集群方法总结2
Bypat博客出品-服务器运维集群方法总结2Bypat博客出品-服务器运维集群方法总结2
Bypat博客出品-服务器运维集群方法总结2
 
高性能Web服务器nginx及相关新技术的应用
高性能Web服务器nginx及相关新技术的应用高性能Web服务器nginx及相关新技术的应用
高性能Web服务器nginx及相关新技术的应用
 
ByPat博客出品Lvs+keepalived
ByPat博客出品Lvs+keepalivedByPat博客出品Lvs+keepalived
ByPat博客出品Lvs+keepalived
 
Bypat博客出品-linux+apache+mysql+php之linux系统安装
Bypat博客出品-linux+apache+mysql+php之linux系统安装Bypat博客出品-linux+apache+mysql+php之linux系统安装
Bypat博客出品-linux+apache+mysql+php之linux系统安装
 

Similar to Bypat博客出品-手把手教你如何建立自己的linux系统lfs速成手册

Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)ngotogenome
 
Composer - The missing package manager for PHP
Composer - The missing package manager for PHPComposer - The missing package manager for PHP
Composer - The missing package manager for PHPTareq Hasan
 
JBoss AS 7 - YaJUG - nov. 2012
JBoss AS 7 - YaJUG - nov. 2012JBoss AS 7 - YaJUG - nov. 2012
JBoss AS 7 - YaJUG - nov. 2012Alexis Hassler
 
PHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the CloudPHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the CloudSalesforce Developers
 
Andresen 8 21 02
Andresen 8 21 02Andresen 8 21 02
Andresen 8 21 02FNian
 
Operating OPNFV: Deploy it, test it, run it
Operating OPNFV: Deploy it, test it, run itOperating OPNFV: Deploy it, test it, run it
Operating OPNFV: Deploy it, test it, run itOPNFV
 
BayLISA - FreeNAS 10 by Jordan Hubbard
BayLISA - FreeNAS 10 by Jordan HubbardBayLISA - FreeNAS 10 by Jordan Hubbard
BayLISA - FreeNAS 10 by Jordan HubbardiXsystems
 
JBoss AS 7 : Déployer sur terre et dans les nuages
JBoss AS 7 : Déployer sur terre et dans les nuagesJBoss AS 7 : Déployer sur terre et dans les nuages
JBoss AS 7 : Déployer sur terre et dans les nuagesAlexis Hassler
 
Phoenix Servers with Docker and Nginx
Phoenix Servers with Docker and NginxPhoenix Servers with Docker and Nginx
Phoenix Servers with Docker and NginxNils De Moor
 
OVN 設定サンプル | OVN config example 2015/12/27
OVN 設定サンプル | OVN config example 2015/12/27OVN 設定サンプル | OVN config example 2015/12/27
OVN 設定サンプル | OVN config example 2015/12/27Kentaro Ebisawa
 
Learning Your Way Around Alfresco [A Developer's Intro, Part 1. by Jeff Potts]
Learning Your Way Around Alfresco [A Developer's Intro, Part 1. by Jeff Potts]Learning Your Way Around Alfresco [A Developer's Intro, Part 1. by Jeff Potts]
Learning Your Way Around Alfresco [A Developer's Intro, Part 1. by Jeff Potts]Alfresco Software
 
IPS: Image Packaging System
IPS: Image Packaging SystemIPS: Image Packaging System
IPS: Image Packaging SystemEric Sproul
 
How to deploy PHP projects with docker
How to deploy PHP projects with dockerHow to deploy PHP projects with docker
How to deploy PHP projects with dockerRuoshi Ling
 
Jak se ^bonami\.(cz|pl|sk)$ vešlo do kontejneru
Jak se ^bonami\.(cz|pl|sk)$ vešlo do kontejneruJak se ^bonami\.(cz|pl|sk)$ vešlo do kontejneru
Jak se ^bonami\.(cz|pl|sk)$ vešlo do kontejneruVašek Boch
 
OpenSource Hardware -Debian Way
OpenSource Hardware -Debian WayOpenSource Hardware -Debian Way
OpenSource Hardware -Debian WaySiji Sunny
 
Linux Survival Kit for Proof of Concept & Proof of Technology
Linux Survival Kit for Proof of Concept & Proof of TechnologyLinux Survival Kit for Proof of Concept & Proof of Technology
Linux Survival Kit for Proof of Concept & Proof of TechnologyNugroho Gito
 
Local file systems update
Local file systems updateLocal file systems update
Local file systems updateLukáš Czerner
 

Similar to Bypat博客出品-手把手教你如何建立自己的linux系统lfs速成手册 (20)

Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
 
Composer - The missing package manager for PHP
Composer - The missing package manager for PHPComposer - The missing package manager for PHP
Composer - The missing package manager for PHP
 
Linux world
Linux worldLinux world
Linux world
 
JBoss AS 7 - YaJUG - nov. 2012
JBoss AS 7 - YaJUG - nov. 2012JBoss AS 7 - YaJUG - nov. 2012
JBoss AS 7 - YaJUG - nov. 2012
 
PHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the CloudPHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the Cloud
 
Andresen 8 21 02
Andresen 8 21 02Andresen 8 21 02
Andresen 8 21 02
 
Operating OPNFV: Deploy it, test it, run it
Operating OPNFV: Deploy it, test it, run itOperating OPNFV: Deploy it, test it, run it
Operating OPNFV: Deploy it, test it, run it
 
BayLISA - FreeNAS 10 by Jordan Hubbard
BayLISA - FreeNAS 10 by Jordan HubbardBayLISA - FreeNAS 10 by Jordan Hubbard
BayLISA - FreeNAS 10 by Jordan Hubbard
 
JBoss AS 7 : Déployer sur terre et dans les nuages
JBoss AS 7 : Déployer sur terre et dans les nuagesJBoss AS 7 : Déployer sur terre et dans les nuages
JBoss AS 7 : Déployer sur terre et dans les nuages
 
Phoenix Servers with Docker and Nginx
Phoenix Servers with Docker and NginxPhoenix Servers with Docker and Nginx
Phoenix Servers with Docker and Nginx
 
Linker Wisdom
Linker WisdomLinker Wisdom
Linker Wisdom
 
OVN 設定サンプル | OVN config example 2015/12/27
OVN 設定サンプル | OVN config example 2015/12/27OVN 設定サンプル | OVN config example 2015/12/27
OVN 設定サンプル | OVN config example 2015/12/27
 
Learning Your Way Around Alfresco [A Developer's Intro, Part 1. by Jeff Potts]
Learning Your Way Around Alfresco [A Developer's Intro, Part 1. by Jeff Potts]Learning Your Way Around Alfresco [A Developer's Intro, Part 1. by Jeff Potts]
Learning Your Way Around Alfresco [A Developer's Intro, Part 1. by Jeff Potts]
 
IPS: Image Packaging System
IPS: Image Packaging SystemIPS: Image Packaging System
IPS: Image Packaging System
 
How to deploy PHP projects with docker
How to deploy PHP projects with dockerHow to deploy PHP projects with docker
How to deploy PHP projects with docker
 
Nfs
NfsNfs
Nfs
 
Jak se ^bonami\.(cz|pl|sk)$ vešlo do kontejneru
Jak se ^bonami\.(cz|pl|sk)$ vešlo do kontejneruJak se ^bonami\.(cz|pl|sk)$ vešlo do kontejneru
Jak se ^bonami\.(cz|pl|sk)$ vešlo do kontejneru
 
OpenSource Hardware -Debian Way
OpenSource Hardware -Debian WayOpenSource Hardware -Debian Way
OpenSource Hardware -Debian Way
 
Linux Survival Kit for Proof of Concept & Proof of Technology
Linux Survival Kit for Proof of Concept & Proof of TechnologyLinux Survival Kit for Proof of Concept & Proof of Technology
Linux Survival Kit for Proof of Concept & Proof of Technology
 
Local file systems update
Local file systems updateLocal file systems update
Local file systems update
 

Recently uploaded

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 

Recently uploaded (20)

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 

Bypat博客出品-手把手教你如何建立自己的linux系统lfs速成手册

  • 1. Linux LFS 2006 9 11 tar xvf 2006 9 11 2006 8 11 2006-03-27 2006-03-25 2006-03-24 2006-03-20 linux-Lib-Headers-2.6.11.2 linux-lib-headers-2.6.11.2 2006-03-17 2006-03-14 LFS LFS Linux LFS VMWare Workstation 5.0 WMWare VMWare VMWare LFS LFS www.linuxsir.org LFS Blog linuxsir http://www.linuxsir.org/bbs/showthread.php?t=244052 Blog http://youbest.cublog.cn youbest LiveCD ISO ( 6.1.1-3 ) http://ftp.osuosl.org/pub/lfs-livecd...86-6.1.1-3.iso ISO VMWare ISO VMWare Workstation 5.0 File->New->Virtual Machine... Custom Guest operating system Linux Version Other Linux 128M 256M 128M GCC3.x GCC4.0.x swap 256M swap Network connection Use network address translation(NAT) SCSI Adpters Buslogic Create a new virtual disk Virtual Disk Type IDE SCSI
  • 2. SCSI B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m IDE SCSI SCSI Adpters Buslogic Buslogic 4G LFS BLFS Edit virtual machine settings CD-ROM Use ISO image LiveCD ISO Start this virtual machine LiveCD Asia/Shanghai LiveCD LFS LiveCD /usr/share/LFS-BOOK-6.1.1-HTML LFS /lfs-sources LFS cfdisk 512M /dev/sda1 swap /dev/sda2
  • 3. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m mkswap /dev/sda1 mkfs.xfs /dev/sda2 mkswap /dev/sda2 Xfs VMWare VMWare swapon /dev/sda1 swapon swapoff free LFS “ ” export LFS=/mnt/lfs mkdir -pv $LFS export LFS=/mnt/lfs “ ” LFS
  • 4. /dev/sda2 “ B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« ” h t t p : / / b l o g . b y p a t . c o m mount /dev/sda2 $LFS mkdir -v $LFS/sources chmod -v a+wt $LFS/sources chmod a+wt 777 mkdir -v $LFS/tools ln -sv $LFS/tools / /tools lfs groupadd lfs useradd -s /bin/bash -g lfs -m -k /dev/null lfs lfs passwd lfs tools sources lfs lfs chown -v lfs $LFS/tools chown -v lfs $LFS/sources lfs su - lfs # $ lfs root root LFS lfs lfs cat > ~/.bash_profile << "EOF"
  • 5. exec env -i HOME=$HOME TERM=$TERM PS1='u:w$ ' /bin/bash B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m 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 bash lfs PATH /tools/bin /bin /usr/bin /bin /usr/bin /tools/bin LFS Stripping 1. LiveCD VMWare F2 BIOS BOOT CD-ROM
  • 6. 2. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m 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" 8. cd $LFS/sources LFS cd $LFS/sources Binutils-2.15.94.0.2.2 - Pass 1 tar xvf /lfs-sources/binutils-2.15.94.0.2.2.tar.bz2
  • 7. cd binutils-2.15.94.0.2.2 B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m tar xvf bz2 gz tar tar bz2 j gz z binutils tar xvjf /lfs-sources/binutils-2.15.94.0.2.2.tar.bz2 LFS LiveCD tar tar tar xvf GCC4 GCC4 LFS-6.1.1-3 LiveCD GCC 3.4.3 patch -Np1 -i /lfs-sources/binutils-2.15.94.0.2.2-gcc4-1.patch binutils mkdir -v ../binutils-build cd ../binutils-build ../binutils-2.15.94.0.2.2/configure --prefix=/tools --disable-nls make make install make -C ld clean make -C ld LIB_PATH=/tools/lib cd .. binutils-build binutils- build binutils binutils-2.16.1 binutils-2.15.94.0.2.2 GCC-3.4.3 - Pass 1 tar xvf /lfs-sources/gcc-3.4.3.tar.bz2 mkdir -v gcc-build cd gcc-build ../gcc-3.4.3/configure --prefix=/tools --libexecdir=/tools/lib --with-local-prefix=/tools --disable-nls --enable-shared --enable-languages=c make bootstrap make install ln -vs gcc /tools/bin/cc cd .. rm -rf gcc-build rm -rf gcc-3.4.3 gcc-3.4.3
  • 8. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m gcc-3.4.4 gcc-3.4.5 gcc-3.4.3 GCC4.0.x gcc-3.4.x GCC4.0.x LFS Linux-Libc-Headers-2.6.11.2 tar xvf /lfs-sources/linux-libc-headers-2.6.11.2.tar.bz2 cd linux-libc-headers-2.6.11.2 cp -Rv include/asm-i386 /tools/include/asm cp -Rv include/linux /tools/include cd .. rm -rf linux-libc-headers-2.6.11.2 Glibc-2.3.4 tar xvf /lfs-sources/glibc-2.3.4.tar.bz2 cd glibc-2.3.4 patch -Np1 -i /lfs-sources/glibc-2.3.4-fix_test-1.patch mkdir -v ../glibc-build cd ../glibc-build ../glibc-2.3.4/configure --prefix=/tools --disable-profile --enable-add-ons --enable-kernel=2.6.0 --with-binutils=/tools/bin --without-gd --with-headers=/tools/include --without-selinux make mkdir -v /tools/etc touch /tools/etc/ld.so.conf make install make localedata/install-locales cd .. rm -rf glibc-build rm -rf glibc-2.3.4 glibc-2.3.4 GCC4 gcc-3.4.x glibc-2.3.6 GCC4 --enable-kernel=2.6.0 kernel kernel linux- 2.6.15 2.6.0 make localedata/install-locales locale locale localedef LFS locale mkdir -pv /tools/lib/locale localedef -i zh_CN -f GB18030 zh_CN localedef -i zh_CN -f GBK zh_CN localedef -i zh_CN -f UTF-8 zh_CN localedef -i zh_CN -f GB2312 zh_CN localedef -i zh_HK -f UTF-8 zh_CN localedef -i zh_HK -f BIG5-HKSCS zh_CN localedef -i zh_TW -f EUC-TW zh_CN
  • 9. localedef -i zh_TW -f UTF-8 zh_CN B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m localedef -i zh_TW -f BIG5 zh_CN cd binutils-build make -C ld install cd .. rm -rf binutils-build rm -rf binutils-2.15.94.0.2.2 SPECFILE=$(gcc --print-file specs) && sed 's@ /lib/ld-linux.so.2@ /tools/lib/ld-linux.so.2@g' $SPECFILE > tempspecfile && mv -f tempspecfile $SPECFILE && unset SPECFILE rm -vf /tools/lib/gcc/*/*/include/{pthread.h,bits/sigthread.h} binutils-build make -C ld install GCC specs specs /lib/ld-linux.so.2 /tools/lib/ld-linux.so.2 LFS specs GCC4.0.x specs specs GCC4.0.1 LFS echo 'main(){}' > dummy.c cc dummy.c readelf -l a.out | grep ': /tools' [Requesting program interpreter: /tools/lib/ld-linux.so.2] /tools/lib rm -rf a.out dummy.c 3 make check 3 Tcl-8.4.9 Expect-5.43.0 DejaGNU-1.4.4 tar xvf /lfs-sources/tcl8.4.9-src.tar.bz2 cd tcl8.4.9/unix ./configure --prefix=/tools make make install cd .. export TCLPATH=$(pwd) ln -sv tclsh8.4 /tools/bin/tclsh cd .. tar xvf /lfs-sources/expect-5.43.0.tar.bz2 cd expect-5.43 patch -Np1 -i /lfs-sources/expect-5.43.0-spawn-1.patch ./configure --prefix=/tools --with-tcl=/tools/lib --with-tclinclude=$TCLPATH --with- x=no make make SCRIPTS="" install unset TCLPATH
  • 10. cd .. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m tar xvf /lfs-sources/dejagnu-1.4.4.tar.bz2 cd dejagnu-1.4.4 ./configure --prefix=/tools make install cd .. rm -rf tcl8.4.9 rm -rf expect-5.43 GCC-3.4.3 - Pass 2 tar xvf /lfs-sources/gcc-3.4.3.tar.bz2 cd gcc-3.4.3 patch -Np1 -i /lfs-sources/gcc-3.4.3-no_fixincludes-1.patch patch -Np1 -i /lfs-sources/gcc-3.4.3-specs-2.patch mkdir -v ../gcc-build cd ../gcc-build ../gcc-3.4.3/configure --prefix=/tools --libexecdir=/tools/lib --with-local-prefix=/tools --enable-clocale=gnu --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-languages=c,c++ --disable-libstdcxx-pch make make install cd .. rm -rf gcc-build rm -rf gcc-3.4.3 Binutils-2.15.94.0.2.2 - Pass 2 tar xvf /lfs-sources/binutils-2.15.94.0.2.2.tar.bz2 mkdir -v binutils-build cd binutils-build ../binutils-2.15.94.0.2.2/configure --prefix=/tools --disable-nls --enable-shared --with-lib-path=/tools/lib make make install make -C ld clean make -C ld LIB_PATH=/usr/lib:/lib cd .. binutils-build Gawk-3.1.4 tar xvf /lfs-sources/gawk-3.1.4.tar.bz2 cd gawk-3.1.4 ./configure --prefix=/tools make make install
  • 11. cd .. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m rm -rf gawk-3.1.4 Coreutils-5.2.1 tar xvf /lfs-sources/coreutils-5.2.1.tar.bz2 cd coreutils-5.2.1 DEFAULT_POSIX2_VERSION=199209 ./configure --prefix=/tools make make install cd .. rm -rf coreutils-5.2.1 Bzip2-1.0.3 tar xvf /lfs-sources/bzip2-1.0.3.tar.bz2 cd bzip2-1.0.3 make make PREFIX=/tools install cd .. rm -rf bzip2-1.0.3 Gzip-1.3.5 tar xvf /lfs-sources/gzip-1.3.5.tar.bz2 cd gzip-1.3.5 ./configure --prefix=/tools make make install cd .. rm -rf gzip-1.3.5 Diffutils-2.8.1 tar xvf /lfs-sources/diffutils-2.8.1.tar.bz2 cd diffutils-2.8.1 ./configure --prefix=/tools make make install cd .. rm -rf diffutils-2.8.1 Findutils-4.2.23
  • 12. tar xvf /lfs-sources/findutils-4.2.23.tar.bz2 B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m cd findutils-4.2.23 ./configure --prefix=/tools make make install cd .. rm -rf findutils-4.2.23 Make-3.80 tar xvf /lfs-sources/make-3.80.tar.bz2 cd make-3.80 ./configure --prefix=/tools make make install cd .. rm -rf make-3.80 Grep-2.5.1a tar xvf /lfs-sources/grep-2.5.1a.tar.bz2 cd grep-2.5.1a ./configure --prefix=/tools --disable-perl-regexp make make install cd .. rm -rf grep-2.5.1a Sed-4.1.4 tar xvf /lfs-sources/sed-4.1.4.tar.bz2 cd sed-4.1.4 ./configure --prefix=/tools make make install cd .. rm -rf sed-4.1.4 Gettext-0.14.3 tar xvf /lfs-sources/gettext-0.14.3.tar.bz2 cd gettext-0.14.3 ./configure --prefix=/tools --disable-libasprintf --without-csharp make make install
  • 13. cd .. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m rm -rf gettext-0.14.3 Ncurses-5.4 tar xvf /lfs-sources/ncurses-5.4.tar.bz2 cd ncurses-5.4 ./configure --prefix=/tools --with-shared --without-debug --without-ada --enable- overwrite make make install cd .. rm -rf ncurses-5.4 Patch-2.5.4 tar xvf /lfs-sources/patch-2.5.4.tar.bz2 cd patch-2.5.4 CPPFLAGS=-D_GNU_SOURCE ./configure --prefix=/tools make make install cd .. rm -rf patch-2.5.4 Tar-1.15.1 tar xvf /lfs-sources/tar-1.15.1.tar.bz2 cd tar-1.15.1 ./configure --prefix=/tools make make install cd .. rm -rf tar-1.15.1 Texinfo-4.8 tar xvf /lfs-sources/texinfo-4.8.tar.bz2 cd texinfo-4.8 ./configure --prefix=/tools make make install cd .. rm -rf texinfo-4.8
  • 14. Bash-3.0 B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m tar xvf /lfs-sources/bash-3.0.tar.bz2 cd bash-3.0 patch -Np1 -i /lfs-sources/bash-3.0-avoid_WCONTINUED-1.patch ./configure --prefix=/tools --without-bash-malloc make make install ln -vs bash /tools/bin/sh cd .. rm -rf bash-3.0 M4-1.4.3 tar xvf /lfs-sources/m4-1.4.3.tar.bz2 cd m4-1.4.3 ./configure --prefix=/tools make make install cd .. rm -rf m4-1.4.3 Bison-2.0 tar xvf /lfs-sources/bison-2.0.tar.bz2 cd bison-2.0 ./configure --prefix=/tools make make install cd .. rm -rf bison-2.0 Flex-2.5.31 tar xvf /lfs-sources/flex-2.5.31.tar.bz2 cd flex-2.5.31 patch -Np1 -i /lfs-sources/flex-2.5.31-debian_fixes-3.patch touch doc/flex.1 ./configure --prefix=/tools make make install cd .. rm -rf flex-2.5.31 Util-linux-2.12q
  • 15. tar xvf /lfs-sources/util-linux-2.12q.tar.bz2 B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m cd util-linux-2.12q sed -i 's@/usr/include@/tools/include@g' configure ./configure make -C lib make -C mount mount umount make -C text-utils more cp mount/{,u}mount text-utils/more /tools/bin cd .. rm -rf util-linux-2.12q util-linux-2.12q GCC4 cfdisk util-linux-2.12r Perl-5.8.7 tar xvf /lfs-sources/perl-5.8.7.tar.bz2 cd perl-5.8.7 patch -Np1 -i /lfs-sources/perl-5.8.7-libc-1.patch ./configure.gnu --prefix=/tools -Dstatic_ext='IO Fcntl POSIX' make perl utilities cp -v perl pod/pod2man /tools/bin mkdir -pv /tools/lib/perl5/5.8.7 cp -Rv lib/* /tools/lib/perl5/5.8.7 cd .. rm -rf perl-5.8.7 Stripping /tools strip Strip strip --strip-debug /tools/lib/* strip --strip-unneeded /tools/{,s}bin/* info man rm -rf /tools/{info,man} lfs exit root #
  • 16. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m mkdir -pv $LFS/{proc,sys} 1. LiveCD 2. export LFS=/mnt/lfs mkdir -pv $LFS mount /dev/sda2 $LFS 3. swapon /dev/sda1 tools mount -vt proc proc $LFS/proc mount -vt sysfs sysfs $LFS/sys LFS mount -vft tmpfs tmpfs $LFS/dev mount -vft tmpfs tmpfs $LFS/dev/shm mount -vft devpts -o gid=4,mode=620 devpts $LFS/dev/pts mount mkdir $LFS/cdrom mount /dev/cdrom $LFS/cdrom lfs-sources $LFS/sources cp -a /lfs-sources/* $LFS/sources 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
  • 17. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m 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 lfs root 0 root chown -R 0:0 /tools install -dv /{bin,boot,dev,etc/opt,home,lib,mnt} install -dv /{sbin,srv,usr/local,var,opt} install -dv /root -m 0750 install -dv /tmp /var/tmp -m 1777 install -dv /media/{floppy,cdrom} install -dv /usr/{bin,include,lib,sbin,share,src} ln -sv share/{man,doc,info} /usr install -dv /usr/share/{doc,info,locale,man} install -dv /usr/share/{misc,terminfo,zoneinfo} install -dv /usr/share/man/man{1,2,3,4,5,6,7,8} install -dv /usr/local/{bin,etc,include,lib,sbin,share,src} ln -sv share/{man,doc,info} /usr/local install -dv /usr/local/share/{doc,info,locale,man} install -dv /usr/local/share/{misc,terminfo,zoneinfo} install -dv /usr/local/share/man/man{1,2,3,4,5,6,7,8} install -dv /var/{lock,log,mail,run,spool} install -dv /var/{opt,cache,lib/{misc,locate},local} install -dv /opt/{bin,doc,include,info} install -dv /opt/{lib,man/man{1,2,3,4,5,6,7,8}} ln -sv /tools/bin/{bash,cat,pwd,stty} /bin
  • 18. ln -sv /tools/bin/perl /usr/bin B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib ln -sv bash /bin/sh root cat > /etc/passwd << "EOF" root:x:0:0:root:/root:/bin/bash EOF cat > /etc/group << "EOF" root:x:0: bin:x:1: sys:x:2: kmem:x:3: tty:x:4: tape:x:5: daemon:x:6: floppy:x:7: disk:x:8: lp:x:9: dialout:x:10: audio:x:11: video:x:12: utmp:x:13: usb:x:14: cdrom:x:15: EOF bash root “I have no name!” exec /tools/bin/bash --login +h touch /var/run/utmp /var/log/{btmp,lastlog,wtmp} chgrp -v utmp /var/run/utmp /var/log/lastlog chmod -v 664 /var/run/utmp /var/log/lastlog
  • 19. mknod -m 600 /dev/console c 5 1 B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m mknod -m 666 /dev/null c 1 3 /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 cd /sources LFS /cdrom /cdrom/lfs-sources sources export LFS=/cdrom/lfs-sources sources export LFS=/sources File-4.13 Bash-3.0 1. LiveCD 2.
  • 20. export LFS=/mnt/lfs B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m 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 export LFS=/sources Linux-Libc-Headers-2.6.11.2 tar xvf $LFS/linux-libc-headers-2.6.11.2.tar.bz2 cd linux-libc-headers-2.6.11.2 cp -Rv include/asm-i386 /usr/include/asm cp -Rv include/linux /usr/include chown -Rv root:root /usr/include/{asm,linux} find /usr/include/{asm,linux} -type d -exec chmod -v 755 {} ; find /usr/include/{asm,linux} -type f -exec chmod -v 644 {} ; cd .. rm -rf linux-libc-headers-2.6.11.2 Man-pages-2.01 tar xvf $LFS/man-pages-2.01.tar.bz2 cd man-pages-2.01
  • 21. make install B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m cd .. rm -rf man-pages-2.01 man-pages 2.01 Glibc-2.3.4 glibc-2.3.4 glibc-build tar xvf $LFS/glibc-2.3.4.tar.bz2 cd glibc-2.3.4 tar -xjvf $LFS/glibc-linuxthreads-2.3.4.tar.bz2 patch -Np1 -i $LFS/glibc-2.3.4-rtld_search_dirs-1.patch patch -Np1 -i $LFS/glibc-2.3.4-fix_test-1.patch patch -Np1 -i $LFS/glibc-2.3.4-tls_assert-1.patch mkdir -v ../glibc-build cd ../glibc-build ../glibc-2.3.4/configure --prefix=/usr --disable-profile --enable-add-ons --enable-kernel=2.6.0 --libexecdir=/usr/lib/glibc make make -k check >glibc-check-log 2>&1 grep Error glibc-check-log touch /etc/ld.so.conf make install make localedata/install-locales make -C ../glibc-2.3.4/linuxthreads/man make -C ../glibc-2.3.4/linuxthreads/man install cat > /etc/nsswitch.conf << "EOF" # Begin /etc/nsswitch.conf passwd: files group: files shadow: files hosts: files dns networks: files protocols: files services: files ethers: files rpc: files # End /etc/nsswitch.conf EOF cp -v --remove-destination /usr/share/zoneinfo/Asia/Shanghai /etc/localtime cat > /etc/ld.so.conf << "EOF"
  • 22. /usr/local/lib B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m /opt/lib EOF cd .. rm -rf glibc-build rm -rf glibc-2.3.4 glibc LFS cd binutils-build make -C ld INSTALL=/tools/bin/install install cd .. rm -rf binutils-build rm -rf binutils-2.15.94.0.2.2 binutils LFS binutils tar xvf $LFS/binutils-2.15.94.0.2.2.tar.bz2 mkdir binutils-build cd binutils-build ../binutils-2.15.94.0.2.2/configure --prefix=/tools --disable-nls --enable-shared --with-lib-path=/tools/lib make make -C ld clean make -C ld LIB_PATH=/usr/lib:/lib make -C ld INSTALL=/tools/bin/install install cd .. rm -rf binutils-build rm -rf binutils-2.15.94.0.2.2 specs perl -pi -e 's@ /tools/lib/ld-linux.so.2@ /lib/ld-linux.so.2@g;' -e 's@*startfile_prefix_spec:n@$_/usr/lib/ @g;' $(gcc --print-file specs)
  • 23. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m echo 'main(){}' > dummy.c cc dummy.c readelf -l a.out | grep ': /lib' [Requesting program interpreter: /lib/ld-linux.so.2] /lib rm -v dummy.c a.out Binutils-2.15.94.0.2.2 tar xvf $LFS/binutils-2.15.94.0.2.2.tar.bz2 mkdir binutils-build cd binutils-build ../binutils-2.15.94.0.2.2/configure --prefix=/usr --enable-shared make tooldir=/usr make check check make tooldir=/usr install cp -v ../binutils-2.15.94.0.2.2/include/libiberty.h /usr/include cd .. rm -rf binutils-build rm -rf binutils-2.15.94.0.2.2 GCC-3.4.3 tar xvf $LFS/gcc-3.4.3.tar.bz2 cd gcc-3.4.3 patch -Np1 -i $LFS/gcc-3.4.3-no_fixincludes-1.patch patch -Np1 -i $LFS/gcc-3.4.3-linkonce-1.patch sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in mkdir -v ../gcc-build cd ../gcc-build ../gcc-3.4.3/configure --prefix=/usr --libexecdir=/usr/lib --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++ make
  • 24. make -k check B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m check make install ln -sv ../usr/bin/cpp /lib ln -sv gcc /usr/bin/cc cd .. rm -rf gcc-build rm -rf gcc-3.4.3 Coreutils-5.2.1 tar xvf $LFS/coreutils-5.2.1.tar.bz2 cd coreutils-5.2.1 patch -Np1 -i $LFS/coreutils-5.2.1-uname-2.patch patch -Np1 -i $LFS/coreutils-5.2.1-suppress_uptime_kill_su-1.patch DEFAULT_POSIX2_VERSION=199209 ./configure --prefix=/usr make echo "dummy1:x:1000:" >> /etc/group echo "dummy2:x:1001:dummy" >> /etc/group echo "dummy:x:1000:1000:::/bin/bash" >> /etc/passwd make NON_ROOT_USERNAME=dummy check-root src/su dummy -c "make RUN_EXPENSIVE_TESTS=yes check" sed -i '/dummy/d' /etc/passwd /etc/group make install mv -v /usr/bin/{cat,chgrp,chmod,chown,cp,date,dd,df,echo} /bin mv -v /usr/bin/{false,hostname,ln,ls,mkdir,mknod,mv,pwd,rm} /bin mv -v /usr/bin/{rmdir,stty,sync,true,uname} /bin mv -v /usr/bin/chroot /usr/sbin mv -v /usr/bin/{head,sleep} /bin cd ..
  • 25. rm -rf coreutils-5.2.1 B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m Zlib-1.2.3 tar xvf $LFS/zlib-1.2.3.tar.bz2 cd zlib-1.2.3 ./configure --prefix=/usr --shared --libdir=/lib make make check check make install rm -v /lib/libz.so ln -sfv ../../lib/libz.so.1.2.3 /usr/lib/libz.so make clean ./configure --prefix=/usr make make check check make install chmod -v 644 /usr/lib/libz.a cd .. rm -rf zlib-1.2.3 Mktemp-1.5 tar xvf $LFS/mktemp-1.5.tar.bz2 cd mktemp-1.5
  • 26. patch -Np1 -i $LFS/mktemp-1.5-add_tempfile-2.patch B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m ./configure --prefix=/usr --with-libc make make install make install-tempfile cd .. rm -rf mktemp-1.5 Iana-Etc-1.04 tar xvf $LFS/iana-etc-1.04.tar.bz2 cd iana-etc-1.04 make make install cd .. rm -rf iana-etc-1.04 Findutils-4.2.23 tar xvf $LFS/findutils-4.2.23.tar.bz2 cd findutils-4.2.23 ./configure --prefix=/usr --libexecdir=/usr/lib/locate --localstatedir=/var/lib/locate make make check check make install cd .. rm -rf findutils-4.2.23 Gawk-3.1.4 tar xvf $LFS/gawk-3.1.4.tar.bz2 cd gawk-3.1.4 ./configure --prefix=/usr --libexecdir=/usr/lib make
  • 27. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m make check check make install cd .. rm -rf gawk-3.1.4 Ncurses-5.4 tar xvf $LFS/ncurses-5.4.tar.bz2 cd ncurses-5.4 ./configure --prefix=/usr --with-shared --without-debug make make install chmod -v 755 /usr/lib/*.5.4 chmod -v 644 /usr/lib/libncurses++.a mv -v /usr/lib/libncurses.so.5* /lib ln -sfv ../../lib/libncurses.so.5 /usr/lib/libncurses.so ln -sfv libncurses.so /usr/lib/libcurses.so cd .. rm -rf ncurses-5.4 Readline-5.0 tar xvf $LFS/readline-5.0.tar.bz2 cd readline-5.0 patch -Np1 -i $LFS/readline-5.0-fixes-1.patch ./configure --prefix=/usr --libdir=/lib make SHLIB_XLDFLAGS=-lncurses make install chmod -v 755 /lib/lib{readline,history}.so* mv -v /lib/lib{readline,history}.a /usr/lib rm -v /lib/lib{readline,history}.so ln -sfv ../../lib/libreadline.so.5 /usr/lib/libreadline.so ln -sfv ../../lib/libhistory.so.5 /usr/lib/libhistory.so cd .. rm -rf readline-5.0 Vim-6.3
  • 28. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m tar xvf $LFS/vim-6.3.tar.bz2 tar xvf $LFS/vim-6.3-lang.tar.gz cd vim63 echo '#define SYS_VIMRC_FILE "/etc/vimrc"' >> src/feature.h patch -Np1 -i $LFS/vim-6.3-security_fix-2.patch ./configure --prefix=/usr --enable-multibyte make make test test make install ln -sv vim /usr/bin/vi vim cat > /etc/vimrc << "EOF" " Begin /etc/vimrc set nocompatible set backspace=2 syntax on if (&term == "iterm") || (&term == "putty") set background=dark endif " End /etc/vimrc EOF cd .. rm -rf vim63 M4-1.4.3 tar xvf $LFS/m4-1.4.3.tar.bz2 cd m4-1.4.3
  • 29. ./configure --prefix=/usr B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m make make check check make install cd .. rm -rf m4-1.4.3 Bison-2.0 tar xvf $LFS/bison-2.0.tar.bz2 cd bison-2.0 ./configure --prefix=/usr make make check check make install cd .. rm -rf bison-2.0 Less-382 tar xvf $LFS/less-382.tar.bz2 cd less-382 ./configure --prefix=/usr --bindir=/bin --sysconfdir=/etc make
  • 30. make install B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m cd .. rm -rf less-382 Groff-1.19.1 tar xvf $LFS/groff-1.19.1.tar.bz2 cd groff-1.19.1 PAGE=A4 ./configure --prefix=/usr make make install ln -sv soelim /usr/bin/zsoelim ln -sv eqn /usr/bin/geqn ln -sv tbl /usr/bin/gtbl cd .. rm -rf groff-1.19.1 Sed-4.1.4 tar xvf $LFS/sed-4.1.4.tar.bz2 cd sed-4.1.4 sed -i 's@/doc@&/sed-4.1.4@' doc/Makefile.in ./configure --prefix=/usr --bindir=/bin make make check check make install cd .. rm -rf sed-4.1.4 Flex-2.5.31 tar xvf $LFS/flex-2.5.31.tar.bz2 cd flex-2.5.31 patch -Np1 -i $LFS/flex-2.5.31-debian_fixes-3.patch
  • 31. touch doc/flex.1 B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m ./configure --prefix=/usr make make check check make install ln -sv libfl.a /usr/lib/libl.a lex cat > /usr/bin/lex << "EOF" #!/bin/sh # Begin /usr/bin/lex exec /usr/bin/flex -l "$@" # End /usr/bin/lex EOF chmod -v 755 /usr/bin/lex cd .. rm -rf flex-2.5.31 Gettext-0.14.3 tar xvf $LFS/gettext-0.14.3.tar.bz2 cd gettext-0.14.3 ./configure --prefix=/usr make
  • 32. make check B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m check make install cd .. rm -rf gettext-0.14.3 Inetutils-1.4.2 tar xvf $LFS/inetutils-1.4.2.tar.bz2 cd inetutils-1.4.2 patch -Np1 -i $LFS/inetutils-1.4.2-kernel_headers-1.patch patch -Np1 -i $LFS/inetutils-1.4.2-no_server_man_pages-1.patch ./configure --prefix=/usr --libexecdir=/usr/sbin --sysconfdir=/etc --localstatedir=/var --disable-logger --disable-syslogd --disable-whois --disable-servers make make install mv -v /usr/bin/ping /bin cd .. rm -rf inetutils-1.4.2 IPRoute2-2.6.11-050330 tar xvf $LFS/iproute2-2.6.11-050330.tar.bz2 cd iproute2-2.6.11 sed -i '/^TARGETS/s@arpd@@g' misc/Makefile ./configure make SBINDIR=/sbin make SBINDIR=/sbin install cd .. rm -rf iproute2-2.6.11 Perl-5.8.7 tar xvf $LFS/perl-5.8.7.tar.bz2 cd perl-5.8.7 ./configure.gnu --prefix=/usr -Dpager="/bin/less -isR" make
  • 33. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m echo "127.0.0.1 localhost $(hostname)" > /etc/hosts make test test make install cd .. rm -rf perl-5.8.7 Texinfo-4.8 tar xvf $LFS/texinfo-4.8.tar.bz2 cd texinfo-4.8 patch -Np1 -i $LFS/texinfo-4.8-tempfile_fix-1.patch ./configure --prefix=/usr make make check check make install make TEXMF=/usr/share/texmf install-tex cd /usr/share/info rm dir for f in * do install-info $f dir 2>/dev/null done
  • 34. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m cd /sources rm -rf texinfo-4.8 Autoconf-2.59 tar xvf $LFS/autoconf-2.59.tar.bz2 cd autoconf-2.59 ./configure --prefix=/usr make make check check make install cd .. rm -rf autoconf-2.59 Automake-1.9.5 tar xvf $LFS/automake-1.9.5.tar.bz2 cd automake-1.9.5 ./configure --prefix=/usr make make check check 3 make install
  • 35. cd .. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m rm -rf automake-1.9.5 Bash-3.0 tar xvf $LFS/bash-3.0.tar.bz2 cd bash-3.0 tar -xvf $LFS/bash-doc-3.0.tar.bz2 && sed -i "s|htmldir = @htmldir@|htmldir = /usr/share/doc/bash-3.0|" Makefile.in patch -Np1 -i $LFS/bash-3.0-fixes-3.patch patch -Np1 -i $LFS/bash-3.0-avoid_WCONTINUED-1.patch ./configure --prefix=/usr --bindir=/bin --without-bash-malloc --with-installed-readline make make check check make install cd .. rm -rf bash-3.0 /bin/bash exec /bin/bash --login +h 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
  • 36. mount -vt sysfs sysfs $LFS/sys B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m 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 export LFS=/sources File-4.13 tar xvf $LFS/file-4.13.tar.bz2 cd file-4.13 ./configure --prefix=/usr make make install cd .. rm -rf file-4.13 Libtool-1.5.14 tar xvf $LFS/libtool-1.5.14.tar.bz2 cd libtool-1.5.14 ./configure --prefix=/usr make make check
  • 37. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m check make install cd .. rm -rf libtool-1.5.14 Bzip2-1.0.3 tar xvf $LFS/bzip2-1.0.3.tar.bz2 cd bzip2-1.0.3 patch -Np1 -i $LFS/bzip2-1.0.3-install_docs-1.patch patch -Np1 -i $LFS/bzip2-1.0.3-bzgrep_security-1.patch make -f Makefile-libbz2_so make clean make make install cp -v bzip2-shared /bin/bzip2 cp -av libbz2.so* /lib ln -sv ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so rm -v /usr/bin/{bunzip2,bzcat,bzip2} ln -sv bzip2 /bin/bunzip2 ln -sv bzip2 /bin/bzcat cd .. rm -rf bzip2-1.0.3 Diffutils-2.8.1 tar xvf $LFS/diffutils-2.8.1.tar.bz2 cd diffutils-2.8.1 ./configure --prefix=/usr make make install cd .. rm -rf diffutils-2.8.1 Kbd-1.12 tar xvf $LFS/kbd-1.12.tar.bz2 cd kbd-1.12 ./configure make make install
  • 38. cd .. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m rm -rf kbd-1.12 E2fsprogs-1.37 tar xvf $LFS/e2fsprogs-1.37.tar.bz2 cd e2fsprogs-1.37 sed -i -e 's/-DTEST/$(ALL_CFLAGS) &/' lib/e2p/Makefile.in mkdir -v build cd build ../configure --prefix=/usr --with-root-prefix="" --enable-elf-shlibs --disable-evms make make check check make install make install-libs cd ../.. rm -rf e2fsprogs-1.37 Grep-2.5.1a tar xvf $LFS/grep-2.5.1a.tar.bz2 cd grep-2.5.1a ./configure --prefix=/usr --bindir=/bin make make check check
  • 39. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m make install cd .. rm -rf grep-2.5.1a GRUB-0.96 tar xvf $LFS/grub-0.96.tar.bz2 cd grub-0.96 ./configure --prefix=/usr make make check check “ufs2_stage1_5 is too big” make install mkdir -v /boot/grub cp -v /usr/lib/grub/i386-pc/stage{1,2} /boot/grub cd .. rm -rf grub-0.96 Gzip-1.3.5 tar xvf $LFS/gzip-1.3.5.tar.bz2 cd gzip-1.3.5 patch -Np1 -i $LFS/gzip-1.3.5-security_fixes-1.patch ./configure --prefix=/usr sed -i 's@"BINDIR"@/bin@g' gzexe.in make make install mv -v /usr/bin/gzip /bin rm -v /usr/bin/{gunzip,zcat} ln -sv gzip /bin/gunzip ln -sv gzip /bin/zcat ln -sv gzip /bin/compress ln -sv gunzip /bin/uncompress cd .. rm -rf gzip-1.3.5
  • 40. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m Hotplug-2004_09_23 tar xvf $LFS/hotplug-2004_09_23.tar.bz2 cd hotplug-2004_09_23 make install cp -v etc/hotplug/pnp.distmap /etc/hotplug rm -rfv /etc/init.d rm -fv /etc/hotplug/net.agent mkdir -v /lib/firmware cd .. rm -rf hotplug-2004_09_23 Man-1.5p tar xvf $LFS/man-1.5p.tar.bz2 cd man-1.5p sed -i 's@-is@&R@g' configure sed -i 's@MANPATH./usr/man@#&@g' src/man.conf.in ./configure -confdir=/etc make make install cd .. rm -rf man-1.5p Make-3.80 tar xvf $LFS/make-3.80.tar.bz2 cd make-3.80 ./configure --prefix=/usr make make check check make install cd .. rm -rf make-3.80
  • 41. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m Module-Init-Tools-3.1 tar xvf $LFS/module-init-tools-3.1.tar.bz2 tar xvf $LFS/module-init-tools-testsuite-3.1.tar.bz2 cd module-init-tools-3.1 touch modprobe.conf.5 ./configure make check make distclean ./configure --prefix="" --enable-zlib make make install cd .. rm -rf module-init-tools-3.1 Patch-2.5.4 tar xvf $LFS/patch-2.5.4.tar.bz2 cd patch-2.5.4 CPPFLAGS=-D_GNU_SOURCE ./configure --prefix=/usr make make install cd .. rm -rf patch-2.5.4 Procps-3.2.5 tar xvf $LFS/procps-3.2.5.tar.bz2 cd procps-3.2.5 make make install cd .. rm -rf procps-3.2.5 Psmisc-21.6 tar xvf $LFS/psmisc-21.6.tar.bz2 cd psmisc-21.6 ./configure --prefix=/usr --exec-prefix="" make make install mv -v /bin/pstree* /usr/bin ln -sv killall /bin/pidof
  • 42. cd .. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m rm -rf psmisc-21.6 Shadow-4.0.9 tar xvf $LFS/shadow-4.0.9.tar.bz2 cd shadow-4.0.9 ./configure --libdir=/lib --enable-shared sed -i 's/groups$(EXEEXT) //' src/Makefile sed -i '/groups/d' man/Makefile make make install cp -v etc/{limits,login.access} /etc sed -e's@#MD5_CRYPT_ENAB.no@MD5_CRYPT_ENAB yes@' -e 's@/var/spool/mail@/var/mail@' etc/login.defs.linux > /etc/login.defs mv -v /usr/bin/passwd /bin mv -v /lib/libshadow.*a /usr/lib rm -v /lib/libshadow.so ln -sfv ../../lib/libshadow.so.0 /usr/lib/libshadow.so mkdir -v /etc/default pwconv grpconv passwd root root cd .. rm -rf shadow-4.0.9 Sysklogd-1.4.1 tar xvf $LFS/sysklogd-1.4.1.tar.bz2 cd sysklogd-1.4.1 patch -Np1 -i $LFS/sysklogd-1.4.1-fixes-1.patch make make install syslog cat > /etc/syslog.conf << "EOF" # Begin /etc/syslog.conf auth,authpriv.* -/var/log/auth.log *.*;auth,authpriv.none -/var/log/sys.log daemon.* -/var/log/daemon.log
  • 43. kern.* -/var/log/kern.log B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m mail.* -/var/log/mail.log user.* -/var/log/user.log *.emerg * # log the bootscript output: local2.* -/var/log/boot.log # End /etc/syslog.conf EOF cd .. rm -rf sysklogd-1.4.1 Sysvinit-2.86 tar xvf $LFS/sysvinit-2.86.tar.bz2 cd sysvinit-2.86 sed -i 's@Sending processes@& started by init@g' src/init.c make -C src make -C src install cat > /etc/inittab << "EOF" # Begin /etc/inittab id:3:initdefault: si::sysinit:/etc/rc.d/init.d/rc sysinit l0:0:wait:/etc/rc.d/init.d/rc 0 l1:S1:wait:/etc/rc.d/init.d/rc 1 l2:2:wait:/etc/rc.d/init.d/rc 2 l3:3:wait:/etc/rc.d/init.d/rc 3 l4:4:wait:/etc/rc.d/init.d/rc 4 l5:5:wait:/etc/rc.d/init.d/rc 5 l6:6:wait:/etc/rc.d/init.d/rc 6 ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now su:S016:once:/sbin/sulogin 1:2345:respawn:/sbin/agetty -I '033(K' tty1 9600 2:2345:respawn:/sbin/agetty -I '033(K' tty2 9600 3:2345:respawn:/sbin/agetty -I '033(K' tty3 9600
  • 44. 4:2345:respawn:/sbin/agetty -I '033(K' tty4 9600 B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m 5:2345:respawn:/sbin/agetty -I '033(K' tty5 9600 6:2345:respawn:/sbin/agetty -I '033(K' tty6 9600 # End /etc/inittab EOF cd .. rm -rf sysvinit-2.86 Tar-1.15.1 tar xvf $LFS/tar-1.15.1.tar.bz2 cd tar-1.15.1 patch -Np1 -i $LFS/tar-1.15.1-sparse_fix-1.patch ./configure --prefix=/usr --bindir=/bin --libexecdir=/usr/sbin make make check check make install cd .. rm -rf tar-1.15.1 Udev-056 tar xvf $LFS/udev-056.tar.bz2 cd udev-056 make udevdir=/dev make test
  • 45. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m test make DESTDIR=/ udevdir=/dev install cp -v $LFS/udev-config-4.rules /etc/udev/rules.d/25-lfs.rules /sbin/udevstart cd .. rm -rf udev-056 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 export LFS=/sources Util-linux-2.12q tar xvf $LFS/util-linux-2.12q.tar.bz2 cd util-linux-2.12q sed -i 's@etc/adjtime@var/lib/hwclock/adjtime@g' hwclock/hwclock.c mkdir -p /var/lib/hwclock patch -Np1 -i $LFS/util-linux-2.12q-cramfs-1.patch patch -Np1 -i $LFS/util-linux-2.12q-umount_fix-1.patch ./configure
  • 46. make HAVE_KILL=yes HAVE_SLN=yes B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m make HAVE_KILL=yes HAVE_SLN=yes install mv /usr/bin/logger /bin cd .. rm -rf util-linux-2.12q util-linux-2.12q GCC4 Bug util-linux-2.12r chroot logout Strip 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 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 export LFS=/sources
  • 47. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m Strip /tools/bin/find /{,usr/}{bin,lib,sbin} -type f -exec /tools/bin/strip --strip-debug '{}' ';' chroot logout chroot chroot "$LFS" /usr/bin/env -i HOME=/root TERM="$TERM" PS1='u:w$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/bash --login 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 export LFS=/sources LFS-Bootscripts-3.2.1
  • 48. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m tar xvf lfs-bootscripts-3.2.1.tar.bz2 cd lfs-bootscripts-3.2.1 make install cd .. rm -rf lfs-bootscripts-3.2.1 Configuring the setclock Script cat > /etc/sysconfig/clock << "EOF" # Begin /etc/sysconfig/clock UTC=1 # End /etc/sysconfig/clock EOF bash cat > /etc/inputrc << "EOF" set horizontal-scroll-mode Off set meta-flag On set input-meta On set convert-meta Off set output-meta On set bell-style none "eOd": backward-word "eOc": forward-word "e[1~": beginning-of-line "e[4~": end-of-line "e[5~": beginning-of-history "e[6~": end-of-history "e[3~": delete-char "e[2~": quoted-insert "eOH": beginning-of-line "eOF": end-of-line "e[H": beginning-of-line "e[F": end-of-line EOF Bash Shell The Bash Shell Startup Files cat > /etc/profile << "EOF" # Begin /etc/profile export LANG=zh_CN.GB18030
  • 49. export INPUTRC=/etc/inputrc # End /etc/profile EOF echo "HOSTNAME=mylinux" > /etc/sysconfig/network hosts cat > /etc/hosts << "EOF" # Begin /etc/hosts (no network card version) 127.0.0.1 mylinux localhost # End /etc/hosts (no network card version) EOF cd /etc/sysconfig/network-devices && mkdir -v ifconfig.eth0 && cat > ifconfig.eth0/ipv4 << "EOF" ONBOOT=yes SERVICE=ipv4-static IP=192.168.1.1 GATEWAY=192.168.1.2 PREFIX=24 BROADCAST=192.168.1.255 EOF IP GATEWAY BROADCAST DNS cat > /etc/resolv.conf << "EOF" # Begin /etc/resolv.conf nameserver DNS nameserver DNS # End /etc/resolv.conf
  • 50. EOF B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m fstab cat > /etc/fstab << "EOF" # Begin /etc/fstab # file system mount-point type options dump fsck # order /dev/sda2 / xfs defaults 1 1 /dev/sda1 swap swap pri=1 0 0 proc /proc proc defaults 0 0 sysfs /sys sysfs defaults 0 0 devpts /dev/pts devpts gid=4,mode=620 0 0 shm /dev/shm tmpfs defaults 0 0 # End /etc/fstab EOF Linux-2.6.11.12 cd /sources tar xvf linux-2.6.11.12.tar.bz2 cd linux-2.6.11.12 make mrproper make menuconfig VMWare5.0 loop Device Drivers->Block devices Loopback device support Cryptoloop Support
  • 51. SCSI Device Drivers->SCSI device support->SCSI low-level drivers BusLogic SCSI support initrd Device Drivers->Networking support->Ethernet (10 or 100Mbit) AMD PCnet32 PCI support
  • 52. B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m Device Drivers->Sound->Advanced Linux Sound Architecture->PCI devices (Creative) Ensoniq AudioPCI 1371/1373 Xfs File Systems->XFS support XFS initrd make make modules_install
  • 53. cp -v arch/i386/boot/bzImage /boot/lfskernel-2.6.11.12 B y p a tSZ[¢N lèNŽ l i n u x•Dn•R N« h t t p : / / b l o g . b y p a t . c o m cp -v System.map /boot/System.map-2.6.11.12 cp -v .config /boot/config-2.6.11.12 Grub grub root (hd0,1) setup (hd0) quit grub cat > /boot/grub/menu.lst << "EOF" # Begin /boot/grub/menu.lst # By default boot the first menu entry. default 0 # Allow 30 seconds before booting the default. timeout 30 # Use prettier colors. color green/black light-green/black # The first entry is for LFS. title LFS 6.1.1 root (hd0,1) kernel /boot/lfskernel-2.6.11.12 root=/dev/sda2 EOF root menu.lst /etc mkdir -v /etc/grub ln -sv /boot/grub/menu.lst /etc/grub logout