配置方法網上實在實在是很多,如果要更詳細的,大家可以直接到網上找,我不會在這裡寫的非常詳細,不會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 {
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 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 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;
# 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;
# }
}
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
}
# 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/p_w_picpaths/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
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
有問題可以和我交流,共同進步!