PXE Network Boot is an Intel technology that can boot a system and install OS from remote image source. The prerequisites to achieve this include: a ROM embedded into a network card confroming Intel PXE specification, a DHCP server that can serve as a responser of the request sent by NIC card and assign an IP for it, a remote boottrap and kernel over TFTP protocol. In this demo, additionally we will use a NFS server that provides the actual image source.
Set up NFS Server
Served as a remote image source provider, we set up a NFS server that the images locates and will be remotely attached to a client. NFS is a cluster file system relatively simple and is readily provided in almost all the Linux distributions. So the first thing to do is to enable the NFS daemo. The NFS server processes are started from the /etc/init.d/nfs and /etc/init.d/nfslock files. Both of these files may be enabled with the customer chkconfig commands:
Code
# chkconfig nfs on
# chkconfig nfslock on
The behavior of NFS on your server may be controlled by the /etc/sysconfig/nfs file. This file contains the options used by the /etc/init.d/nfs file, and usually does not exist by default. So, firstly, start NFS daemon and tell the NFS process where the image source locates and can be mounted remotely by a client server. The more detailed behavior information of NFS process can be seen below:
NFS detailed info
The /etc/init.d/nfs file uses three programs that are essential to the NFS server subsystem: /usr/sbin/rpc.mountd, /usr/sbin/rpc.nfsd, and /usr/sbin/exportfs. The rpc.mountd daemon accepts the remote mount requests for the server's exported file systems. The rpc.nfsd process is a user space program that starts the nfsd kernel threads from the nfsd.o module that handles the local file system I/O on behalf of the client systems.
The exportfs command is responsible for reading the /etc/exports file and making the exported file system information available to both the kernel threads and the mount daemon. Issuing the exportfs -a command will take the information in /etc/exports and write it to /var/lib/nfs/xtab.
The number of nfsd threads that are started in the kernel determine the simultaneous number of requests that can be handled. The default number of threads started is eight, which is almost never enough for a heavily used NFS server. To increase the number of nfsd threads started, you can set a variable in the /etc/sysconfig/nfs file:
RPCNFSDCOUNT=128
The exact number of threads to start depends on a lot of factors, including client load, hardware speed, and the I/O capabilities of the server.
The nfsd threads receive client requests on socket number 2049 for either UDP/IP or TCP/IP requests. Which transport is used as a default depends on the Linux distribution and version. Some versions do not have NFS over TCP available. Performance is better over UDP, provided the network is robust.
Set up TFTP Server
TFTP is a file transfer protocal silimar to FTP but a lot more simpler. Install TFTP packages on the NFS server (or any other server). Further configure the root of the TFTP service via config file /etc/xinetd.d/tftp, a typical specification will look like:
tftp service
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -u nobody -s /tftpboot
disable = no
per_source = 11
cps = 100 2
}
Configure PXELINUX on TFTP server
Now configure PXELINUX on TFTP server so that the PXE client can know where to load an OS bootstrap and start the installation process. The necessary files include:
Code
pxelinux.0: a bootstrap provided by almost all of the Linux distributions. Just copy this file into /tfptroot/.
any kernel or initrd images: a mini system that are located on the same directory as pxelinux.0
pxelinux.cfg: a directory containing all the configuration files needed for installation process.
A sample configuration file looks like:
Sample cfg
DEFAULT install
PROMPT 1
LABEL install
KERNEL vmlinuz
APPEND initrd=initrd.img devfs=nomount ramdisk_size=16384
Configure DHCP server
A typical DHCP configuration looks like the following. Note that in the configuration file, it specifies the NIC address of the client, designates an IP for the client, and specifies the location of the TFTP server and bootstrap location.
Code
option space PXE;
option PXE.mtftp-ip code 1 = ip-address;
option PXE.mtftp-cport code 2 = unsigned integer 16;
option PXE.mtftp-sport code 3 = unsigned integer 16;
option PXE.mtftp-tmout code 4 = unsigned integer 8;
option PXE.mtftp-delay code 5 = unsigned integer 8;
option PXE.discovery-control code 6 = unsigned integer 8;
option PXE.discovery-mcast-addr code 7 = ip-address;
class "pxeclients" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
option vendor-class-identifier "PXEClient";
vendor-option-space PXE;
# At least one of the vendor-specific PXE options must be set in
# order for the client boot ROMs to realize that we are a PXE-compliant
# server. We set the MCAST IP address to 0.0.0.0 to tell the boot ROM
# that we can't provide multicast TFTP (address 0.0.0.0 means no
# address).
option PXE.mtftp-ip 0.0.0.0;
# This is the name of the file the boot ROMs should download.
filename "pxelinux.0";
# This is the name of the server they should get it from.
next-server 192.168.0.1;
}
ddns-update-style interim;
ignore client-updates;
default-lease-time 1200;
max-lease-time 9200;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.0.255;
option routers 192.168.0.254;
option domain-name-servers 192.168.0.1,192.168.0.2;
option domain-name "mydomain.org";
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.10 192.168.0.100;
}
host q10 {
hardware ethernet 00:00:F0:6B:38:5B;
fixed-address 192.168.0.22;
}
A demo reference can de found on IBM developer network: 如何远程安装Linux