centos定制
centos定制
centos定制主要是制作合适自己的iso系统进行批量安装,此例制作出来的iso是一个lnmp环境,其中nginx、php为自己打包的rpm包。iso制作方法参照了http://www.lampbo.org/linux-xuexi/linux-advance/diy-centos6.html
1、安装centos6,本例使用的是centos6.4-minimal系统
wget http://mirrors.sohu.com/centos/6.4/isos/x86_64/CentOS-6.4-x86_64-minimal.iso
2、安装制作工具
yum -y install anaconda repodata createrepo mkisofs
3、挂载光盘
mkdir /mnt/cd1 mount /dev/cdrom /mnt/cd1
4、 创建ios制作目录,将光盘内容拷贝到该目录
mkdir /mnt/centos cp -rp /mnt/cd1/* /mnt/centos cp /mnt/.discinfo /mnt/.treeinfo /mnt/centos
5、 配置kickstart文件,实现系统定制化安装依靠该文件
vi /mnt/centos/isolinux/ks.cfg# Kickstart file automatically generated by anaconda.#version=DEVELinstall #表示是安装,而不是升级cdrom #安装方式lang en_US.UTF-8 #语言keyboard us #键盘network --onboot no --device eth0 --bootproto dhcp --noipv6 #网络rootpw --iscrypted $6$QmGgBxnXalA0DBxs$gtaacsziglTjjNJwNYKWP/QOjqXDvlmkgBGxROU5dL25x7LIizk4Ol8CTINfWQdalpzvji22GkNU9UxZsJ2jP/ #root密码,默认123456firewall --service=ssh #开启防火墙,打开sshauthconfig --enableshadow --passalgo=sha512 #加密方式selinux –disabled #关闭selinuxtimezone --utc Asia/Shanghai #时区bootloader --location=mbr --driveorder=sda #引导程序相关参数# 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 --linux --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=4032 --maxsize=4032#part /boot --fstype=ext4 --size=500#part pv.008002 --grow --size=1#repo --name="CentOS" --baseurl=cdrom:sr0 --cost=100%packages --nobase #需要安装的软件包 @安装软件包组 --不安装的软件@core apr autoconf automake cloog-ppl cpp fontconfig fontconfig-devel gcc gcc-c++ gd glib2-devel keyutils-libs-devel libgomp libICE libidn-devel libjpeg-turbo libjpeg-turbo-devel libpng libpng-devel libsepol-devel libSM libstdc++-devel libtool libX11 libX11-common libX11-devel libXau libXau-devel libxcb libxcb-devel libXext libxml2 libxml2-devel libXpm libXpm-devel libXt make mpfr ncurses-devel pcre-devel perl perl-DBD-MySQL perl-DBI pkgconfig ppl xorg-x11-proto-devel zlib-devel libmcrypt nginx php mysql mysql-server %post #安装后执行脚本echo -ne " * soft nofile 65535 * hard nofile 65535 " >>/etc/security/limits.conf#set sysctl true > /etc/sysctl.conf cat >> /etc/sysctl.conf << EOF net.ipv4.ip_forward = 0 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.default.accept_source_route = 0 kernel.sysrq = 0 kernel.core_uses_pid = 1 net.ipv4.tcp_syncookies = 1 kernel.msgmnb = 65536 kernel.msgmax = 65536 kernel.shmmax = 68719476736 kernel.shmall = 4294967296 net.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_fin_timeout = 30net.ipv4.tcp_max_tw_buckets = 5000net.ipv4.tcp_keepalive_time = 600net.ipv4.tcp_synack_retries = 5net.ipv4.tcp_syn_retries = 1net.ipv4.ip_local_port_range = 1024 65535 EOF /sbin/sysctl -p %end
6、将需要安装的rpm包到/mnt/centos/Packages目录下
7、修改isolinux.cfg启动文件
vi /mnt/centos/isolinux/isolinux.cfg label linux menu label ^Install or upgrade an existing system menu default kernel vmlinuz append ks=cdrom:/isolinux/ks.cfg initrd=initrd.img
8、修改comps.xml文件,每次在/mnt/centos/Packages目录添加rpm包后需要更新此文件
cd /mnt/centos mv /mnt/centos/repodata/*-comps.xml comps.xml ls /mnt/centos/repodata/|grep -v “comps.xml”|xargs -I rm -f {} createrepo -g /mnt/centos/repodata/comps.xml mv /mnt/centos/repodata/*-comps.xml comps.xml declare -x discinfo=`head -1 /mnt/centos/.discinfo` createrepo -u "media://$discinfo" -g repodata/comps.xml /mnt/centos
9、生成iso文件
cd /mnt/centos mkisofs -o centos6.4-sylee-x86_64.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T /mnt/centos/