当前位置: 首页 >> 原创·技术 >> 201706161559 CentOS下Kickstart实现自动安装脚本 >> 正文

201706161559 CentOS下Kickstart实现自动安装脚本

7年前 (2017-06-16)     作者:iMoke     分类:原创·技术     阅读次数:2544     评论(0)    

每次一需要安装Linux系统,就是一个头疼的事,尤其是一个批次要安装10台服务器,一个一个手动配置,确实麻烦。

关于Kickstart,网上有的事教程,但是都没有达到我的目标。


每次一需要安装Linux系统,就是一个头疼的事,尤其是一个批次要安装10台服务器,一个一个手动配置,确实麻烦。

关于Kickstart,网上有的事教程,但是都没有达到我的目标。

我的目标是:

1.全程无人工干预---成功

2.rpm包由光盘包含---失败

3.等等


公开一下我的ks.cfg文件,放到原版iso的根目录

# Kickstart file automatically generated by anaconda.

#version=DEVEL
install
url --url="http://repo.mmoke.com/centos/6/os/x86_64/"
lang zh_CN.UTF-8
keyboard us
network --onboot yes --device eth0 --bootproto dhcp --noipv6
rootpw  --iscrypted 密文
# Reboot after installation
reboot
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512
selinux --enforcing
timezone Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto"
# 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 --initlabel

part /boot --fstype=ext4 --asprimary --size=200
part swap --asprimary --size=4096
part / --fstype=ext4 --grow --asprimary --size=200


repo --name="CentOS"  --baseurl=http://repo.mmoke.com/centos/6/os/x86_64/ --cost=100


%packages --nobase
@Core
%end

%post
#!/bin/sh
#Write By iMoke

#修改自定义yum
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
mv /etc/yum.repos.d/CentOS-Debuginfo.repo /etc/yum.repos.d/CentOS-Debuginfo.repo.bak
mv /etc/yum.repos.d/CentOS-fasttrack.repo /etc/yum.repos.d/CentOS-fasttrack.repo.bak
mv /etc/yum.repos.d/CentOS-Media.repo /etc/yum.repos.d/CentOS-Media.repo.bak
mv /etc/yum.repos.d/CentOS-Vault.repo /etc/yum.repos.d/CentOS-Vault.repo.bak
imokerepo="/etc/yum.repos.d/imoke.repo"
rm -rf $imokerepo
touch $imokerepo
echo "[repo.mmoke.com_base]">>$imokerepo
echo "name=CentOS-6 - Base">>$imokerepo
echo "baseurl=http://repo.mmoke.com/centos/6/os/x86_64/">>$imokerepo
echo "gpgcheck=1">>$imokerepo
echo "enable=1">>$imokerepo
echo "gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6">>$imokerepo
%end


修改一下原版光盘/isolinux/isolinux.cfg文件

label linux
  menu label ^Install or upgrade an existing system
  menu default
  kernel vmlinuz
  append initrd=initrd.img ks=http://repo.mmoke.com/centos/imoke_centos6.8-ks.cfg


我把官方的CentOS-6.8-x86_64-bin-DVD1.iso镜像精简了一下,删除repodata,Packages文件夹,精简后重新打包的ISO只有270M。

有几点是需要说明的

1.通过网络安装,局域网内的一个域名repo.mmoke.com

2.未禁用selinux

3.最后禁用本地yum源,同样使用本地yum源

4.我的脚本只安装Core,也就是最精简的安装,只安装222个包。


在CentOS6.8下,测试通过。

可能不是最合理的,但是是最适合我的。


除非注明,发表在“傲孤漠客”的文章『201706161559 CentOS下Kickstart实现自动安装脚本』版权归iMoke所有。 转载请注明出处为“本文转载于『傲孤漠客』原地址https://www.imoke.org/post/20170616539.html

评论

发表评论   

昵称*

E-mail*(建议输入,以便收到博主回复的提示邮件)

网站