领导给了个任务,制作一个用于ESXi虚拟化平台CentOS最小化安装的CentOS模板,不弄不知道,和CentOS6有点小区别
安装系统
直接安装一个Minimal版本,分区当然一个大根分区最好啦。
定制系统
我把我的定制过程弄成了一个脚本
# 处理无用的yum源(内网,所有互联网源都用不上)
cd /etc/yum.repos.d
for file in $(\ls); do mv $file $file.bak; done
cat > CentOS-Lan.repo <<EOF
[c7-lan]
enabled=1
baseurl=http://mirrors.lan.localhost/centos/lan
name=CentOS Lan Mirror - $basearch
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOF
cd -
# 安装必备软件包,可以按需修改
yum -y install net-tools wget yum-plugin-remove-with-leaves yum-utils vim
# 安装 VMWare Tools
yum -y install open-vm-tools perl
# 停止日志服务
systemctl stop rsyslog
service auditd stop
# 清除yum缓存
yum clean all
# 删除无用日志文件
/usr/sbin/logrotate /etc/logrotate.conf --force
rm -f /var/log/*-???????? /var/log/*.gz
rm -f /var/log/dmesg.old
rm -rf /var/log/anaconda
# 清空日志文件
cat /dev/null > /var/log/audit/audit.log
cat /dev/null > /var/log/wtmp
cat /dev/null > /var/log/lastlog
cat /dev/null > /var/log/grubby
# 删除网卡 MAC 和 UUIDs,防止MAC冲突
sed -i '/^\(HWADDR\|UUID\)=/d' /etc/sysconfig/network-scripts/ifcfg-e*
# 默认启动网卡
sed -i -e 's@^ONBOOT="no@ONBOOT="yes@' /etc/sysconfig/network-scripts/ifcfg-e*
# 清空临时目录
rm -rf /tmp/*
rm -rf /var/tmp/*
# 删除anaconda生成的配置文件
rm -f ~root/anaconda-ks.cfg
# 清除root密码,不然别人部署了进不了系统
passwd -d root
# 清除历史
history -cw
# 关机
init 0
PS
vSphere.5.5或以下在系统支持列表里没有CentOS 7
版权属于:Ryan
原文链接:https://banck.net/2016/04/creating-vmware-centos-7-template/
转载时须注明出处及本声明