PXE configuration notes (Linux)

Source: Internet
Author: User

Server side: RHEL5 (static IP 192.168.1.101)
SOURCE Gentoo System: The Gentoo system on the server comes from it, and the build kernel is executed on this machine.
Diskless client: The NIC is the AMD PCnet32 support PXE boot. The system is Gentoo on the RHEL5, booting via PXE
The experiment mainly has several next steps:

    • Compiling the Gentoo kernel
    • Configuring the DHCP server
    • Configuring the TFTP server
    • Configuring NFS
    • PXE Boot Gentoo

1. Compiling the Gentoo kernel
1) Configure kernel options
I am using the 2.6.30 kernel, make menuconfig to configure the following options (note to be selected as built-in, not module):
Network Support
Network Options
TCP/IP Networking
IP Kernel level Autoconfiguration
IP:DHCP Support
File Systems
Network File Systems
NFSClient Support
NFSClient Support for NFSVersion 3
NFSClient support for the NFSv3 ACL protocol extension
Root file System on NFS
Device Drivers
Network Device Support
Ethernet (100Mbit)--->
Select the NIC driver for the diskless client machine (view system configuration can be used LSPCI)
2) Compile the kernel
(Kernel 2.6) # make && make Modules_install
3) Install the kernel
The newly compiled kernel is arch/i386/boot/bzimage and will later be uploaded to the/tftpboot directory on the server.
2. Configuring the DHCP server on RHEL5
The DHCP server assigns an IP address to the diskless client and tells him the path to the bootloader file on the server. My/etc/dhcpd.conf is as follows:

#
# DHCP Server Configuration file.

#
Ddns-update-style Interim;
Ignore client-updates;

Subnet 192.168.1.0 netmask 255.255.255.0 {
Range 192.168.1.128 192.168.1.254;
Option Subnet-mask 255.255.255.0;
Option broadcast-address 192.168.1.255;
Option routers 192.168.1.1;
Option Domain-name-servers 192.168.1.1;
FileName "pxelinux.0";
Next-server 192.168.1.101;
}

Note that filename here is a relative path, relative to/tftpboot, so filename will be problematic if it is specified as "/tftpboot/pxelinux.0"
For your convenience, I've set DHCP to start automatically in RunLevel 3 4 5. Or it can be started manually, run
# service DHCPD Start
3. Configuring the TFTP server
1) Installing TFTP
Redhat comes with a tftp RPM package that can be installed directly. To set the boot up, you need to change the/etc/xined.d/tftp configuration file, set disable to No
Server_args =-s/tftpboot is the root directory of the TFTP server, I use the default/tftpboot here. The Bootloader,bootloader configuration file and the Gentoo kernel will be placed in this directory.
2) installation of pxelinux.0 and its configuration
Pxelinux.0 is a bootloader, similar to grub, through which load kernel, we can specify the location of the kernel and the boot parameters of the kernel in its configuration file
Installation and configuration are operating in the/tftpboot directory, the configuration of the/tftpboot directory structure is as follows:
Kernel-2.6.30-gentoo-r8
pxelinux.0
pxelinux.cfg/default
KERNEL-2.6.30-GENTOO-R8 is a compiled Gentoo kernel.
pxelinux.0 is a syslinux file that can be copied from syslinux-/core/pxelinux.0, syslinux can be obtained from here
pxelinux.cfg/default is a configuration file for Pxelinux
The Pxelinux will search for the configuration file with the 16 binary representation of the IP address, and if not found, remove the lowest one to continue looking. If all matches fail, the default file is used.
For example:
192.168.0.15 16 binary representation is c0a8000f.
It will search for the following configuration file, which will be used when it is first found.
pxelinux.cfg/c0a8000f
pxelinux.cfg/c0a8000
pxelinux.cfg/c0a800
pxelinux.cfg/c0a80
pxelinux.cfg/c0a8
pxelinux.cfg/c0a
pxelinux.cfg/c0
pxelinux.cfg/C
pxelinux.cfg/default
The contents of my default file are as follows:

Label Linux
Kernel. /kernel-2.6.30-gentoo-r8
Append root=/dev/NFS ip=dhcp nfsroot=192.168.1.101:/nfsroot RW

About pxelinux.cfgDetailed configuration information for the/default can be found in the syslinux documentation. Over here
The first line of labels must be Linux, and other names will not be found. Not subject to this restriction with default
The second line specifies the location of the kernel
The third line specifies a series of startup parameters
root=/dev/ NFS--Specifies the mount mode of root filesystem is NFS
IP=DHCP--Specify kernel to obtain IP address via DHCP
Nfsroot=192.168.1.101:/nfsroot--Specifies that root filesystem is located on the server/nfsroot
RW--Specifies that root filesystem be mounted in a read-write manner
The/nfsroot directory is NFSDirectory of the server export, which can be configured on the server NFSThe time to specify
Here also encountered a bit of a problem, I started in the boot option does not add RW, when the start will be error readonly filesystem. Kernel boot When the default is to mount the root of the RO, but it is supposed to execute the init script once again in the RW mount, do not know why this step is not executed, and finally in the kernel of the boot options add RW.
4. Configuration NFS
1) Start and configure NFS
RHEL5 in the system service. NFS。 For the sake of convenience, I have added the run Level 3 4 5 NFSFor self-booting
Edit/etc/exports File
My exports file is as follows:

/nfsroot 192.168.1.0/24 (Rw,no_root_squash)

/nfsroot--Specify the directory to export
192.168.1.0/24--Specifies the IP range on the network that can mount the directory
(Rw,no_root_squash)-RW Specifies the permission to read and write, No_root_squash ensures that the root user on the client NFSThe directory has root permissions after mount (because the diskless client starts with the root user NFSMount, if you do not have this option, the root user NFSAfter mount will be mapped to nobody user)
It is also important to note that there can be no spaces between 192.168.1.0/24 and (Rw,no_root_squash). This also cost me a lot of Kung fu troubleshoot, the beginning of mount after how all is read-only, and later found that there can be no space between the original.
2) Copy the Gentoo root directory to the RHEL5
Well equipped NFSThe Gentoo file system can then be TAR+SCP to the/nfsroot on the server RHEL5.
Here are two points to note:
i)/dev/console must exist, otherwise the error "Unable to open initial console" can be created by the following command/dev/console
# Mknod/nfsroot/dev/console C 5 1
II) The/proc directory must exist
3) Modify the/etc/fstab file of the diskless client
The contents of my file are as follows:

NFS NOATIME,RW 0 1
NONE/PROC proc Defaults 0 0

4) Remove the old NIC information
Since my diskless client and source Gentoo system are different machines, I want to remove the old NIC information from the source Gentoo system
Modify the file 192.168.1.101:/nfsroot/etc/udev/rules.d/70-persistent-net.rules, delete the information about the old MAC address.
5) Configure the network for diskless clients
Modify File 192.168.1.101:/nfsroot/etc/conf.d/net, add
config_eth0= ("NoOp")
This is the IP address that tells the system to get it directly with the kernel boot. If this is a DHCP or static address, it will stop at starting when it starts eth0
5. PXE Boot Gento
Okay, here's the exciting moment! PXE boot diskless client, shortly after the advent prompt login, done!

PXE configuration notes (Linux)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.