我有很多朋友从事网吧高管技术员。但是大型网吧老板都对ROS 海蜘蛛不太依赖,像QUICK LINUX又是收费的,心理作用呵呵。为此一个朋友向我提出能不能做一个精简一点的CentOS发行版。为此我建立了CENTOS这个发行版。以下是具体的制作过程和朋友们一起分享!希望能共同进步
声明:资料大多来源于网络,本人只是收集整理加实践,成功了写出的总结。
光盘结构介绍
*isolinux 目录存放光盘启动时的安装界面信息
*images 目录包括了必要的启动映像文件
*CentOS 目录存放安装软件包及信息
*.discinfo 文件是安装价质的识别信息
*lemp.tar.gz 文件存放系统初始化及其相关程序安装脚本.
环境说明:CentOS 5.4-i386 Vmware Workstation上完成制作工作.
准备工作:
VMware // 虚拟机,安装过程可以随意设置,错了可以再来
Secure // 串口、SSH连接工具(本实验用Putty即可)
下载一份DVD版CentOS5.4 Linux系统(即.ISO文件)
===================================================
1、在VM安装linux系统
安装anaconda repodata createrepo mkisofs ,关联太多采用yum安装//定制过程需要产生comps.xml文件以及生成iso yum -y install anaconda repodata createrepo mkisofs#安装制作发行版所需的基本软件包
yum -y install anaconda-runtime createrepo yum-utils anacondaanaconda-help busybox-anaconda mkisofs
复制代码
2、生成packages.list 所安装的RPM包文件清单(由于install.log文件在root目录,所以该操作在root目录进行) cat install.log | grep Installing | sed 's/Installing //g' > /root/packages.list #生成后,需要仔细看该文件,一般会在某些文件开始部分如“1:”这样的字符,需要删除这些字符,否在后面执行copy动作会报错,注意引项为英文版Shell
cat install.log | grep 安装 | sed 's/安装 //g' > /root/packages.list #同上,中文版Shell
复制代码
3、建立定制Centos的源目录 mkdir /disk #定制时要复制RPM包的目录
mkdir /mnt/cdrom #加载光驱目录
mount -o loop /dev/cdrom /mnt/cdrom #将光盘内容加载到/mnt/cdrom中
cd /mnt/cdrom/ #复制光盘内容到disk文件下,或者
tar -cf - . | ( cd /disk ; tar -xvpf - )
rm -rf /disk/CentOS/ #先删除所有RPM包
mkdir /disk/CentOS/ #创建RPM包存放目录
复制代码
4、通过脚本复制系统安装的包; #!/bin/bash
DEBUG=0
DVD_CD=/disk/CentOS
ALL_RPMS_DIR=/mnt/cdrom/CentOS/
DVD_RPMS_DIR=$DVD_CD
packages_list=/root/packages.list
number_of_packages=`cat $packages_list | wc -l`
i=1
while [ $i -le $number_of_packages ] ; do
line=`head -n $i $packages_list | tail -n -1`
name=`echo $line | awk '{print $1}'`
version=`echo $line | awk '{print $3}' | cut-f2-d:`
if [ $DEBUG -eq "1" ] ; then
echo $i: $line
echo $name
echo $version
fi
if [ $DEBUG -eq "1" ] ; then
ls $ALL_RPMS_DIR/$name-$version*
if [ $? -ne 0 ] ; then
echo "cp $ALL_RPMS_DIR/$name$version* "
fi
else
echo "cp $ALL_RPMS_DIR/$name-$version* $DVD_RPMS_DIR/"
cp $ALL_RPMS_DIR/$name$version* $DVD_RPMS_DIR/
# in case the copy failed
if [ $? -ne 0 ] ; then
echo "cp $ALL_RPMS_DIR/$name$version* "
cp $ALL_RPMS_DIR/$name* $DVD_RPMS_DIR/
fi
fi
i=`expr $i + 1`
done
复制代码
将以上内容保存为copyrpms.sh chmod 775 copyrpms.sh
./copyrpms.sh
复制代码
经过一系列的复制就完成了你要定制的RPM包(在/disk/CentOS/目录下);
5、定制安装控制文件ks.cfg
一般方便可以直接由root下面的anaconda-ks.cfg修改 cp anaconda-ks.cfg /disk/ks.cfg
复制代码
样例内容如: # Kickstart file automatically generated by anaconda.
install
cdrom
lang en_US.UTF-8
keyboard us
network --device eth0 --bootproto dhcp
firewall --disabled
authconfig --enableshadow --enablemd5
selinux --disabled
timezone --utc Asia/Shanghai
bootloader --location=mbr --driveorder=sda
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
#clearpart --linux --drives=sda
#part /boot --fstype ext3 --size=100 --ondisk=sda
#part pv.6 --size=0 --grow --ondisk=sda
#volgroup VolGroup00 --pesize=32768 pv.6
#logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
#logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=1000 --grow --maxsize=4032
%packages
@mysql
@core
@base
@network-server
@web-server
%post
echo "HOSTNAME=icesoul.local" >> /etc/sysconfig/network
echo "# Do not remove the following line, or various programs" > /etc/hosts
echo "# that require network functionality will fail." >> /etc/hosts
echo "127.0.0.1 localhost" >> /etc/hosts
echo "127.0.0.1 icesoul.local" >> /etc/hosts
eject
reboot
复制代码
6、修改isolinux.cfg文件 // 将/disk/isolinux/目录下的isolinux.cfg文件第一行default linux修改成default linux ks=cdrom:/ks.cfg
样例文件如: default linux ks=cdrom:/ks.cfg
prompt 1
timeout 60
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
kernel vmlinuz
append initrd=initrd.img
label text
kernel vmlinuz
append initrd=initrd.img text
label ks

kernel vmlinuz
append ks initrd=initrd.img
label local
localboot 1
label memtest86
kernel memtest
append -
复制代码
7、生成comps.xml cd /disk/
createrepo -g repodata/comps.xml /disk/
复制代码
到此以上定制任务已经完成。
8、制作IOS文件 cd /disk/
mkisofs -o MyCentOS.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T /disk/
复制代码
/disk/ 目录下产生的MyCentOS.iso 生成的ISO文件。
再用winscp把ISO文件拷出来拿到虚拟机实验,如果OK那就没问题了!