一、简单概述
1.1 Kickstart 概述
对于网络安装系统,在linux 下面最熟悉的应该就是 Kickstart 以及 cobbler。写这篇文章的目的在于我公司目前使用的就是 Kickstart,所有操作系统的版本为 Centos 6.4,和个人的习惯不同,个人崇尚前沿技术以及由于以前做Docker相关,所有操作系统也是Centos 7.2以上版本,对于网络安装系统选择,个人也推荐使用 cobbler。好了,废话就不多说了,如果大家有兴趣可以参考cobbler相关文档,接下来我们就准备相关实验环境。
1.2 满足Kickstart安装系统的需求
1) 网卡必须支持PXE引导;
2) 客户端需要有与Kickstart 通信的IP地址,这里一般都是通过DHCP自动分配IP地址来实现;
3) 提供引导所需的文件,内核文件,内核镜像文件等,此时一般通过tftp-server等实现;
4) kickstart文件,它主要实现自动化安装的过程,比如配置主机名、添加用户、安装系统后相关操作;
5) 提供安装源,一般就是NFS/ftp/httpd等;
总结:通过如上需求,我们就知道需要安装的相关服务,如DHCP/tftp-server/syslinux/kickstart/vsftpd等;
二、配置Kickstart
2.1 环境准备
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# getenforce
Permissive
提示:我这里是能出公网,所以就不配置私有yum原,如果不能出公网,根据自己环境配置yum源即可,这里过程就略;2.2 准备安装源
2.3 安装DHCP服务
1 |
|
###备份原始配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
###在多网卡的情况下绑定网卡启动DHCP服务
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
###启动服务
1 2 3 |
|
2.4 安装ftp
1 |
|
###挂载镜像
1 2 3 |
|
提示:如果是光盘镜像可以这样挂载,mount /opt/CentOS-7-x86_64-Minimal-1511.iso /var/ftp/pub -o loop,但是如果你的ks.cfg文件也放到/var/ftp/pub目录下,注意不要被覆盖掉;
###查看相关内容
1 |
|
###启动vsftp服务
1 2 |
|
2.5 tftp安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
###配置tftp-server
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
2.6 配置Kickstart
[root@localhost ~]# cp ~/anaconda-ks.cfg /var/ftp/pub/ks.cfg
[root@localhost ~]# cat /var/ftp/pub/ks.cfg
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Install OS instead of upgrade
install
# Use network installation
url --url="ftp://192.168.100.1/pub"
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
network --bootproto=dhcp --device=eno16777736 --onboot=yes --ipv6=auto
network --hostname=localhost.localdomain
# Root password
rootpw --iscrypted $6$JqUyORpkn8xu8.i/$60aNcdZwMEjSkRgB3nqDrNw0sWJ7PYTUM/EKjvZWYgD8jkfiuEU8vjhI/BqVYcJvs6UiOpf5GtH3jwBAfhBSP0
# System timezone
timezone Asia/Shanghai --isUtc
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
autopart --type=lvm
# Partition clearing information
clearpart --none --initlabel
# SELinux configuration
selinux --disabled
%packages
@^minimal
@core
kexec-tools
%end
%addon com_redhat_kdump --enable --reserve-mb='auto'
%end
1 2 |
|
###检查是否存在错误
###启动相关服务
1 2 3 4 5 |
|
相关链接:https://access.redhat.com/documentation/zh-CN/Red_Hat_Enterprise_Linux/7/html/Installation_Guide/sect-kickstart-syntax.html
相关链接:http://www.tecmint.com/install-pxe-network-boot-server-in-centos-7/