码迷,mamicode.com
首页 > 其他好文 > 详细

PXE 详解

时间:2014-09-09 16:21:29      阅读:510      评论:0      收藏:0      [点我收藏+]

标签:pxe linux详解

PXE:全称为PrebooteXecution Environment ,可以基于网络给服务器安装系统,需要网卡支持网络启动引导,

一:需要准备的组件如下:

Yum install     xinetd  dhcpd   tftp-server httpd   syslinux

1TFTP服务器;为客户端提供简单文件共享服务,比如启动内核、配置文件等等

2DHCP服务器,作用为给客户端提供IP地址、掩码、网关、DNS、指定TFTP服务器地址

3FTPHTTP服务器,主要共享ks.cfg文件以及系统镜像

4xinetdtftp服务的守护进程

5syslinux是一个安装包,主要提供/usr/share/syslinux/pxelinux.0文件

 

二:配置DHCP服务:

 

[root@localhost ~]# cat/etc/dhcp/dhcpd.conf

subnet 192.168.100.0  netmask 255.255.255.0 {  #声明一个网段,不可是一个IP地址

  range 192.168.100.10 192.168.100.100;   #声明提供的IP地址范围

 option domain-name-servers 192.168.100.1;  #DNS地址

 option routers 192.168.100.1;  #网关

 default-lease-time 600;  #默认租约

 next-server 192.168.100.1; #TFTP服务器地址

 filename "pxelinux.0";   # pxe专用启动引导文件,直接存放在TFTP目录

 max-lease-time 7200;  #最长租约

}

 

三:准备tftp服务:

[root@localhost ~]# cat  /etc/xinetd.d/tftp

# default: off

# description: The tftp server serves filesusing the trivial file transfer \

#      protocol.  The tftp protocol is oftenused to boot diskless \

#      workstations, download configuration files to network-aware printers, \

#      and to start the installation process for some operating systems.

service tftp

{

       socket_type             = dgram

       protocol                = udp

       wait                    = yes

       user                    = root

       server                  =/usr/sbin/in.tftpd

       server_args             = -s/var/lib/tftpboot

       disable                 = no  #disabled改为no

       per_source              = 11

       cps                     = 100 2

       flags                   = IPv4

 

[root@localhost ~]# /etc/init.d/xinetd  restart #重启xinetd服务

停止 xinetd                                              [确定]

正在启动 xinetd                                          [确定]

 

四:准备ks.cfg文件(ks为文件名,可以自己定)

yum install system-config-kickstart

# system-config-kickstart

 

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣


 


 


 


 


 

  

注:ks.xfg文件内容:

 

[root@localhost html]# cat ks.cfg

#platform=x86, AMD64, or Intel EM64T

#version=DEVEL

# Firewall configuration

firewall --disabled

# Install OS instead of upgrade

install

# Use network installation

url--url="http://192.168.100.1/centos6"

# Root password

rootpw --iscrypted$1$DoekR6CB$6acDFNurEa.MsWUlGmUJQ.

# System authorization information

auth --useshadow  --passalgo=sha512

# Use text mode install

text

# System keyboard

keyboard us

# System language

lang en_US

# SELinux configuration

selinux --disabled

# Do not configure the X Window System

skipx

# Installation logging level

logging --level=info

# Reboot after installation

reboot

# System timezone

timezone Asia/Shanghai

# System bootloader configuration

bootloader --location=mbr

# Clear the Master Boot Record

zerombr

# Partition clearing information

clearpart --all --initlabel

# Disk partitioning information

part /boot --fstype="ext4"--size=200

part / --fstype="ext4" --grow--size=1

 

%packages

@additional-devel

@base

@basic-desktop

@desktop-debugging

@desktop-platform

@desktop-platform-devel

@development

@eclipse

@emacs

@fonts

@general-desktop

@graphical-admin-tools

@graphics

@hardware-monitoring

@input-methods

@internet-applications

@internet-browser

@java-platform

@legacy-x

@office-suite

@performance

@perl-runtime

@remote-desktop-clients

@ruby-runtime

@server-platform-devel

@system-management

@system-management-messaging-client

@system-management-snmp

@system-management-wbem

@technical-writing

@tex

@x11

 

%end

 

五:启动文件准备

/var/lib/tftpboot/pxelinux.cfg/vmlinuz  #启动内核

initrd.img  #系统初始化

boot.msg  #主题

vesamenu.c32 #启动菜单主程序

splash.jpg  #启动背景

pxelinux.0  #tftp引导文件

/var/lib/tftpboot/pxelinux.cfg/default

cp /var/www/html/centos6/images/pxeboot/{vmlinuz,initrd.img}   /var/lib/tftpboot/

cp /var/www/html/centos6/isolinux/{boot.msg,vesamenu.c32,splash.jpg}  /var/lib/tftpboot/

cp /usr/share/syslinux/pxelinux.0/var/lib/tftpboot/

mkdir /var/lib/tftpboot/isolinux.cfg

cp /mnt/isolinux/isolinux.cfg/var/lib/tftpboot/pxelinux.cfg/default

 

编辑default文件:

 

[root@localhost pxelinux.cfg]# cat default

default vesamenu.c32

#prompt 1

timeout 600

 

display boot.msg

 

menu background splash.jpg

menu title Welcome to CentOS 6.5!

menu color border 0 #ffffffff #00000000

menu color sel 7 #ffffffff #ff000000

menu color title 0 #ffffffff #00000000

menu color tabmsg 0 #ffffffff #00000000

menu color unsel 0 #ffffffff #00000000

menu color hotsel 0 #ff000000 #ffffffff

menu color hotkey 7 #ffffffff #ff000000

menu color scrollbar 0 #ffffffff #00000000

 

label linux

 menu label ^Install or upgrade an existing system

 menu default

 kernel vmlinuz

 append initrd=initrd.img ks=http://192.168.100.1/ks.cfg ksdevice=link #指定ks.cfg文件路径

label vesa

 menu label Install system with ^basic video driver

 kernel vmlinuz

 append initrd=initrd.img xdriver=vesa nomodeset

label rescue

 menu label ^Rescue installed system

 kernel vmlinuz

 append initrd=initrd.img rescue

label local

 menu label Boot from ^local drive

 localboot 0xffff

label memtest86

 menu label ^Memory test

 kernel memtest

 append -

 

[root@localhost pxelinux.cfg]# mount /dev/cdrom  /var/www/html/centos6/  #挂载光盘

mount: block device /dev/sr0 iswrite-protected, mounting read-only

 

[root@localhost html]# chmod  744  ks.cfg  #给普通用户读权限

 

[root@localhost html]#/etc/init.d/httpd  restart   #重启http服务

停止 httpd                                               [确定]

正在启动 httpdhttpd: Could not reliably determine the server‘s fully qualifieddomain name, using localhost.localdomain for ServerName

                                                          [确定]

 

六:客户端安装测试:

 如果安装过程中出现错误,会有相应提示,要根据提示进行排错

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


本文出自 “Linux 学习” 博客,请务必保留此出处http://zhangshijie.blog.51cto.com/806066/1550228

PXE 详解

标签:pxe linux详解

原文地址:http://zhangshijie.blog.51cto.com/806066/1550228

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!