66,安装文件类型查询工具(file)
- cd /sources
- tar xvf file-4.21.tar.gz
- cd file-4.21
- /configure --prefix=/usr
- make
- make install
- cd ..
- rm -rf file-4.21
67,安装查找工具(findutils)
- cd /sources
- tar xvf findutils-4.2.31.tar.gz
- cd findutils-4.2.31
- /configure --prefix=/usr --libexecdir=/usr/lib/findutils \
- --localstatedir=/var/lib/locate
- make
- make install
- mv -v /usr/bin/find /bin
- sed -i -e 's/find:=${BINDIR}/find:=\/bin/' /usr/bin/updatedb
- cd ..
- rm -rf findutils-4.2.31
67,安装查找工具(findutils)
- cd /sources
- tar xvf findutils-4.2.31.tar.gz
- cd findutils-4.2.31
- /configure --prefix=/usr --libexecdir=/usr/lib/findutils \
- --localstatedir=/var/lib/locate
- make
- make install
- mv -v /usr/bin/find /bin
- sed -i -e 's/find:=${BINDIR}/find:=\/bin/' /usr/bin/updatedb
- cd ..
- rm -rf findutils-4.2.31
68,安装程序生成工具(flex)
- cd /sources
- tar xvf flex-2.5.33.tar.bz2
- cd flex-2.5.33
- /configure --prefix=/usr
- make
- make install
- ln -sv libfl.a /usr/lib/libl.a
- cat > /usr/bin/lex <<EOF
- #!/bin/bash
- # Begin /usr/bin/lex
- exec /usr/bin/flex -l "$@"
- EOF
- chmod -v 755 /usr/bin/lex
- cd ..
- rm -rf flex-2.5.33
69,安装引导工具(grub)
- cd /sources
- tar xvf grub-0.97.tar.gz
- cd grub-0.97
- patch -Np1 -i /sources/grub-0.97-disk_geometry-1.patch
- /configure --prefix=/usr
- make
- make install
- mkdir /boot/grub
- cp /usr/lib/grub/i386-pc/stage{1,2} /boot/grub
- cd ..
- rm -rf grub-0.97
70,安装gawk
- cd /sources
- tar xvf gawk-3.1.5.tar.bz2
- cd gawk-3.1.5
- patch -Np1 -i /sources/gawk-3.1.5-segfault_fix-1.patch
- /configure --prefix=/usr --libexecdir=/usr/lib
- echo "#define HAVE_LANGINFO_CODESET 1" >>config.h
- echo "#define HAVE_LC_MESSAGES 1" >>config.h
- make
- make install
- cd ..
- rm -rf gawk-3.1.5
71,安装国际化语言支持工具(gettext)
- cd /sources
- tar xvf gettext-0.16.1.tar.gz
- cd gettext-0.16.1
- /configure --prefix=/usr
- make
- make install
- cd ..
- rm -rf gettext-0.16.1
72,安装文本过滤工具(grep)
- cd /sources
- tar xvf grep-2.5.1a.tar.bz2
- cd grep-2.5.1a
- patch -Np1 -i /sources/grep-2.5.1a-redhat_fixes-2.patch
- chmod +x tests/fmbtest.sh
- /configure --prefix=/usr --bindir=/bin
- make
- make install
- cd ..
- rm -rf grep-2.5.1a
73,安装格式化文件工具(groff)
- cd /sources
- tar xvf groff-1.18.1.4.tar.gz
- cd groff-1.18.1.4
- patch -Np1 -i /sources/groff-1.18.1.4-debian_fixes-1.patch
- sed -i -e 's/2010/002D/' -e 's/2212/002D/' \
- -e 's/2018/0060/' -e 's/2019/0027/' font/devutf8/R.proto
- PAGE=A4 ./configure --prefix=/usr --enable-multibyte
- make
- make install
- ln -sv eqn /usr/bin/geqn
- ln -sv tbl /usr/bin/gtbl
- cd ..
- rm -rf groff-1.18.1.4
74,安装压缩工具(gzip)
- cd /sources
- tar xvf gzip-1.3.12.tar.gz
- cd gzip-1.3.12
- /configure --prefix=/usr --bindir=/bin
- make
- make instlll
- mv -v /bin/{gzexe,uncompress,zcmp,zdiff,zegrep} /usr/bin
- mv -v /bin/{zfgrep,zforce,zgrep,zless,zmore,znew} /usr/bin
- cd ..
- rm -rf gzip-1.3.12
75,安装常用网络工具集(inetutils)
- cd /sources
- tar xvf inetutils-1.5.tar.gz
- cd inetutils-1.5
- patch -Np1 -i /sources/inetutils-1.5-no_server_man_pages-2.patch
- /configure --prefix=/usr --libexecdir=/usr/sbin \
- --sysconfdir=/etc --localstatedir=/var \
- --disable-ifconfig --disable-logger --disable-syslogd \
- --disable-whois --disable-servers
- make
- make install
- mv -v /usr/bin/ping /bin
- cd ..
- rm -rf inetutils-1.5
76,安装网络管理工具(iproute2)
- cd /sources
- tar xvf iproute2-2.6.20-070313.tar.gz
- cd iproute-2.6.20-070313
- sed -i -e '/tc-bfifo.8/d' -e '/tc-pfifo.8/s/pbfifo/bfifo/' Makefile
- make SBINDIR=/sbin
- make SBINDIR=/sbin install
- mv -v /sbin/arpd /usr/sbin
- cd ..
- rm -rf iproute-2.6.20-070313
77,安装键盘映射表工具(kbd)
- cd /sources
- tar xvf kbd-1.12.tar.bz2
- cd kbd-1.12
- patch -Np1 -i /sources/kbd-1.12-backspace-1.patch
- patch -Np1 -i /sources/kbd-1.12-gcc4_fixes-1.patch
- /configure --datadir=/lib/kbd
- make
- make install
- mv -v /usr/bin/{kbd_mode,openvt,setfont} /bin
- cd ..
- rm -rf kbd-1.12
78,安装文本查看工具(less)
- cd /sources
- tar xvf less-406.tar.gz
- cd less-406
- /configure --prefix=/usr --sysconfdir=/etc
- make
- make install
- cd ..
- rm -rf less-406
79,安装编译过程控制工具(make)
- cd /sources
- tar xvf make-3.81.tar.bz2
- cd make-3.81
- /configure --prefix=/usr
- make
- make install
- cd ..
- rm -rf make-3.81
80,安装帮助手册查看工具(man-db)
- cd /sources
- tar xvf man-db-2.4.4.tar.gz
- cd man-db-2.4.4
- mv man/de{_DE.88591,}
- mv man/es{_ES.88591,}
- mv man/it{_IT.88591,}
- sed -i 's,\*_\*,??,' man/Makefile.in
- sed -i -e '\%\t/usr/man%d' -e '\%\t/usr/local/man%d' src/man_db.conf.in
- cat >> include/manconfig.h.in << "EOF"
- #define WEB_BROWSER "exec /usr/bin/lynx"
- #define COL "/usr/bin/col"
- #define VGRIND "/usr/bin/vgrind"
- #define GRAP "/usr/bin/grap"
- EOF
- patch -Np1 -i /sources/man-db-2.4.4-fixes-1.patch
- /configure --prefix=/usr --enable-mb-groff --disable-setuid
- make
- make install
- cat >> convert-mans << "EOF"
- #!/bin/sh -e
- FROM="$1"
- TO="$2"
- shift ; shift
- while [ $# -gt 0 ]
- do
- FILE="$1"
- shift
- iconv -f "$FROM" -t "$TO" "$FILE" >.tmp.iconv
- mv .tmp.iconv "$FILE"
- done
- EOF
- install -m755 convert-mans /usr/bin
- cd ..
- rm -rf man-db-2.4.4
81,安装创建临时文件函数(mktemp)
- cd /sources
- tar xvf mktemp-1.5.tar.gz
- cd mktemp-1.5
- patch -Np1 -i /sources/mktemp-1.5-add_tempfile-3.patch
- /configure --prefix=/usr --with-libc
- make
- make install
- make install-tempfile
- cd ..
- rm -rf mktemp-1.5
82,安装内核模块管理工具(module-init-tools)
- cd /sources
- tar xvf module-init-tools-3.2.2.tar.bz2
- cd module-init-tools-3.2.2
- patch -Np1 -i /sources/module-init-tools-3.2.2-modprobe-1.patch
- /configure
- make distclean
- /configure --prefix=/ --enable-zlib
- make
- make INSTALL=install install
- cd ..
- rm -rf module-init-tools-3.2.2
83,安装打补丁工具(patch)
- cd /sources
- tar xvf patch-2.5.4.tar.gz
- cd patch-2.5.4
- /configure --prefix=/usr
- make
- make install
- cd ..
- rm -rf patch-2.5.4
84,安装进程管理工具(psmisc)
- cd /sources
- tar xvf psmisc-22.5.tar.gz
- cd psmisc-22.5
- /configure --prefix=/usr --exec-prefix=""
- make
- make install
- mv -v /bin/pstree* /usr/bin
- ln -sv killall /bin/pidof
- cd ..
- rm -rf psmisc-22.5
85,安装密码管理工具(shadow)
- cd /sources
- tar xvf shadow-4.0.18.1.tar.bz2
- cd shadow-4.0.18.1
- patch -Np1 -i /sources/shadow-4.0.18.1-useradd_fix-2.patch
- /configure --libdir=/lib --sysconfdir=/etc --enable-shared --without-selinux
- sed -i 's/groups$(EXEEXT) //' src/Makefile
- find man -name Makefile -exec sed -i 's/groups\.1 / /' {} \;
- sed -i -e 's@#MD5_CRYPT_ENAB.no@MD5_CRYPT_ENAB yes@' \
- -e 's@/var/spool/mail@/var/mail@' etc/login.defs
- make
- make install
- 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
- 配置添加用户默认设置,并给root用户配置密码
- pwconv
- grpconv
- useradd -D -b /home
- sed -i 's/yes/no/' /etc/default/useradd
- passwd root
- cd ..
- rm -rf shadow-4.0.18.1
86,安装系统日志记录工具(sysklogd)
- cd /sources
- tar xvf sysklogd-1.4.1.tar.gz
- cd sysklogd-1.4.1
- patch -Np1 -i /sources/sysklogd-1.4.1-fixes-2.patch
- patch -Np1 -i /sources/sysklogd-1.4.1-8bit-1.patch
- make
- make install
- 配置syslog
- cat > /etc/syslog.conf <<EOF
- auth,authpriv.* -/var/log/auth.log
- *.*;auth,authpriv.none -/var/log/sys.log
- daemon.* -/var/log/daemon.log
- kern.* -/var/log/kern.log
- mail.* -/var/log/mail.log
- user.* -/var/log/user.log
- *.emerg *
- EOF
- cd ..
- rm -rf sysklogd-1.4.1
87,安装开机过程控制工具(sysvinit)
- cd /sources
- tar xvf sysvinit-2.86.tar.gz
- cd sysvinit-2.86
- sed -i 's@Sending processes@& configured via /etc/inittab@g' src/init.c
- make -C src
- make -C src install
- 编辑启动配置文件
- cat > /etc/inittab <<EOF
- 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 tty1 9600
- 2:2345:respawn:/sbin/agetty tty2 9600
- 3:2345:respawn:/sbin/agetty tty3 9600
- 4:2345:respawn:/sbin/agetty tty4 9600
- 5:2345:respawn:/sbin/agetty tty5 9600
- 6:2345:respawn:/sbin/agetty tty6 9600
- EOF
- cd ..
- rm -rf sysvinit-2.86
88,安装打包工具(tar)
- cd /sources
- tar xvf tar-1.18.tar.bz2
- cd tar-1.18
- /configure --prefix=/usr --bindir=/bin --libexecdir=/usr/sbin
- make
- make install
- cd ..
- rm -rf tar-1.18
89,安装信息阅读工具(texinfo)
- cd /sources
- tar xvf texinfo-4.9.tar.bz2
- cd texinfo-4.9
- patch -Np1 -i /sources/texinfo-4.9-multibyte-1.patch
- patch -Np1 -i /sources/texinfo-4.9-tempfile_fix-1.patch
- /configure --prefix=/usr
- make
- make install
- make TEXMF=/usr/share/texmf install-tex
- cd ..
- rm -rf texinfo-4.9
90,安装设备自动管理工具(udev)
- cd /sources
- tar xvf udev-113.tar.bz2
- cd udev-113
- tar -xvf /sources/udev-config-6.3.tar.bz2
- install -dv /lib/{firmware,udev/devices/{pts,shm}}
- mknod -m0666 /lib/udev/devices/null c 1 3
- ln -sv /proc/self/fd /lib/udev/devices/fd
- ln -sv /proc/self/fd/0 /lib/udev/devices/stdin
- ln -sv /proc/self/fd/1 /lib/udev/devices/stdout
- ln -sv /proc/self/fd/2 /lib/udev/devices/stderr
- ln -sv /proc/kcore /lib/udev/devices/core
- make EXTRAS="`echo extras/*/`"
- make DESTDIR=/ EXTRAS="`echo extras/*/`" install
- cp -v etc/udev/rules.d/[0-9]* /etc/udev/rules.d/
- cd udev-config-6.3
- make install
- make install-doc
- make install-extra-doc
- cd ..
- install -m644 -v docs/writing_udev_rules/index.html \
- /usr/share/doc/udev-113/index.html
- cd ..
- rm -rf udev-113
91,安装工具集(util-linux)
- cd /sources
- tar xvf util-linux-2.12r.tar.bz2
- cd util-linux-2.12r
- sed -e 's@etc/adjtime@var/lib/hwclock/adjtime@g' \
- -i $(grep -rl '/etc/adjtime' .)
- mkdir -pv /var/lib/hwclock
- patch -Np1 -i /sources/util-linux-2.12r-cramfs-1.patch
- patch -Np1 -i /sources/util-linux-2.12r-lseek-1.patch
- /configure
- make HAVE_KILL=yes HAVE_SLN=yes
- make HAVE_KILL=yes HAVE_SLN=yes install
- cd ..
- rm -rf util-linux-2.12r
92,安装文本编辑工具(vim)
- cd /sources
- tar xvf vim-7.1.tar.bz2
- tar xvf vim-7.1-lang.tar.gz
- cd vim71
- patch -Np1 -i /sources/vim-7.1-fixes-1.patch
- patch -Np1 -i /sources/vim-7.1-mandir-1.patch
- echo '#define SYS_VIMRC_FILE "/etc/vimrc"' >> src/feature.h
- /configure --prefix=/usr --enable-multibyte
- make
- make install
- ln -sv vim /usr/bin/vi
- for L in "" fr it pl ru; do
- ln -sv vim.1 /usr/share/man/$L/man1/vi.1
- done
- ln -sv ../vim/vim71/doc /usr/share/doc/vim-7.1
- 配置vim
- cat > /etc/vimrc <<EOF
- set nocompatible
- set backspace=2
- syntax on
- if (&term == "iterm") || (&term == "putty")
- set background=dark
- endif
- EOF
- cd ..
- rm -rf vim71
93,重新进入chroot
- logout
- chroot /mnt/lfs /tools/bin/env -i \
- HOME=/root TERM=$TERM PS1='\u [\w]\$ ' \
- PATH=/bin:/usr/bin:/sbin:/usr/sbin \
- /tools/bin/bash --login
- /tools/bin/find /{,usr/}{bin,lib,sbin} -type f \
- -exec /tools/bin/strip --strip-debug '{}' ';'
- logout
- chroot "/mnt/lfs" /usr/bin/env -i \
- HOME=/root TERM="$TERM" PS1='\u [\w]\$ ' \
- PATH=/bin:/usr/bin:/sbin:/usr/sbin \
- /bin/bash --login
94,安装系统启动脚本集合
- cd /sources
- tar xvf lfs-bootscripts-6.3.tar.bz2
- cd lfs-bootscripts-6.3
- make install
- cd ..
- rm -rf lfs-bootscripts-6.3
95,对系统做一系列的配置
- 时间设置
- echo "UTC=1" >/etc/sysconfig/clock
- bash下的键盘功能
- vim /etc/inputrc
- 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
- bash shell启动文件
- vim /etc/profile
- export LANG=en
- export INPUTRC=/etc/inputrcalias ls="ls --color"export PS1='\u [\w]\$ '
- 主机名
- echo "HOSTNAME=ZTE" > /etc/sysconfig/network
- hosts文件
- echo "127.0.0.1 ZTE localhost" >/etc/hosts
- DNS
- echo "nameserver 202.96.134.133" >/etc/resolv.conf
- IP地址
- mkdir -pv /etc/sysconfig/network-devices/ifconfig.eth0
- vim /etc/sysconfig/network-devices/ifconfig.eth0/ipv4
- ONBOOT=yes
- SERVICE=ipv4-static
- IP=192.168.1.1
- NETMASK=255.255.255.0
- GATEWAY=192.168.1.2
- fstab文件
- vim /etc/fstab
- /dev/hda2 / ext3 defaults 1 1
- /dev/hda1 /boot ext3 defaults 1 1
- proc /proc proc defaults 0 0
- sysfs /sys sysfs defaults 0 0
- devpts /dev/pts devpts gid=4,mode=620 0 0
- tmpfs /dev/shm tmpfs defaults 0 0
96,安装内核(linux-2.6.22.5)
- cd /sources
- tar xvf linux-2.6.22.5.tar.bz2
- cd linux-2.6.22.5
- make mrproper
- make menuconfig
- .....
- .....
- make
- make modules_install
- cp -v arch/i386/boot/bzImage /boot/lfskernel-2.6.22.5
- cp -v System.map /boot/System.map-2.6.22.5
- cp -v .config /boot/config-2.6.22.5
- install -d /usr/share/doc/linux-2.6.22.5
- cp -r Documentation/* /usr/share/doc/linux-2.6.22.5
97,安装grub
- grub
- root (hd0,0)
- setup (hd0)
- quit
98,系统瘦身
- rm -rf /tools
- rm -rf /lfs-sources
99,启动自己的系统
1,如果使用liveCD制作的操作如下
- 取出光盘直接重启即可,
2,如果使用现有的宿主系统制作的操作如下
- shutdown –h now
- 关机之后新创建一虚拟系统,其他的根据自己需要定义,
- 需要注意的是创建虚拟磁盘的时候要选择现有的虚拟磁盘,见下图,
650) this.width=650;" onsubmit onchange onunload onselect onreset>
创建完成后启动虚拟机即可.
650) this.width=650;" onsubmit onchange onunload onselect onreset>
650) this.width=650;" onsubmit onchange onunload onselect onreset>