第一部份:文字版
我有很多朋友從事網(wǎng)吧高管技術(shù)員。但是大型網(wǎng)吧老板都對ROS 海蜘蛛不太依賴,像QUICK LINUX又是收費的,心理作用呵呵。為此一個朋友向我提出能不能做一個精簡一點的CentOS發(fā)行版。為此我建立了CENTOS這個發(fā)行版。以下是具體的制作過程和朋友們一起分享!希望能共同進步
聲明:資料大多來源于
網(wǎng)絡(luò),本人只是收集整理加實踐,成功了寫出的總結(jié)。
光盤結(jié)構(gòu)介紹
*iso
linux 目錄存放光盤啟動時的
安裝界面信息
*images 目錄包括了必要的啟動映像
文件*CentOS 目錄存放安裝
軟件包及信息
*.discinfo 文件是安裝價質(zhì)的識別信息
*lemp.tar.gz 文件存放
系統(tǒng)初始化及其相關(guān)
程序安裝腳本.
環(huán)境說明:CentOS 5.4-i386 Vmware Workstation上完成制作工作.
準備工作:
VMware //
虛擬機,安裝過程可以隨意
設(shè)置,錯了可以再來
Secure // 串口、SSH連接工具(本實驗用Putty即可)
下載一份DVD版CentOS5.4 Linux系統(tǒng)(即.ISO文件)
===================================================
1、在VM安裝linux系統(tǒng)
安裝anaconda repodata createrepo mkisofs ,關(guān)聯(lián)太多采用
yum安裝//定制過程需要產(chǎn)生comps.xml文件以及生成iso
- yum -y install anaconda repodata createrepo mkisofs#安裝制作發(fā)行版所需的基本軟件包
- yum -y install anaconda-runtime createrepo yum-utils anacondaanaconda-help busybox-anaconda mkisofs
復(fù)制代碼2、生成packages.list 所安裝的RPM包文件清單(由于install.log文件在root目錄,所以該操作在root目錄進行)
- cat install.log | grep Installing | sed 's/Installing //g' > /root/packages.list #生成后,需要仔細看該文件,一般會在某些文件開始部分如“1:”這樣的字符,需要刪除這些字符,否在后面執(zhí)行copy動作會報錯,注意引項為英文版Shell
- cat install.log | grep 安裝 | sed 's/安裝 //g' > /root/packages.list #同上,中文版Shell
復(fù)制代碼3、建立定制
Centos的源目錄
- mkdir /disk #定制時要復(fù)制RPM包的目錄
- mkdir /mnt/cdrom #加載光驅(qū)目錄
- mount -o loop /dev/cdrom /mnt/cdrom #將光盤內(nèi)容加載到/mnt/cdrom中
- cd /mnt/cdrom/ #復(fù)制光盤內(nèi)容到disk文件下,或者
- tar -cf - . | ( cd /disk ; tar -xvpf - )
- rm -rf /disk/CentOS/ #先刪除所有RPM包
- mkdir /disk/CentOS/ #創(chuàng)建RPM包存放目錄
復(fù)制代碼4、通過腳本復(fù)制系統(tǒng)安裝的包;
- #!/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 -f 2 -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
復(fù)制代碼將以上內(nèi)容保存為copyrpms.sh
- chmod 775 copyrpms.sh
- ./copyrpms.sh
復(fù)制代碼經(jīng)過一系列的復(fù)制就完成了你要定制的RPM包(在/disk/CentOS/目錄下);
5、定制安裝控制文件ks.cfg
一般方便可以直接由root下面的anaconda-ks.cfg修改
- cp anaconda-ks.cfg /disk/ks.cfg
復(fù)制代碼樣例內(nèi)容如:
- # 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
復(fù)制代碼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 -
復(fù)制代碼7、生成comps.xml
- cd /disk/
- createrepo -g repodata/comps.xml /disk/
復(fù)制代碼到此以上定制任務(wù)已經(jīng)完成。
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/
復(fù)制代碼/disk/ 目錄下產(chǎn)生的MyCentOS.iso 生成的ISO文件。
再用winscp把ISO文件拷出來拿到
虛擬機實驗,如果OK那就沒問題了!