以前有折騰過CentOS5.x版本,今天在論壇中看到有哥們提問關於最新版本的定製光盤,按照這以前的方法不成功。我特地下載一個 CentOS 6.3 進行測試並記錄過程一塊兒分享,發現其實方法和以前的區別不大。因爲水平有限,環境有限,因此不能保證這是十分的正確的。
安裝系統時選擇所須要的軟件包進行最小化安裝,安裝過程和以前的版本差很少,這裏略過,接下來就開始如下步驟:
1.安裝所需的軟件包:
[root@localhost ~]# yum -y install createrepo mkisofs isomd5sum
2.根據當前系統已安裝的軟件包生成安裝系統所須要的rpm列表
[root@localhost ~]# awk '/Installing/{print $2}' install.log |sed 's/^[0-9]*://g' >/root/packages.list
3.創建定製所須要的目錄並把除Packages目錄之外的文件複製到新的系統目錄
[root@localhost ~]# mkdir /mnt/cdrom
[root@localhost ~]# mkdir -p /data/OS
[root@localhost ~]# mount /dev/cdrom /mnt/cdrom/
[root@localhost ~]# rsync -a --exclude=Packages /mnt/cdrom/ /data/OS/
[root@localhost ~]# mkdir /data/OS/Packages
4.使用腳本自動複製所須要的RPM包到新創建的光盤目錄中Packages
[root@localhost ~]# vim cprpms.sh
-
#!/bin/bash
-
SRC_RPMS=/mnt/cdrom/Packages
-
DST_RPMS=/data/OS/Packages
-
packages_list=/root/packages.list
-
number_of_packages=`cat $packages_list | wc -l`
-
i=1
-
while [ $i -le $number_of_packages ] ;
-
do
-
name=`head -n $i $packages_list | tail -n -1`
-
echo
"cp $SRC_RPMS/$name* $DST_RPMS/"
-
cp $SRC_RPMS/$name* $DST_RPMS/
-
i=`expr $i + 1`
-
done
[root@localhost ~]# sh cprpms.sh
5.配置kickstart腳本
[root@localhost ~]# vim /data/OS/isolinux/ks.cfg
-
#platform=x86, AMD64, or Intel EM64T
-
# Firewall configuration
-
firewall --disabled
-
# Install OS instead of upgrade
-
install
-
# Use CDROM installation media
-
cdrom
-
# Root password default is "redhat"
-
rootpw --iscrypted $1$36bsCbH1$UDJ6eCqPi2Nm1KsgajvHs1
-
# System authorization information
-
auth --useshadow
--passalgo
=
md5
-
# Use text mode install
-
text
-
firstboot --disable
-
# System keyboard
-
keyboard us
-
# System language
-
lang en_US
-
# SELinux configuration
-
selinux --disabled
-
# Do not configure the X Window System
-
skipx
-
# Installation logging level
-
logging
--level
=
info
-
# Reboot after installation
-
reboot
-
# System timezone
-
timezone Asia/Shanghai
-
# Network information
-
network
--bootproto
=
dhcp
--device
=
eth0
--onboot
=on –noipv6
-
# System bootloader configuration
-
bootloader
--location
=
mbr
-
# Clear the Master Boot Record
-
zerombr
-
# Partition clearing information
-
clearpart --all --initlabel
-
# Disk partitioning information
-
part /boot
--fstype
=
"ext4"
--size
=
100
-
part /
--fstype
=
"ext4"
--size
=
5120
-
part swap
--size
=
1024
-
part /data
--fstype
=
"ext4"
--grow
--size
=
1
-
%packages
-
@base
-
@core
-
@development
-
@server-policy
-
sgpio
-
ntp
-
6.讓系統從kickstart配置啓動安裝
[root@localhost OS]# vim /data/OS/isolinux/isolinux.cfg
default linux
label linux
kernel vmlinuz
append ks=cdrom:/isolinux/ks.cfg initrd=initrd.img #修改行
7.生成rpm包的依賴關係
[root@localhost ~]# cd /data/OS/
[root@localhost OS]# createrepo -g repodata/*-comps.xml /data/OS/
[root@localhost OS]# declare -x discinfo=`head -1 .discinfo`
[root@localhost OS]# createrepo -u "media://$discinfo" -g repodata/*-comps.xml /data/OS/
8.生成ISO鏡像文件
[root@localhost ~]# cd /data/OS/
[root@localhost OS]# mkisofs -R -J -T -r -l -d -joliet-long -allow-multidot \
-allow-leading-dots -no-bak -o /data/CentOS-6.3-x86_64.iso \
-b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot \
-boot-load-size 4 -boot-info-table /data/OS
9.生成MD5校驗碼
[root@localhost ~]# implantisomd5 /data/CentOS-6.3-x86_64.iso
10.測試