PXE无人值守安装linux

1.dhcp服务器安装

  用于为用户动态的分配ip地址

 [root@target ~]# mount /dev/cdrom /mnt/cdrom              //挂载镜像

 [root@target ~]# vim /etc/yum.repos.d/rhel-debuginfo.repo     //配置yum

PXE无人值守安装linux_Linux自动安装

 [root@target ~]# yum install dhcp                         //安装dhcp服务器

 [root@target ~]# vim /etc/dhcpd.conf                      //末行模式下执行如下命令获得配置文件   :r /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample    /

配置如下

PXE无人值守安装linux_Linux自动安装_02

 启动dhcp服务器,并且加入开机启动

 [root@target ~]# service dhcpd start

 [root@target ~]# chkconfig dhcpd on

2.配置ftp服务器

  用于提供系统安装所需的系统软件

  [root@target ~]# yum install vsftpd                              //安装服务器软件

  [root@target ~]# cp -R /mnt/cdrom/* /var/ftp/pub/                //把光盘中的系统文件copyftp中匿名文件夹中

  启动服务器,并设置开机启动

  [root@target ~]# service vsftpd start

  [root@target ~]# chkconfig vsftpd on

3.配置tftp服务器

  用于提供引导服务器安装时的终端配置

  [root@target ~]# yum install tftp-server                        //安装tftp软件

  [root@target ~]# vim /etc/xinetd.d/tftp                         //设置配置文件

  只需将disable=yes修改为 disable=no即可,用于设置tftp服务可启动

  [root@target ~]# service xinetd restart                         //启动tftp服务器(tftp是一个超级守护进程)

4.copy开机引导程序到tftp文件夹中

  [root@target ~]# cp /usr/lib/syslinux/pxelinux.0 /tftpboot/         //ftfp的驱动文件 

  [root@target ~]# cp /mnt/cdrom/p_w_picpaths/pxeboot/vmlinuz /tftpboot/  //pxe的内核文件

  [root@target ~]# cp /mnt/cdrom/p_w_picpaths/pxeboot/initrd.img /tftpboot/  //启动时与硬件相关驱动

  [root@target ~]# mkdir -pv /tftpboot/pxelinux.cfg                  //pxe所需目录

  [root@target ~]# cp /mnt/cdrom/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default    //所需配置文件

5.安装无人值守程序

  [root@target ~]# yum install system-config-kickstart               //软件安装

  执行配置命令

  [root@target ~]# system-config-kickstart

  

PXE无人值守安装linux_PXE无人值守安装linux_03

PXE无人值守安装linux_PXE无人值守安装linux_04

PXE无人值守安装linux_PXE_05

PXE无人值守安装linux_PXE无人值守安装linux_06

PXE无人值守安装linux_PXE_07

 

PXE无人值守安装linux_Linux自动安装_08

PXE无人值守安装linux_无人值守安装linux_09

PXE无人值守安装linux_PXE_10

 

 

PXE无人值守安装linux_PXE无人值守安装linux_11

PXE无人值守安装linux_Linux自动安装_12

 

保存配置

对保存的配置文件ks.cfg进行配置

 [root@target ~]# vim /root/ks.cfg 

 加入如下一行,可加任意地方

 

PXE无人值守安装linux_PXE无人值守安装linux_13

6.dhcp服务器中配置tftp服务器的查找

  将配置文件修改如下,只需加入两行

  [root@target ~]# vim /etc/dhcpd.conf  

PXE无人值守安装linux_无人值守安装linux_14

重启服务

 [root@target ~]# service dhcpd restart

7.配置tftp服务器,指明ftp服务器

[root@target ~]# vim /tftpboot/pxelinux.cfg/default

 

PXE无人值守安装linux_PXE无人值守安装linux_15

最好修改默认时间,否则会等10分钟才能够启动程序

timeout修改为6秒:timeout 6

8.copy ks.cfgftp服务器中

  [root@target ~]# cp /root/ks.cfg /var/ftp/pub/

9.测试

  我们是在虚拟机里面重新安装一个系统,所以先要排除一些虚拟机安装的外在条件

  Tftp,ftpdhcp服务器要与安装的服务器在同一个网段中,我使用的是host-noly

  删除虚拟机本身的dhcp服务器

   配置参数

   

PXE无人值守安装linux_PXE无人值守安装linux_16

   

PXE无人值守安装linux_Linux自动安装_17

等待安装成功即可,如果刚刚安装后,启动失败,则重新启动即可,在启动时可能会因为sendmail的启动,影响启动速度,耐心等待!!