centos定制

前端之家收集整理的这篇文章主要介绍了centos定制前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

centos定制

技术更容易入门 免费体验 >>>

hot3.png


centos定制

centos定制主要是制作合适自己的iso系统进行批量安装,此例制作出来的iso是一个lnmp环境,其中NginxPHP为自己打包的rpm包。iso制作方法参照了http://www.lampbo.org/linux-xuexi/linux-advance/diy-centos6.html

1、安装centos6,本例使用的是centos6.4-minimal系统

wgethttp://mirrors.sohu.com/centos/6.4/isos/x86_64/CentOS-6.4-x86_64-minimal.iso

2、安装制作工具

yum-yinstallanacondarepodatacreaterepomkisofs

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#Kickstartfileautomaticallygeneratedbyanaconda.#version=DEVELinstall#表示是安装,而不是升级cdrom#安装方式langen_US.UTF-8#语言keyboardus#键盘network--onbootno--deviceeth0--bootprotodhcp--noipv6#网络rootpw--iscrypted$6$QmGgBxnXalA0DBxs$gtaacsziglTjjNJwNYKWP/QOjqXDvlmkgBGxROU5dL25x7LIizk4Ol8CTINfWQdalpzvji22GkNU9UxZsJ2jP/#root密码,默认123456firewall--service=ssh#开启防火墙,打开sshauthconfig--enableshadow--passalgo=sha512#加密方式selinux�Cdisabled#关闭selinuxtimezone--utcAsia/Shanghai#时区bootloader--location=mbr--driveorder=sda#引导程序相关参数#Thefollowingisthepartitioninformationyourequested#Notethatanypartitionsyoudeletedarenotexpressed#heresounlessyouclearallpartitionsfirst,thisis#notguaranteedtowork#clearpart--linux--drives=sda#volgroupVolGroup--pesize=4096pv.008002#logvol/--fstype=ext4--name=lv_root--vgname=VolGroup--grow--size=1024--maxsize=51200#logvolswap--name=lv_swap--vgname=VolGroup--grow--size=4032--maxsize=4032#part/boot--fstype=ext4--size=500#partpv.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"
*softnofile65535
*hardnofile65535
">>/etc/security/limits.conf#setsysctltrue>/etc/sysctl.conf
cat>>/etc/sysctl.conf<<EOF
net.ipv4.ip_forward=0net.ipv4.conf.default.rp_filter=1net.ipv4.conf.default.accept_source_route=0kernel.sysrq=0kernel.core_uses_pid=1net.ipv4.tcp_syncookies=1kernel.msgmnb=65536kernel.msgmax=65536kernel.shmmax=68719476736kernel.shmall=4294967296net.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=102465535EOF

/sbin/sysctl-p

%end

6、将需要安装的rpm包到/mnt/centos/Packages目录下
7、修改isolinux.cfg启动文件

vi/mnt/centos/isolinux/isolinux.cfg
labellinux
menulabel^Installorupgradeanexistingsystem
menudefault
kernelvmlinuz
appendks=cdrom:/isolinux/ks.cfginitrd=initrd.img

8、修改comps.xml文件,每次在/mnt/centos/Packages目录添加rpm包后需要更新此文件

cd/mnt/centos
mv/mnt/centos/repodata/*-comps.xmlcomps.xml
ls/mnt/centos/repodata/|grep-v“comps.xml”|xargs-Irm-f{}
createrepo-g/mnt/centos/repodata/comps.xml
mv/mnt/centos/repodata/*-comps.xmlcomps.xml
declare-xdiscinfo=`head-1/mnt/centos/.discinfo`
createrepo-u"media://$discinfo"-grepodata/comps.xml/mnt/centos

9、生成iso文件

cd/mnt/centos
mkisofs-ocentos6.4-sylee-x86_64.iso-bisolinux/isolinux.bin-cisolinux/boot.cat-no-emul-boot-boot-load-size4-boot-info-table-R-J-v-T/mnt/centos/

猜你在找的CentOS相关文章