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

相关推荐

  • 第四周作业

    1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。[root@localhost ~]# cp -r /etc/skel/ /home/tuser1[root@localhost /]# chmod -R g=,o= /home/tuser1 2、编辑/etc/group文件…

    Linux干货 2017-03-04
  • M22 Centos环境设置

    Centos有4个地方存储环境变量:/etc/profile /etc/bashrc ~/.bash_profile ~/.bashrc /etc/profile:定义了系统环境变量pathmunge()函数如果第二个参数是“after”,PATH=$PATH:$1设置MAIL路径为/var/spool/mail/$USER设置root帐号的环境变量设置HI…

    Linux干货 2017-03-05
  • 【典韦文章】zabbix实现微信报警

    作者 典韦,追马代发 一、注册微信公众号 首先申请微信公众平台https://mp.weixin.qq.com/一个人最多申请5个公众号,所以还是可以的 申请完之后就可以根据腾讯的提示使用微信公众号了,然后用你自己的微信扫描关注微信号。 就可以看到用户数了,接下来的就要使用的用户的微信ID号了。点击用户查看用户的微信ID号。在浏览器查看用户的微信ID号。就是…

    Linux干货 2015-08-24
  • 8.1作业习题

    1,创建testuser uid 1234,主组:bin,辅助组:root,ftp,shell:/bin/csh home:/testdir/testuser useradd -u 1234 -g bin -G root,ftp -s /bin/csh -d /testdir/testuser testuser 2.修改testuser uid:4321,主…

    Linux干货 2016-08-04
  • parted使用说明

    一.为什么使用parted命令     传统的MBR(Master Boot Record)分区方式,有一个局限:无法支持超过2TB的硬盘分区(单个分区超过2TB)。     GPT(GUID Partition Table)的分区表很好的解决了这个问题,但在Linux系统中,传…

    Linux干货 2015-04-13
  • N25-第四周

    一、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。     [root@localhost ~]# cp -r /etc/skel /home/tuser1      [root@localhost ~]# chmo…

    Linux干货 2017-01-09