定制自動化安裝盤
# 安裝所需要的軟件包:
代碼如下:
yum -y install createrepo mkisofs isomd5sum
# 生成精簡後的rpm列表
代碼如下:
awk '/安裝/{print $2}' install.log |sed 's/^[0-9]*://g' >/root/packages.list //我的是中文環境具體看log裡是什麼
# 約束目錄結構
代碼如下:
mkdir -p /mnt/cdrom
mkdir -p /data/OS
mount /dev/cdrom /mnt/cdrom
rsync –a --exclude=Packages /mnt/cdrom/* /data/OS
mkdir /data/OS/Packages
# 將精簡後的rpm文件 拷貝到新的系統目錄裡
# 拷貝到新的系統目錄方法很多,這裡省事兒就用了替換命令 但是結果都一樣啊 呵呵
復制代碼
代碼如下:
cp /mnt/cdrom/Packages/libgcc-4.4.7-3.el6.x86_64
cp /mnt/cdrom/Packages/setup-2.8.14-20.el6.noarch
cp /mnt/cdrom/Packages/filesystem-2.4.30-3.el6.x86_64
cp /mnt/cdrom/Packages/xml-common-0.6.3-32.el6.noarch
cp /mnt/cdrom/Packages/cjkuni-fonts-common-0.2.20080216.1-35.el6.noarch
cp /mnt/cdrom/Packages/iso-codes-3.16-2.el6.noarch
cp /mnt/cdrom/Packages/basesystem-10.0-4.el6.noarch
cp /mnt/cdrom/Packages/dmz-cursor-themes-0.4-4.el6.noarch
cp /mnt/cdrom/Packages/libX11-common-1.5.0-4.el6.noarch
cp /mnt/cdrom/Packages/ca-certificates-2010.63-3.el6_1.5.noarch
cp /mnt/cdrom/Packages/ncurses-base-5.7-3.20090208.el6.x86_64
cp /mnt/cdrom/Packages/tzdata-2012j-1.el6.noarch
cp /mnt/cdrom/Packages/glibc-common-2.12-1.107.el6.x86_64
cp /mnt/cdrom/Packages/nss-softokn-freebl-3.12.9-11.el6.x86_64
cp /mnt/cdrom/Packages/glibc-2.12-1.107.el6.x86_64
cp /mnt/cdrom/Packages/ncurses-libs-5.7-3.20090208.el6.x86_64
cp /mnt/cdrom/Packages/bash-4.1.2-14.el6.x86_64
cp /mnt/cdrom/Packages/libattr-2.4.44-7.el6.x86_64
cp /mnt/cdrom/Packages/libcap-2.16-5.5.el6.x86_64
cp /mnt/cdrom/Packages/zlib-1.2.3-29.el6.x86_64
cp /mnt/cdrom/Packages/dbus-libs-1.2.24-7.el6_3.x86_64
cp /mnt/cdrom/Packages/info-4.13a-8.el6.x86_64
cp /mnt/cdrom/Packages/libxml2-2.7.6-8.el6_3.4.x86_64
:%s/^/cp /mnt/cdrom/Packages//g
cp /mnt/cdrom/Packages/cjkuni-uming-fonts-0.2.20080216.1-35.el6.noarch.rpm
cp /mnt/cdrom/Packages/cjkuni-ukai-fonts-0.2.20080216.1-35.el6.noarch.rpm
cp /mnt/cdrom/Packages/man-pages-3.22-20.el6.noarch.rpm
cp /mnt/cdrom/Packages/words-3.0-17.el6.noarch.rpm
cp /mnt/cdrom/Packages/centos-indexhtml-6-1.el6.centos.noarch.rpm
cp /mnt/cdrom/Packages/ql2400-firmware-5.08.00-1.el6.noarch.rpm
cp /mnt/cdrom/Packages/iwl5000-firmware-8.83.5.1_1-1.el6_1.1.noarch.rpm
cp /mnt/cdrom/Packages/ql2100-firmware-1.19.38-3.1.el6.noarch.rpm
cp /mnt/cdrom/Packages/ivtv-firmware-20080701-20.2.noarch.rpm
cp /mnt/cdrom/Packages/libertas-usb8388-firmware-5.110.22.p23-3.1.el6.noarch.rpm
cp /mnt/cdrom/Packages/xorg-x11-drv-ati-firmware-6.99.99-1.el6.noarch.rpm
cp /mnt/cdrom/Packages/ql2500-firmware-5.08.00-1.el6.noarch.rpm
cp /mnt/cdrom/Packages/atmel-firmware-1.3-7.el6.noarch.rpm
cp /mnt/cdrom/Packages/zd1211-firmware-1.4-4.el6.noarch.rpm
cp /mnt/cdrom/Packages/iwl4965-firmware-228.61.2.24-2.1.el6.noarch.rpm
cp /mnt/cdrom/Packages/rt61pci-firmware-1.2-7.el6.noarch.rpm
cp /mnt/cdrom/Packages/iwl3945-firmware-15.32.2.9-4.el6.noarch.rpm
cp /mnt/cdrom/Packages/ql2200-firmware-2.02.08-3.1.el6.noarch.rpm
cp /mnt/cdrom/Packages/rt73usb-firmware-1.8-7.el6.noarch.rpm
cp /mnt/cdrom/Packages/ipw2100-firmware-1.3-11.el6.noarch.rpm
cp /mnt/cdrom/Packages/ql23xx-firmware-3.03.27-3.1.el6.noarch.rpm
cp /mnt/cdrom/Packages/ipw2200-firmware-3.1-4.el6.noarch.rpm
cp /mnt/cdrom/Packages/rootfiles-8.1-6.1.el6.noarch.rpm
:%s/$/.rpm/g
cp /mnt/cdrom/Packages/cjkuni-uming-fonts-0.2.20080216.1-35.el6.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/cjkuni-ukai-fonts-0.2.20080216.1-35.el6.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/man-pages-3.22-20.el6.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/words-3.0-17.el6.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/centos-indexhtml-6-1.el6.centos.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/ql2400-firmware-5.08.00-1.el6.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/iwl5000-firmware-8.83.5.1_1-1.el6_1.1.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/ql2100-firmware-1.19.38-3.1.el6.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/ivtv-firmware-20080701-20.2.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/libertas-usb8388-firmware-5.110.22.p23-3.1.el6.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/xorg-x11-drv-ati-firmware-6.99.99-1.el6.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/ql2500-firmware-5.08.00-1.el6.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/atmel-firmware-1.3-7.el6.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/zd1211-firmware-1.4-4.el6.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/iwl4965-firmware-228.61.2.24-2.1.el6.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/rt61pci-firmware-1.2-7.el6.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/iwl3945-firmware-15.32.2.9-4.el6.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/ql2200-firmware-2.02.08-3.1.el6.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/rt73usb-firmware-1.8-7.el6.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/ipw2100-firmware-1.3-11.el6.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/ql23xx-firmware-3.03.27-3.1.el6.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/ipw2200-firmware-3.1-4.el6.noarch.rpm /data/OS/Packages
cp /mnt/cdrom/Packages/rootfiles-8.1-6.1.el6.noarch.rpm /data/OS/Packages
:%s/$/ /data/OS/Packages/g
# 創建ks.cfg文件 默認安裝完系統就會安裝所有的定制軟件包了
# 關鍵字
代碼如下:
%post --nochroot %post
[root@test OS]# pwd
/data/OS
[root@test OS]# cat ks.cfg
firewall --disabled
install
cdrom
rootpw --iscrypted $1$stMs72eG$G3f0zhGBjp6/SioZ28CxQ0
auth --useshadow --passalgo=md5
text
firstboot --disable
keyboard us
lang en_US.UTF-8
selinux --disabled
# Do not configure the X Window System
skipx
logging --level=info
reboot --eject
timezone Asia/Shanghai
network --device em1 --bootproto=static --ip=192.168.7.123 --netmask=255.255.248.0 --gateway=192.1s
bootloader --location=mbr --driveorder=sda
# Clear the Master Boot Record
zerombr yes
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part / --fstype="ext4" --size=10240
part swap --size=4096
part /data --fstype="ext4" --grow --size=1
%packages
@base
@core
@server-policy
sgpio
device-mapper-persistent-data
ntp
%post --nochroot
mkdir -p /mnt/sysimage/tmp/custom_data >> /tmp/custom.log 2>&1
cp /mnt/source/Packages/lnmp_pack.tar.gz /mnt/sysimage/tmp/custom_data >> /