对于最新的jhalfs-2.3.1却没有介绍,本文对前两篇文章做了一些修改,使得更加快速的创建LFS。
准备工作:
1.在windows里面装个SecureCRT,我的是Version 6.1.0 (build 349) ,以便在windows里面用它来登陆LiveCD中的sshd服务,这样子就可以copy&paste了。
2.在windows里添加共享目录,名称为share
3.下载本文附件中的两个脚本和《第二版 手把手教你如何建立自己的Linux系统》中提到的中文utf8-kernel-2.6.22.5-core-1.patch utf8-kernel-2.6.22.5-fonts-1.patch下载解压后放到上面建的windows共享目录share中
4.在windows里面装个UltraEdit,看脚本和日志用
5.关于脚本的输出日志,我在第1个脚本里面加入{要执行的脚本} 1>> alfs6.3_01.log 2>> alfs6.3_01.log,来记录脚本输出
6.脚本执行流程和《第二版 手把手教你如何建立自己的Linux系统》一样,建议先看一下脚本,大体对照一下
7.建议:在虚拟机设置硬盘的时候3G就够了,最好当时分配空间,这样子加快速度
8.lfslivecd-x86-6.3-r2160.iso
在我的机子上执行时间,做个参考:
20:40 start,然后配置jhalfs,接着执行jhalfs的make所花费时间为:
real 144m46.347s
user 82m22.351s
sys 48m1.189s
23:04 jhalfs end
23:16 开始配置内核
23:38 编译完
总共耗时3.0小时左右吧.比我的半自动化流程要快半个小时,下面开始:
#在虚拟机里启动sshd服务,这里一定要设置密码,否则SecureCRT登陆不上去
passwd root
/etc/rc.d/init.d/sshd start
#然后在windows里面使用SecureCRT,copy&paste如下命令
cfdisk
mkswap /dev/hda1
mkfs.xfs -f /dev/hda2
swapon /dev/hda1
#挂载硬盘
export LFS=/mnt/lfs
mkdir -pv $LFS
mount /dev/hda2 $LFS
chmod -v a+wt /mnt/lfs
chown -v jhalfs /mnt/lfs
#转到jhalfs
passwd jhalfs
su jhalfs
cd
cd jhalfs-2.3.1/
time make
#设置4项就可以了,其它都用默认
--- General Settings --->常规设置
1.(/mnt/build_dir) Build Directory 建立的LFS位置,这里设置/mnt/lfs
--- Build Settings --->
2.语言设置$LANG 为zh_CN.UTF-8
3.[*] Run testsuites 不选
--- Advanced Features --->高级设置
4.[*] Create SBU and disk usage report 不选
...
#jhalfs完成,大概需要2个小时24分钟
exit
mount --bind /dev /mnt/lfs/dev
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
#mount –vt devpts devpts $LFS/dev/pts
#mount –vt tmpfs shm $LFS/dev/shm
#这里我写了两个脚本,方便设置,以及下载两个中文补丁
mkdir -v $LFS/mylfsshell
mount -t smbfs -o username=***,password=*** //192.168.187.1/share $LFS/mylfsshell/
chmod 777 $LFS/mylfsshell/
chmod 777 $LFS/mylfsshell/*.sh
echo "start:为最后的设置进入chroot环境-------------------------------"
chroot "$LFS" /usr/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin \
/bin/bash --login
cp /mylfsshell/utf8-kernel-2.6.22.5-core-1.patch /sources
cp /mylfsshell/utf8-kernel-2.6.22.5-fonts-1.patch /sources
#脚本alfs_01.sh主要设置 /etc/fstab, /etc/hosts, /etc/sysconfig/clock,/etc/sysconfig/console,/etc/sysconfig/network, /etc/sysconfig//network-devices/ifconfig.eth0/ipv4
sh /mylfsshell/alfs_01.sh
#接下来和《第二版 手把手...》中一模一样了,最后执行alfs_02.sh
mv /alfs6.3_01.log /mylfsshell/
echo "start:安装内核Linux-2.6.22.5-------------------------------"
cd /sources
export LFS=/sources
tar xvf $LFS/linux-2.6.22.5.tar.bz2
cd linux-2.6.22.5
#如果之前下载了UTF-8编码文字显示补丁,那么这里可以将这两个补丁打入内核
patch -Np1 -i $LFS/utf8-kernel-2.6.22.5-core-1.patch
patch -Np1 -i $LFS/utf8-kernel-2.6.22.5-fonts-1.patch
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
grub
root (hd0,1)
setup (hd0)
quit
sh /mylfsshell/alfs_02.sh
#大功告成,退出重启,ok了
#设置一下密码
passwd root
logout
alfs_01.sh文件的内容:
{
date
#
#
echo "start:时间设置(Configuring the setclock Script)-------------------------------"
cat > /etc/sysconfig/clock << "EOF"
# Begin /etc/sysconfig/clock
UTC=1
# End /etc/sysconfig/clock
EOF
#
#
echo "start:设置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
#
#
echo "start:设置Bash Shell启动文件(The Bash Shell Startup Files)-------------------------------"
cat > /etc/profile << "EOF"
# Begin /etc/profile
export LANG=zh_CN.UTF-8
export INPUTRC=/etc/inputrc
alias ls="ls --color"
export PS1='\u:\w\$ '
# End /etc/profile
EOF
#
#
echo "start:设置本地网络名-------------------------------"
echo "HOSTNAME=mylinux" > /etc/sysconfig/network
#
#
echo "start:设置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
#
#
echo "start:设置网络的静态地址-------------------------------"
cd /etc/sysconfig/network-devices &&
mkdir -v ifconfig.eth0 &&
cat > ifconfig.eth0/ipv4 << "EOF"
ONBOOT=yes
SERVICE=ipv4-static
IP=192.168.187.133
GATEWAY=192.168.187.2
PREFIX=24
BROADCAST=192.168.187.255
EOF
#
#
echo "start:设置DNS-------------------------------"
cat > /etc/resolv.conf << "EOF"
# Begin /etc/resolv.conf
nameserver 192.168.187.2
nameserver 209.166.160.36
# End /etc/resolv.conf
EOF
#
#
echo "start:建立fstab文件-------------------------------"
cat > /etc/fstab << "EOF"
# Begin /etc/fstab
# file system mount-point type options dump fsck
# order
/dev/hda2 / xfs defaults 1 1
/dev/hda1 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
echo "end:01.sh-----------------"
date
} 1>> alfs6.3_01.log 2>> alfs6.3_01.log
#
#
#离胜利只有一步之遥了,加油!
#
#
:<cp mylfs6.3_08.log /mylfsshell
echo "start:安装内核Linux-2.6.22.5-------------------------------"
cd /sources
export LFS=/sources
tar xvf $LFS/linux-2.6.22.5.tar.bz2
cd linux-2.6.22.5
#如果之前下载了UTF-8编码文字显示补丁,那么这里可以将这两个补丁打入内核
patch -Np1 -i $LFS/utf8-kernel-2.6.22.5-core-1.patch
patch -Np1 -i $LFS/utf8-kernel-2.6.22.5-fonts-1.patch
make mrproper
#这个地方要是找不到gcc,用这个命令export PATH=$PATH:/tools/bin
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
grub
root (hd0,1)
setup (hd0)
quit
sh /mylfsshell/alfs_02.sh
BLOCK
alfs_02.sh文件的内容:
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.3
root (hd0,1)
kernel /boot/lfskernel-2.6.22.5 root=/dev/hda2
EOF
#
#
echo "start:将menu.lst连接到/etc目录下-------------------------------"
mkdir -v /etc/grub
ln -sv /boot/grub/menu.lst /etc/grub
#
#
exit
------------->说明:
使用上述的版本制作出来的LFS没有ifconfig这个命令。颇为奇怪...
阅读(4276) | 评论(1) | 转发(0) |