PXE网络启动安装Linux系统

(red hat linux enterprises  5.3测试,成功安装系统)

安装需要DHCP,TFTP,xinet服务,至于系统的安装包,可以使用NFS,WEB,FTP服务提供,我使用的是NFS。文中紫色的字代表实际操作命令。

首先配置DHCP(/etc/dhcpd.conf),这里我用模板作为例子来进行配置:

vim /etc/dhcpd.conf

ddns-update-style interim;
ignore client-updates;

subnet 192.168.0.0 netmask 255.255.255.0 { 子网声明,请根据自己情况修改

# --- default gateway
option routers 192.168.0.1; 默认网关,请根据自己情况修改
option subnet-mask 255.255.255.0; 子网掩码,请根据自己情况修改

# option nis-domain "domain.org"; NIS域,我没使用
# option domain-name "domain.org"; DNS域,我没使用
# option domain-name-servers 192.168.1.1; DNS服务器地址,我没使用

option time-offset -18000; # Eastern Standard Time
# option ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
# option netbios-node-type 2;

range dynamic-bootp 192.168.0.128 192.168.0.254; 地址池,请根据自己情况修改
default-lease-time 21600; 默认地址租期,请根据自己情况修改
max-lease-time 43200; 最长地址租期,请根据自己情况修改

next-server 192.168.0.1; 我没使用DNS,所以直接写IP地址,请根据自己情况自行修改,PXE文件所在服务器
filename "pxelinux.0"; 新添加的

# we want the nameserver to appear at a fixed address
# host ns { 主机声明,这里没有使用,毕竟网络安装就是为了多台主机同时使用
# next-server marvin.redhat.com;
# hardware ethernet 12:34:56:78:AB:CD;
# fixed-address 207.175.42.254;
# }
}



配置 TFTP(/etc/xinetd.d/tftp):

vim /etc/xinetd.d/tftp

# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol. The tftp protocol is often used 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 /tftpboot
disable = no 改为no
per_source = 11
cps = 100 2
flags = IPv4
}



以上配置完后重启服务:

service dhcpd restart 重启DHCP服务
service xinetd restart 重启xinet服务

设置开机时自动启动:
chkconfig --level 35 dhcpd on 在init级别3和5的时候启动DHCP
chkconfig tftp on 自动启动TFTP
chkconfig --level 35 xinetd on 在init级别3和5的时候启动xinet



配置PXE

复制 /usr/lib/syslinux/pxelinux.0 到 /tftpboot 目录中。

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

关于 /tftpboot 目录,我安装TFTP时系统自动建立好了,没有自动建立的,请手工建立此目录。
mkdir /tftpboot

在 /tftpboot 目录中创建 pxelinux.cfg 目录用来存放配置文件。
mkdir /tftpboot/pxelinux.cfg

复制第一张安装光盘下 /p_w_picpath/pxeboot/initrd.img 和 vmlinux 复制到 /tftpboot 目录中。并把 /isolinux/*.msg 也复制到 /tftpboot 目录中。最后将 /isolinux/isolinux.cfg 复制到 /tftpboot/pxelinux.cfg 目录中,并改名为 default 。

至此,你的PXE服务就配置完成了,当然了,这只是最基本的配置方法,这里就不说安装源的配置方法了。



转载于:https://blog.51cto.com/xinnuo/1179863