CentOS 6.5 自动安装镜像

mkdir /mnt/cdrom
mkdir /ISO



 mount  /dev/cdrom  /mnt/cdrom

/usr/bin/rsync -a --exclude=Packages/ --exclude=repodata/ /mnt/cdrom/  /ISO/
 mkdir -p /ISO/{Packages,repodata}

 [root@CentOS ~]# vi copy.sh
#!/bin/bash
cd /root
awk '/Installing/{print $2}' install.log | sed 's/^*://g' >package.txt
DVD='/mnt/cdrom/Packages'
PACKDIR='/root/package.txt'
NEW_DVD='/ISO/Packages'
while read LINE
do
cp ${DVD}/${LINE}*.rpm /${NEW_DVD} || echo "$LINE don't cp......."
done < package.txt
rm -f package.txt
[root@CentOS ~]# chmod +x copy.sh
[root@CentOS ~]# ./copy.sh
[root@CentOS ~]# ll /ISO/Packages/ |wc -l

[root@CentOS ~]# cd /ISO
[root@CentOS ISO]# cp ~/anaconda-ks.cfg isolinux/ks.cfg
[root@CentOS ISO]# vi  isolinux/ks.cfg
[root@CentOS ISO]# chmod 644 isolinux/isolinux.cfg
[root@CentOS ISO]# vi isolinux/isolinux.cfg
[root@CentOS ISO]# chmod 444  isolinux/isolinux.cfg

yum -y install anaconda repodata createrepo mkisofs rsync


cp /mnt/cdrom/repodata/b4e0b9342ef85d3059ff095fa7f140f654c2cb492837de689a58c581207d9632-c6-x86_64-comps.xml /ISO/repodata/minimal-x86_64.xml

createrepo -g repodata/minimal-x86_64.xml ./

declare -x discinfo=`head -1 .discinfo`

echo $discinfo

createrepo -u "media://$discinfo" -g repodata/minimal-x86_64.xml .





 mkisofs -o CentOS-6.5_64.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T /ISO/

 /usr/bin/implantisomd5 /ISO/CentOS-6.5_64.iso



 -----------------isolinux.cfg-----------------
default auto

timeout 600

display boot.msg

menu background splash.jpg
menu title Welcome to CentOS 6.5!
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color scrollbar 0 #ffffffff #00000000


label auto
  menu label ^Install or upgrade an existing system
  menu default
  kernel vmlinuz
  append ks=cdrom:/isolinux/ks.cfg initrd=initrd.img


 -----------------ks.cfg-----------------
 # Kickstart file automatically generated by anaconda.

#version=DEVEL
install
text
cdrom
lang en_US.UTF-8
keyboard us
network --onboot no --device eth0 --bootproto dhcp --noipv6
rootpw  --iscrypted $6$UGJyDRk7gbzAm3gp$BSbjTDfehTlnJENxLe5ErW11om2DEaE4o1wNmqVLeTgLx6dpLFaYxaY2hAVHyHuH9my6M5twnobx9jpbb29ai0
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone --utc Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="nomodeset crashkernel=auto rhgb quiet"
# 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 --all --drives=sda
#volgroup VolGroup --pesize=4096 pv.008002
#logvol / --fstype=ext4 --name=lv_root --vgname=VolGroup --grow --size=1024 --maxsize=51200
#logvol swap --name=lv_swap --vgname=VolGroup --grow --size=1504 --maxsize=1504

part /boot --fstype=ext4 --size=500
#part pv.008002 --grow --size=1
part swap --size=4096
part / --fstype=ext4 --size=1024 --grow

#repo --name="CentOS"  --baseurl=cdrom:sr0 --cost=100
reboot --eject

%packages --nobase
@core
%end

你可能感兴趣的:(centos,kickstart)