配置方法網上實在實在是很多,如果要更詳細的,大家可以直接到網上找,我不會在這裡寫的非常詳細,不會step by step的講述,最重要的是要知道實現原理!相信看了我下面的原理講解,能對你們看相關文檔帶來更大的幫助,因為真的有很多人在對著文檔做的時候更本不知道自己在做什麼!
流程化實現原理:
支持PXE的電腦開機(預先打開網卡PXE功能,網絡引導)---> DHCP給該電腦一個IP地址,並指明下一跳tftp文件服務器 ---> 電腦去tftp服務器上(/tftpboot 文件夾下面)下載到一個叫做 pxelinux.0的文件,並拿到pxelinux.cfg文件夾下的default配置文件 ---> 根據該配置文件加載內核等操作,同時該配置文件中可以指明ks.cfg文件的地址,這樣實現全程無人化安裝!
基本實現步驟:
1.DHCP服務器配置
[root@localhost ~]# cat /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
allow booting;
allow bootp;
subnet 192.168.1.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
# option nis-domain "domain.org";
# option domain-name "domain.org";
option domain-name-servers 192.168.1.1;
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.1.2 192.168.1.10;
default-lease-time 21600;
max-lease-time 43200;
next-server 192.168.1.112;
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;
2.tftp服務器配置
[root@localhost ~]# cat /etc/xinetd.d/tftp
# default: off
# de.ion: 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
per_source = 11
cps = 100 2
flags = IPv4
}
3.准備相關文件
安裝目錄樹,ks.cfg,initrd.img,pxelinux.0,pxelinux.cfg,vmlinuz
A--把安裝目錄樹拷貝到一個共享目錄中,例如,/var/ftp/pub下面,用ftp共享
B--ks.cfg也拷貝到 /var/ftp/pub下面
C--
cp /usr/lib/syslinux/pxelinux.0 /tftpboot
cp /media/cdrom/images/pxeboot/{initrd.img,vmlinuz} /tftpboot
mkdir /tftpboot/pxelinux.cfg
touch /tftpboot/pxelinux.cfg/default
default文件內容:(ftp地址自己改)
[root@localhost ~]# cat /tftpboot/pxelinux.cfg/default
default linux
prompt 1
timeout 60
display boot.msg
label linux
kernel vmlinuz
append initrd=initrd.img text ks=ftp://192.168.1.112/pub/ks.cfg