centos 制作iso镜像

centos 6.9 定制化iso镜像. 以最小化安装为例.

1.以centos6.9 最小化安装一mini系统.

vi /root/ks.cfg

install
cdrom
lang en_US.UTF-8
keyboard us
network --onboot no --device eth0 --bootproto dhcp --noipv6
rootpw  --iscrypted $6$ZI78JvmQ56MxYSe3$dn9UV./VvFieP25R94ciYo4wg7p17sM8gCt2WQa/hqMeHiynnBqL/abF14D0AOSXjnptoBHqLYGhzun6W7Qfr1
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512
ignoredisk --only-use=sda
selinux --disabled
timezone Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
clearpart --all --initlabel  --drives=sda
part /boot --fstype=ext4 --size=200
part / --fstype=ext4 --size=20000
part swap --size=2048
part /data --fstype=ext4 --grow --size=1
reboot
%packages
@core
@server-policy
@workstation-policy

%post
#add user
useradd pos
echo "12341234" | passwd pos --stdin
#service
for i in `chkconfig --list | grep 3:on | awk '{print $1}'`; do echo $i; chkconfig $i off; done
for i in auditd crond network  rdma  rsyslog sshd udev-post; do echo $i ; chkconfig $i on; done

#profile
echo "ulimit -SHn 51200">>/etc/profile
echo "TMOUT=6000" >>/etc/profile

#passwd
echo "admin"  | passwd root --stdin

#ssh login slowly
sed -i "s/#UseDNS yes/UseDNS no/" /etc/ssh/sshd_config
sed -i "s/GSSAPICleanupCredentials yes/GSSAPICleanupCredentials no/" /etc/ssh/sshd_config
/etc/init.d/sshd restart

rm -fr /tmp/*
%end

2.  yum install createrepo mkisofs isomd5sum squashfs-tools -y

    mkdir /root/os

   将以os为iso制作目录.

mount /etc/cdrom/   /media

rsync -a --exclude=Packages/ --exclude=repodata/ /media/   /root/os/

mkdir -p /root/os/{Packages,repodata}

3.拷贝mimi 包

cd /root

cat install.log | grep -v "^*" |  awk '{print $2}' >package.txt

for i in $(cat package.txt); do cp /media/Packages/${i}* /root/os/ ; done

4.创建光驱yum仓库.

cp /media/repodata/*c6-x86_64-comps.xml  /root/minimal-x86_64.xml

5.重新生成repo

  declare -x discinfo=$(head -1 /root/os/.discinfo

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

6.cp ks.cfg  /root/os/isolinux/    

   cat  /root/os/isolinux/isolinux.cfg 


default vesamenu.c32
#prompt 1
timeout 100

display boot.msg

menu background splash.jpg
menu title Welcome to CentOS 6.9!
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 linux
  menu label ^Install system  
  menu default
  kernel vmlinuz
  append initrd=initrd.img ks=cdrom:/isolinux/ks.cfg


7.制作iso

cd /root

mkisofs -o OS-6.9_64.iso -input-charset utf-8 -b isolinux/isolinux.bin -c      isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T -joliet-long  /root/os/


8.生成iso文件md5值

implantisomd5    OS-6.9_64.iso



装系统测试^_^




你可能感兴趣的:(系统)