之前有折腾过CentOS5.x版本,今天在论坛中看到有哥们提问关于最新版本的定制光盘,按照这之前的方法不成功。我特意下载一个CentOS 6.3 进行测试并记录过程一起分享,发现其实方法和之前的区别不大。由于水平有限,环境有限,所以不能保证这是十分的正确的。
测试环境:VMware Workstation 8.0 CentOS 6.3 x86_64
首先当然是下载一个CentOS 6.3
CentOS 6.3下载地址:
32位: http://mirror.centos.org/centos/6.3/isos/i386/CentOS-6.3-i386-bin-DVD1to2.torrent
64位: http://mirror.centos.org/centos/6.3/isos/x86_64/CentOS-6.3-x86_64-bin-DVD1to2.torrent
首先当然是下载一个CentOS 6.3
CentOS 6.3下载地址:
32位: http://mirror.centos.org/centos/6.3/isos/i386/CentOS-6.3-i386-bin-DVD1to2.torrent
64位: http://mirror.centos.org/centos/6.3/isos/x86_64/CentOS-6.3-x86_64-bin-DVD1to2.torrent
安装系统时选择所需要的软件包进行最小化安装,安装过程和之前的版本差不多,这里略过,接下来就开始以下步骤:
1.安装所需的软件包:
[root@localhost ~]# yum -y install createrepo mkisofs isomd5sum
[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
[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
[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
[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
[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 #修改行
[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/
[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
[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
[root@localhost ~]# implantisomd5 /data/CentOS-6.3-x86_64.iso
10.测试
转载于:https://blog.51cto.com/2856499/1407176