如何使用PXE自动安装linux

如何使用PXE自动安装linux,第1张

最近公司里要搞自动安装,我就研究了pxe,也从网上参考了不少资料,这里做了一些简单的整理,文字表达功底比较有限,大家别拍砖啊,呵呵

准备:

1,在VMware中安装了一个CentOS63(CentOS6.4系统,IP : 192.168.202.131)

2,在VMware中创建了一个CentOS65(空机器,未装操作系统)

3,CentOS镜像文件挂载在CentOS63的/media/CentOS_6.4_Final位置

操作步骤:

一,配置DHCP

1,安装dhcpd

yum install dhcp

2,修改dhcp配置文件/etc/dhcp/dhcpd.conf

ddns-update-style interim

ignore client-updates

allow booting

allow bootp

subnet 192.168.202.0 netmask 255.255.255.0 {

range 192.168.202.200 192.168.202.220

option routers 192.168.202.131

option subnet-mask 255.255.255.0

default-lease-time 21600

max-lease-time 43200

next-server 192.168.202.131

filename "pxelinux.0"

}

3,启动dhcpd

chkconfig --add dhcpd

service dhcpd start

使用命令可以看到dhcpd绑定了多个端口

[root@localhost init.d]# netstat -anp | grep dhcpd

udp0 0 0.0.0.0:67 0.0.0.0:* 3266/dhcpd

raw0 0 0.0.0.0:1 0.0.0.0:* 7 3266/dhcpd

unix 2 [ ] DGRAM18034 3266/dhcpd

注意:第2行raw表示绑定在ICMP协议上,协议号为1

二,配置TFTP

4,安装TFTP

yum install tftp-server

5,修改tftpd配置文件/etc/xinetd.d/tftp,ftp根目录为/var/lib/tftpboot

service tftp

{

socket_type = dgram

protocol = udp

wait = yes

user = root

server = /usr/sbin/in.tftpd

server_args = -s /var/lib/tftpboot

disable = no

per_source = 11

cps = 100 2

flags = IPv4

}

6,启动tftp服务(端口69)

/etc/init.d/xinetd restart

三,配置引导内核

7,下载pxe引导配置文件

yum install syslinux

cp `rpm -ql syslinux | grep '/pxelinux.0'` /var/lib/tftpboot

8,拷贝网络启动的内核文件

cp /media/CentOS_6.4_Final/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot

mkdir /var/lib/tftpboot/pxelinux.cfg

cp /media/CentOS_6.4_Final/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default

修改default文件:

default linux

prompt 1

timeout 60

display boot.msg

menu background splash.jpg

menu title Welcome to CentOS 6.4!

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 ks=http://192.168.202.131/ks.cfg initrd=initrd.img

四,配置kickstart

9,安装nginx,根目录/usr/local/nginx/html

yum install nginx

chkconfig --add nginx

service nginx start

10,拷贝操作系统源文件

mkdir /usr/local/nginx/html/dvd

cp -R /media/CentOS_6.4_Final/* /usr/local/nginx/html/dvd/

11,下载kickstart

yum install system-config-kickstart

cp /root/anaconda-ks.cfg /usr/local/nginx/html/ks.cfg

chmod 755 /usr/local/nginx/html/ks.cfg (不分配权限,外部无法通过http访问,会报403)

修改ks.cfg:

#platform=x86, AMD64, or Intel EM64T

#version=DEVEL

# Firewall configuration

firewall --disabled

# Install OS instead of upgrade

install

# Use text install

text

# Use network installation

url --url="http://192.168.202.131/dvd"

# Root password

rootpw --iscrypted $1$.IvWB.Gl$E4fI4Ez4Z8HyHRCZW5Btr0

# System authorization information

auth --useshadow --passalgo=sha512

# Run the Setup Agent on first boot

firstboot --reconfig

# System keyboard

keyboard us

# System language

lang zh_CN.UTF-8

# SELinux configuration

selinux --enforcing

# Installation logging level

logging --level=info

# System timezone

timezone Asia/Shanghai

# Network information

network --bootproto=dhcp --device=eth0 --onboot=yes

# System bootloader configuration

bootloader --location=mbr

# Clear the Master Boot Record

zerombr

# Partition clearing information

clearpart --all

# Disk partitioning information

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

part swap --fstype="swap" --size=1000

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

# Reboot after installation

reboot

%packages

@base

@core

gcc

%end

五,验证

12,修改CentOS65虚拟配置文件CentOS65.vmx,增加一行bios.bootDelay= "10000",即表示在启动bios的时候停留10秒(否则你根本来不及按任何键的)

给CentOS65加电(打开Power),按Esc选择从Network启动

如何用Windows2012R2搭建PXEServer目录Pre-Reading:..31.硬件、软件准备.52.添加Roles52.1.添加ActiveDirectoryDomainServices并配置5I.添加ADDSRole7II.进入ADDSWizard配置验证信息、根域名、NetBIOS域名、ADDS目录等信息,Install并重启。82.2.添加DHCPRole并配置DHCPv4和DHCPv6..16I.对将要作为PXE网口的网口配置静态IPv4和IPv6地址17II.添加DHCPRole19III.进入DHCPConfigurationWizard配置DHCPv423IV.进入DHCPConfigurationWizard配置DHCPv6.342.3.添加WindowsDeploymentServicesRole并配置40I.添加WDSRole41II.进入WDSWizard配置等信息,Install并重启.422.4.添加WebService(IIS)Role的FTP服务483.配置PXE的installimage和bootimage.503.1.将PXENICdriver集成到boot.wim和install.wim中503.2.在PXEServer的WDS服务中添加BootImage和InstallImage.563.3.开启WDS服务574.验证PXE是否配置成功.604.1.验证PXEServer配置是否成功的步骤.604.2.PXEServer未能正常提供服务的常见问题汇总..605.Linux系统PXE安装的配置.615.1.RHEL系统PXE安装的配置过程62I.为RHEL6.5x64系统配置目录和脚本文件.62II.配置有关RHEL6.5x64安装的系统架构、DHCPBootfileName、tftp等选项.675.2.SLES系统PXE安装的配置过程.695.3.SLES+KISO系统PXE安装的配置过程.695.4.VMware系统的配置过程..695.5.PXEReboot的配置过程..69Pre-Reading:PXE(Pre-bootExecutionEnvironment)是由Intel设计的一种网络协议,它可以使计算机通过网络启动。协议分为client和server两端,PXEclient端集成在网卡ROM中(即PXE启动需要网卡ROM的支持),当Client端计算机启动时,BIOS把PXEclient端网络启动请求调入内存执行,并显示出启动菜单,经用户选择后,PXEServer进行响应,将预定的启动文件传输给PXEclient,Client端将Server上的启动文件通过网络下载到本地运行。PXE协议的成功运行需要解决以下两个问题:a)既然是通过网络传输,那么计算机在启动时,它的IP地址由谁来配置;b)通过什么协议下载Linux内核和根文件系统。1.PXE启动涉及文件简介:a)pxelinux.0:是计算机的自展引导程序(bootstrap),负责系统的引导和启动,类似于BIOS的作用,会调用PXE的相关配置文件;b)pxelinux.cfg:存放PXE配置文件的文件夹;c)vmlinuz:Linux内核文件,是最简Linux系统;d)initrd.img:根文件系统,2.PXE启动流程:如图0所示。图0.PXE启动流程a)客户端在网络中寻找DHCP服务器,然后请求一个IP地址,服务器端收到请求后,给客户端分配一个IP;b)DHCP服务器联系到TFTP服务器为此客户端发送一个bootstrap(引导程序,pxelinux.0);c)客户端收到bootstrap后执行,bootstrap会请求TFTP服务器传送bootstrap的配置文件(pxelinux.cfg下的default),客户端收到后读取配置文件;d)根据配置文件内容和客户情况,客户端向TFTP服务端请求传送内核映象文件(vmlinuz)和根文件系统文件(initrd.img);e)客户端启动内核映象文件,PXE启动过程结束。1.硬件、软件准备硬件:DL380pGen8+331FLR网卡(注意:将要作为PXE端口的网口暂且不要连线);软件:Windows2012R2+稳定版SPP+syslinux405。组装Server,装OS,打HP官网上DL380pGen8配套的SPP(或一款较稳定的老版本SPP也可),将syslinux405拷贝到系统中。2.添加Roles关闭Public、Private、Domain三个防火墙。需要添加的Roles有ActiveDirectoryDomainServices、DHCP、WindowsDeploymentServices、WebService(IIS)的FTP,共四个,以下Roles的添加顺序不要颠倒,前后的Roles配置有依赖性。2.1.添加ActiveDirectoryDomainServices并配置ADDS服务简介:WhatistheADDSserverrole?ADDSprovidesadistributeddatabasethatstoresandmanagesinformationaboutnetworkresourcesandapplication-specificdatafromdirectory-enabledapplications.AdministratorscanuseADDStoorganizeelementsofanetwork,suchasusers,computers,andotherdevices,intoahierarchicalcontainmentstructure.ThehierarchicalcontainmentstructureincludestheActiveDirectoryforest,domainsintheforest,andorganizationalunits(OUs)ineachdomain.AserverthatisrunningADDSiscalledadomaincontroller.Organizingnetworkelementsintoahierarchicalcontainmentstructureprovidesthefollowingbenefits:?Theforestactsasasecurityboundaryforanorganizationanddefinesthescopeofauthorityforadministrators.Bydefault,aforestcontainsasingledomain,whichisknownastheforestrootdomain.?AdditionaldomainscanbecreatedintheforesttoprovidepartitioningofADDSdata,whichenablesorganizationstoreplicatedataonlywhereitisneeded.ThismakesitpossibleforADDStoscalegloballyoveranetworkthathaslimitedavailablebandwidth.AnActiveDirectorydomainalsosupportsanumberofothercorefunctionsthatarerelatedtoadministration,includingnetwork-wideuseridentity,authentication,andtrustrelationships.?OUssimplifythedelegationofauthoritytofacilitatethemanagementoflargenumbersofobjects.Throughdelegation,ownerscantransferfullorlimited


欢迎分享,转载请注明来源:夏雨云

原文地址:https://www.xiayuyun.com/zonghe/368736.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-12
下一篇2023-05-12

发表评论

登录后才能评论

评论列表(0条)

    保存