Kickstart实现CentOS 6.5的网络自动安装

1.KickStart

KickStart是一种无人职守安装方式。KickStart的工作原理是通过记录典型的安装过程中所需人工干预填写的各种参数,并生成一个名为ks.cfg的文件;在其后的安装过程中(不只局限于生成KickStart安装文件的机器)当出现要求填写参数的情况时,安装程序会首先去查找KickStart生成的文件,当找到合适的参数时,就采用找到的参数,当没有找到合适的参数时,才需要安装者手工干预。这样,如果KickStart文件涵盖了安装过程中出现的所有需要填写的参数时,安装者完全可以只告诉安装程序从何处取ks.cfg文件,然后去忙自己的事情。等安装完毕,安装程序会根据ks.cfg中设置的重启选项来重启系统,并结束安装。

PXE + KickStart安装的条件

2.实验环境

组件:

 dhcp:动态分配Ip地址 

 httpd:基于web访问centos镜像文件

 tftp:存放linux pxe引导文件

 syslinux:syslinux是一个功能强大的引导加载程序

服务器:

  主机centos6.5  IP:192.168.180.130

 安装:dhcp httpd tftp syslinux服务

3.操作步骤

一.安装相关组件

[root@localhost ~]#yum -y install dhcp* httpd* tftp* syslinux*

挂载CentOS6.5DVD光盘,并复制第一张光盘下的所有内容(文件和文件夹)到/var/www/html/centos(centos目录需要自己创建)下(apache默认网站根目录)

[root@localhost ~]#mount /dev/cdrom  /mnt/
[root@localhost ~]#cp -rf /mnt/* /var/www/html/centos

二、配置apache

[root@localhost ~]#service httpd start

三、配置tftp

[root@localhost ~]#vim /etc/xinetd.d/tftp
修改14行disable = no

[root@localhost ~]#/etc/init.d/xinetd start

四、配置dhcp

[root@localhost ~]#vim /etc/dhcp/dhcpd.conf
ddns-update-style  interim;
default-lease-time 216000;
filename "/pxelinux.0";
max-lease-time 43200;
next-server 192.168.180.130;
subnet 192.168.180.0 netmask 255.255.255.0 {
         option   subnet-mask 255.255.255.0;
         option   routers      192.168.180.2;
         range dynamic-bootp 192.168.180.2 192.168.180.200;
         default-lease-time 21600;
}

五、配置支持PXE启动

我已经把第一张光盘的内容复制到/var/www/html目录中了,所以所需要的文件我只需要从/var/www/html目录中复制就行了

1、进入tftpboot文件夹,没有就建一个,有了就不用建了。
[root@localhost ~]#cd /var/lib/tftpboot/

2、把pxelinux.0复制到/tftpboot/中
[root@localhost ~]#cd  /usr/share/syslinux 
[root@localhost ~]#cp pxelinux.0 /var/lib/tftpboot
[root@localhost ~]#cp vesamenu.c32 /var/lib/tftpboot

3、把Linux第一张安装光盘上/images/pxeboot/initrd.img和vmlinux复制到/tftpboot/中
[root@localhost ~]#cp /var/www/html/images/pxeboot/initrd.img   /var/lib/tftpboot
[root@localhost ~]#cp /var/www/html/images/pxeboot/vmlinux   /var/lib/tftpboot

4、 复制第一张安装光盘上的isolinux/*.msg到/tftpboot/中
[root@localhost ~]#cp /var/www/html/isolinux/*.msg   /var/lib/tftpboot

5、 在tftpboot中新建一个pxelinux.cfg目录
[root@localhost ~]#mkdir pxelinux.cfg

6、 把Linux第一张安装光盘上isolinux目录中的isolinux.cfg复制到pxelinux.cfg目录中,并同时更改文件名称为default
[root@localhost ~]# cd pxelinux.cfg
[root@localhost ~]# cp /var/www/html/isolinux/isolinux.cfg   /var/lib/tftpboot/pxelinux.cfg/default
[root@localhost ~]# vim /var/lib/tftpboot/pxelinux.cfg/default
把22行注释掉,在下面添加:
append initrd=initrd.img ks=http://192.168.180.130/ks.cfg

六、修改/var/www/html/ks.cfg文件,指定读取ks.cfg的方法

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use CDROM installation media
url --url=http://192.168.180.130/centos/
# Root password
rootpw --iscrypted $1$mR96CBFs$tpDEL7evE3eL2UjJ5PjG2.
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone  Asia/Shanghai
# Network information
network  --bootproto=dhcp --device=eth0 --onboot=on
# System bootloader configuration
bootloader --append="crashkernel=auto rhgb quiet" --location=mbr --driveorder="sdb"
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel 
# Disk partitioning information
part /boot --fstype="ext4" --size=200
part swap --size=4096
part / --fstype="ext4" --size=40960
%pre
echo "start install"
%end

%post
echo "install end"
%end
#程序包段
%packages
@chinese-support
@development
@X Window System
@remote-desktop-clients
%end

七、设置服务开机自启动:

[root@localhost ~]# chkconfig httpd on
[root@localhost ~]# chkconfig xinetd on
[root@localhost ~]# chkconfig dhcpd on

八.设置bios为网卡启动,启动后,就会进入到安装界面,并自行安装。

wKiom1PY2SfRSt0IAACxjGMXu60908.jpg

wKioL1PY2l6xlTfPAACCoZlPM4U767.jpg

原创文章,作者:a295053193,如若转载,请注明出处:http://www.178linux.com/53336

(0)
a295053193a295053193
上一篇 2016-10-24 09:11
下一篇 2016-10-24 09:11

相关推荐

  • centos启动流程

    1、centos启动流程 简单流程简介: POST –> Boot Sequence(BIOS) –> Boot Loader (MBR) –> Kernel(ramdisk) –> rootfs –> switchroot –> /sbin/init…

    Linux干货 2016-09-09
  • 8.6正则表达式grep及其他文本处理命令练习

    正则表达式grep及其他文本处理命令练习 上课练习 1 1、centos 6找出ifconfig命令结果中本机的IPv4地址 [root@qzx ~]# ifconfig|head -n 2|tail -n 1|tr -s ' [:alpha:]'&…

    Linux干货 2016-08-07
  • VIM 文 本 编 辑 工 具-20160808

    VIM 文 本 编 辑 工 具 §·学习大纲   一·使用vi和vim的三种主要模式 二·扩展模式下基本操作 三·命令模式下基本操作 四·编辑模式下基本操作 五·VIM寄存器 六·编辑二进制文件 七·可视化模式 八·多文件模式 九·使用多个“窗口” 十·定制vim的工作特性 十一·VIM了解更多 十二·练习题     §·使用v…

    Linux干货 2016-08-10
  • centos7 yum源仓库网络共享

    一般yum源仓库需要两部分组成,一部分为rpm程序包,另一个就是repodata元数据组成。制作一个简单的网络共享yum源仓库,在制作网络共享服务器需要事先配备好你的yum源,以方便使用 1.安装网络共享yum源仓库服务 以ftp为例: (1)在centos7中是否有ftp,用rpm -q 对vsftpd程序包查看 [root@local…

    Linux干货 2017-04-23
  • 2

    2

    Linux干货 2018-03-26
  • iptables

    iptables 包过滤型的防火墙 Firewall:防火墙,隔离工具;工作于主机或网络边缘,对于进出本主机或本网络的报文根据事先定义的检查规则作匹配检测,对于能够被规则匹配到的报文作出相应处理的组件; 主机防火墙网络防火墙 软件防火墙(软件逻辑)硬件防火墙(硬件和软件逻辑) 版本 ipfw (firewall framework):命令行工具,生成规则并送…

    Linux干货 2017-06-13