定制CentOS5.6系统

定制CentOS5.6 ServerCD系统安装盘

1  在虚拟机中安装系统,选择所需的设置和软件包本次试验用的是CentOS-5.6-i386

2  安装定制光盘所需软件

yum -y install createrepo mkisofs

 

3  生成安装系统所需的rpm文件列表

awk '/Installing/{print $2}' install.log |sed 's/^[0-9]*://g' >/root/packages.list 

 

4  创建定制工作目录

mkdir /home/OS
    
mount /dev/cdrom /mnt
    
rsync –a --exclude=CentOS /mnt/ /home/OS
    
mkdir /home/OS/CentOS
    

 

5  复制系统安装所需rpm包,如下脚本

vi cprpm.sh

 

#!/bin/bash
    
DEBUG=0
    
DVD_CD=/home/OS/CentOS            //目标地址,即要复制到的地方 
ALL_RPMS_DIR=/mnt/CentOS/         //源目录,CentOS 5.6为例 
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
    

 

此脚本将复制文件到/home/OS/CentOS

chmod +x cprpm.sh
    
./cprpm.sh
    

 

6  定制kickstart文件ks.cfg

文件从/root/anaconda-ks.cfg中复制修改,修改如下
①  
安装gccgcc-c++
②  
移除sendmail, firstboot-tui, bluez-utils
③  
关闭不使用的服务

vi /home/OS/ks.cfg内容如下:

# Kickstart file automatically generated by anaconda.
    
install
    
cdrom
    
lang en_US.UTF-8
    
keyboard us
    
network --device eth0 --bootproto dhcp
    
rootpw --iscrypted $1$yDf6lXw3$bRYzQP269EcdjAy8qeOo30
    
firewall --enabled --port=22:tcp
    
authconfig --enableshadow --enablemd5
    
selinux --enforcing
    
timezone 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.2 --size=0 --grow --ondisk=sda
    
#volgroup VolGroup00 --pesize=32768 pv.2
    
#logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
    
#logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=512 --grow --maxsize=1024
    

   
     
   
%packages
    
@base
    
@core
    
gcc
    
gcc-c++
    
keyutils
    
iscsi-initiator-utils
    
trousers
    
fipscheck
    
device-mapper-multipath
    
-sendmail
    
-firstboot-tui
    
-bluez-utils
    

   
     
   
%post
    
# Disable unused service
    
chkconfig acpid off
    
chkconfig anacron off
    
chkconfig ip6tables off
    
chkconfig lvm2-monitor off
    
chkconfig netfs off
    
chkconfig nfslock off
    
chkconfig pcscd off
    
chkconfig portmap off
    
chkconfig restorecond off
    
chkconfig rpcgssd off
    
chkconfig rpcidmapd off
    

 

 

7  修改/home/OS/isolinux/isolinux.cfg

把第一行的default linux改成default text ks=cdrom:/ks.cfg

 

8  生成comps.xml

cd /home/OS
    
declare -x discinfo=`head -1 .discinfo`
    
createrepo –g repodata/comps.xml /home/OS/
    

 

9  生成ISO文件

isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T /home/OS
    

 

/home/OS/CentOS-5.6-1386-CD.iso即生成的ISO文件,可以用虚拟机测试一下哦!

 

 

 

你可能感兴趣的:(centos,职场,精简,裁剪,休闲)