Construction of Linux Diskless Workstation Network Environment

1 Diskless Workstation and Its Principle

1.1 Diskless Workstation A

diskless workstation is a computer terminal without a hard disk.
It does not contain a hard storage device itself. When the machine boots, it needs to transfer the operating system startup file to the local memory with the help of a server on the network, and then the startup can be completed. Therefore, a diskless workstation must have a CPU, motherboard, memory, network card and remote boot device. The remote boot device is mainly solidified or plugged into the network card in the form of a chip. When the system starts, it is responsible for connecting to the server, obtaining the IP address, and instructing the transmission of the operating system boot file on the server to the local memory. At present, there are mainly two kinds of remote boot chips, RPL and PXE. The latter is an upgraded version of the former and is currently being widely used.
1.2 PXE chip startup principle

When the PXE chip starts remotely, it first needs to perform a DHCP session process to obtain an IP address and related information for subsequent file transfer; after the IP address is successfully obtained, the PXE chip triggers the TFTP session process, according to DHCP The relevant information acquired by the process requests a startup file from the server. After receiving the request, the server sends the corresponding startup file according to the local policy. After receiving the startup file, the workstation starts the local startup process.
The above is a brief description of the startup process of the PXE chip diskless workstation. For the relevant content of the DHCP protocol, please refer to the RFC2131 standardization document, and the relevant content of the TFTP protocol, please refer to the RFC1350 standardization document.
For the Linux operating system, the boot files that PXE needs to download are configuration files and kernel files. Among them, the configuration file is included in the DHCP response message and obtained through the TFTP session process; the name and location of the kernel file are given in the configuration file, and also need to be obtained through the TFTP session process; after the kernel file is successfully obtained, the system starts to start locally , when the startup process needs to load the file system, PXE will request the server to connect to the server directory corresponding to the root file system (the file system is the NFS network root file system) according to the configuration file. If successful, the startup will end. Figure 1-1 on the next page shows an interaction model for this process.
The detailed startup process of Linux diskless workstation is as follows:
Step 1 The workstation is powered on, and the PXE chip performs self-checking;
Step 2 When it is ready to start, the PXE chip sends a DHCP request;
Step 3 The server receives the request from the workstation and sends a DHCP response, including the client's IP address, default gateway, and DNS server and the location of the boot image file (configuration file and kernel);
Step 4 The PXE chip on the workstation starts a TFTP session request to download the file according to the location of the configuration file;
Step 5 Load the image file, start local boot, and mount the NFS network root file System;
Step 6 The Login line appears, and the startup is successful.

Figure 1-1 Network interaction during PXE chip booting
1.3 Overview of the configuration process

According to the above description, it is not difficult to know that the core work of configuring a diskless network environment lies in the configuration of the diskless network file server, and the configuration of the file server is determined by It consists of several parts such as DHCP and TFTP. Therefore, it is not difficult to know that to configure the network environment of the Linux diskless workstation, the following tasks need to be completed in turn:
(1) Select and install the Linux operating system on the diskless network file server;
(2) Configure the basic network environment of the operating system;
( 3) Configure the DHCP server;
(4) Configure the TFTP server;
(5) Create a working directory, configuration file and kernel file
for the workstation; (6) Build a reasonable and standardized Linux file system for the workstation;
(7) Start the workstation and proceed necessary debugging.
2 Detailed configuration instructions

2.1 Selection and installation of operating system

First, choose an operating system for your server that is suitable for a diskless workstation network environment. This operating system should have powerful network functions, optimized processing speed, and high stability. When choosing an operating system, do not choose a PC system with a server version, but choose a network operating system specially developed for server and large machine applications. After consideration, we decided to choose Red Hat Enterprise Linux Advanced Server 4 (RHAS4) operating system for this configuration. This system is an operating system specially designed by Red Hat for enterprise servers. Powerful, close to standard Linux, easy to operate and manage.
2.2 Basic network environment configuration

Building the most basic network environment is what any network server must do well. The content of this part includes configuring IP address, subnet mask, host name and DNS server, etc. If you use dial-up or virtual dial-up network, you should also configure the corresponding Modem and PPP protocol support. This part of the operation is very simple in RHAS4. Just select "Application" - "System Settings" - "Network" at the top of the desktop environment, and you can follow the prompts. If the desktop environment is not installed, use the ifconfig command Configure it.
2.3 Configure DHCP service

DHCP service needs to be configured on the /etc/dhcpd.conf file, which can be configured by opening this file with vi or gedit. Enter vi /etc/dhcpd.conf or gedit /etc/dhcpd.conf on the command line, modify the following content according to the instructions in brackets, paste it in, save and exit. (The behavior comment line with # at the beginning does not have to be pasted)
#------------------------------------------------- -------------------------------------------------- ------------------------
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
#
#(DHCP-DNS interaction)
ddns-update-style interim;
#(Ignore client-updates)
ignore client-updates;
# (allow bootp protocol to start)
allow bootp;
allow booting;
# (subnet scope)
subnet 192.168.1.0 netmask 255.255.255.0 {
# ---default gateway (default gateway information, the first three options are router IP, sub Netmask, DNS)
       option routers 192.168.1.1;
       option subnet-mask 255.255.255.0;
       option domain-name-servers 192.168.1.1;
       option time-offset -18000;
#(address pool range)
range dynamic-bootp 192.168.1.2 192.168.1.253;
# (IP address lease period, in seconds, the bold part can be set according to your needs; -1 means it will never expire, not recommended)
default-lease-time 14400;
max-lease-time 86400;
}
#(Take the configuration of the DHCP allocation policy of a workstation c1 as an example)
#(The meanings of several lines are: workstation name, server name, workstation MAC address, to
The IP address assigned to the workstation , the location of the startup configuration file, and the path of the NFS root file system)
# (The location of the startup configuration file and the path of the NFS root file system are closely related to the configuration of the subsequent steps, and the parts in bold # will be based on Changes in subsequent configuration content)
host c1{
server-name "server";
hardware ethernet 00:30:18:63:55:02;
fixed-address 192.168.1.3;
filename "/tftpboot/pxelinux.0";
option root-path "/tftpboot/192.168.1.3"
}
# (If there are other machines, continue to configure host c2 in this way...)
#----------------- -------------------------------------------------- --------------------------------------------



2.4 Configure TFTP service

The TFTP service needs to be registered and configured in /etc/xinetd.d, which can be configured by opening this file with vi or gedit. Enter vi /etc/xinetd.conf or gedit /etc/xinetd.conf in the command line, append the following content to the end of the file, save and exit.
includedir /etc/xinetd.d
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
}
2.5 Working system kernel compilation

Diskless workstation needs to be measured according to its own particularity It is necessary to understand the characteristics of a diskless workstation first. It is not difficult to know from the above description that the diskless workstation must support DHCP/BOOTP protocol startup, and must support the NFS file system as its root file system, and also support related network devices. The selection of the kernel is also very important. The kernel with too low version has few functions and poor security; the kernel with too high version will be unstable. After consideration, the Linux kernel version 2.6.23 is used in this configuration. The download address of the kernel source package is:
http://www.at.kernel.org/pub/linux/kernel/v2.6/linux-2.6 .23.tar.gz.
After the kernel is downloaded, execute the following commands in the terminal in sequence:
cp linux-2.6.23.tar.gz /usr/src
cd /usr/src
tar zxf linux-2.6.23.tar.gz
cd linux-2.6.23
make menuconfig
According to the characteristics of diskless workstations, set kernel compilation options, including CPU type, disable module function, DHCP/BOOTP boot protocol and NFS file system support , the following is the configuration method:
(1) The options under the Processor type and features item must be set according to the CPU type of the diskless workstation, not the CPU type of the server;
(2) Loadable module support All options under this item are prohibited , that is, the module function is not supported (devices required for diskless, such as network cards, must be compiled into the kernel and cannot be compiled into modules);
(3) Networking ---> Networking options, select the item with *:
  
  •      IP: kernel level auto configuration
  •   
  •      IP: DHCP support
  •   
  •      IP: BOOTP support
  •    [ ] IP: RARP support <--- not needed
    (4) File System ---> Network File Systems, select the item with *:
      
  •     NFS file system support
  •   
  •     Provide NFSv3 client support
  •   
  •     Root file system on NFS
  • (5) Block Devices, select the item with *:
  •     Loopback device support
  •     Network block device support
  • Then check other options, remove unnecessary redundant items such as Bluetooth, save and exit.
    Execute the following commands in sequence:
    make dep
    make bzImage
    The final generated bzImage is the compiled new kernel file. According to the last prompt information, you can copy it from the path where the file was generated.
    2.6 Configuring the working directory and startup file

    According to the second half of the configuration file in Section 2.1, it is not difficult to know that each workstation needs to be configured with specific DHCP options. The bold part is the directory where the workstation works on the server. The name of this directory May vary depending on requirements or preferences of the configurator. In this document, in order to protect the integrity of this configuration, we will configure it according to the host name (c1), host IP address (192.168.16.3) and working directory /tftpboot/** specified in the DHCP configuration file. First, we create the /tftpboot general directory, and then execute the following commands in sequence:
    mkdir /tftpboot (create the /tftpboot general directory, where the working directories of all machines are stored)
    cp bzImage /tftpboot (copy the previously compiled bzImage file to / tftpboot)
    chmod 777 /tftpboot/bzImage (set the file attribute as readable, writable and executable, this step is optional)
    cd /tftpboot
    mkdir 192.168.1.3 (create the working directory of the c1 host, which is named after its IP address here, you can Modify as needed)
    At this point, we have completed the creation of the working directory of the c1 host, and have placed the new kernel compiled for the diskless workstation in the general directory. The next step is to create configuration files and startup files for the c1 host. It's time.
    In this configuration, pxelinux.0 is used as the startup file of the machine. As written in the DHCP configuration file, the workstation first obtains this file through TFTP, then searches for the configuration file according to the instructions of this file, and then according to the configuration file Instructs to get the kernel file via TFTP. The pxelinux.0 file is included in the package syslinux, which can be downloaded from http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-3.53.tar.gz.
    After the download is complete, you can unzip the pxelinux.0 file and execute the following commands in sequence: tar
    zxf syslinux-3.53.tar.gz
    cp ./syslinux-3.53/pxelinux.0 /tftpboot
    It is copied to the general directory /tftpboot, which corresponds to the filename "/tftpboot/pxelinux.0" line in the DHCP configuration file. It is not difficult to understand that the response message of the DHCP service will bring back the file name /tftpboot/pxelinux.0 , so that subsequent TFTP processes can use this file name to send correct TFTP file transfer requests.
    As mentioned above, pxelinux.0 will instruct the workstation to obtain the configuration file for further startup. Therefore, we must understand the strategy of pxelinux.0 to find the configuration file in order to place the configuration file. This strategy is very simple. Its action is to instruct the workstation to download the file with the same name as the hexadecimal number of the IP address obtained by the workstation in the pxelinux.cfg subdirectory of the directory where the pxelinux.0 file is located. For this example, the location of the configuration file should be /tftpboot/pxelinux.cfg/C0A80103 (192.168.1.3 in hex). According to this inherent strategy, we can proceed with the configuration.
    mkdir /tftpboot/pxelinux.cfg
    cd /tftpboot/pxelinux.cfg
    vi C0A80103 or gedit C0A80103 Modify
    the following content according to the instructions in brackets, paste it in, save and exit. (The behavior comment line with # at the beginning does not have to be pasted)
    #------------------------------------------------- -------------------------------------------------- ------------------------
    default linux
    label linux
    # (The following bzImage is the name of the new kernel generated by compilation, which can be modified as needed)
    kernel bzImage
    # (The following 192.168.1.3 is the working directory of the c1 host, which can be modified as needed)
    append ip=dhcp root=/dev/nfsroot rw enforcing=0 nfsroot=./192.168.1.3 vga=normal
    #------ -------------------------------------------------- -------------------------------------------------- -----
    When using PXELINUX (pxelinux.0), for some systems, it is sometimes necessary to use the tftp server software with the TSIZE parameter. The download address of the software is
    http://www.kernel.org/pub/software/network/tftp/tftp-hpa-0.48.tar.gz, the installation method is a typical MAKE three-step method, and will not be described in detail here.
    2.7 Configuring the Workstation File System

    The Linux diskless workstation needs to have a relatively strict Linux file system, which needs to be stored in the working directory of the diskless workstation, in this example, the /tftpboot/192.168.1.3 directory. The basic Linux file system needs to contain basic directories such as bin, usr, home, etc. These directories can be copied under the existing Linux, or other file systems can be used as templates to generate. The constructed file system determines the file system used on the workstation. The specific version of Linux.
    If the file system is generated by copying the local machine, the Linux version on the workstation will be exactly the same as that on the server. The operability of this method is very good, but because the file system on the server is too large, the workstation is often used by users. There are several brief black screens when logging in, which affects the user's mood and overall effect. The operation of generating a file system by copying the local machine can be completed by executing the following commands in sequence:
    cd /tftpboot/192.168.1.3
    cp –a /bin
    cp –a /dev
    mknod dev/nfsroot b 255 0
    chmod 600 dev/nfsroot
    cp –a /etc
    cp –a /home
    cp –a /lib
    rm –rf lib/modules
    cp –a /root
    cp –a /sbin
    cp –a /var
    mkdir proc
    mkdir usr
    mkdir tmp
    chmod 777 tmp
    touch fastboot
    chattr +i fastboot
    If you use other Linux systems as templates to construct the file system of the diskless workstation, you need to install the smallest possible Linux on other machines and make a full copy of the file system. . The version and type of Linux on the workstations configured this way depends on the template Linux system. This operation requires the configurator to have a relatively in-depth understanding of the characteristics of the template Linux system, and the operability is not strong, but because the constructed Linux file system is often relatively small, the system can be started relatively quickly. The specific configuration process is omitted here, and can be performed with reference to the above-mentioned process.
    Take the method of copying the local file system as an example. In this example, the operating system on the workstation is RHAS4, which is the same as that on the server. Since the system is not an ext2/3 file system on a traditional machine, it is also necessary to perform internal operations. To configure the etc/fstab file system table, execute the following commands in sequence (based on the example of host c1):
    cd /tftpboot/192.168.1.3
    vi etc/fstab or gedit etc/fstab
    Delete all lines without "none proc" , # comment line can be reserved, and append a line at the end of the file:
    server:/tftpboot/192.168.1.3 / nfs default 1 1
    Save and exit.
    After the above configuration is completed, some functional configuration needs to be performed on the working directory of a specific host to make it work normally. These configurations are related to NFS file system access and can be implemented by executing the following commands in sequence:
    cd /tftpboot/192.168.1.3
    vi etc/exports or gedit etc/exports
    Overwrite the original content with the following content, and save and exit (based on the example description of host c1, # table comment).
    # etc/exports: the access control list for filesystems which may be exported
    # to NFS clients. See exports(5).
    # (Set the NFS access control of the host to the server directory, * means any host can be, this line only needs to be written once)
    /tftpboot/192.168.1.3 c1(rw,sync,no_root_squash)
    /tftpboot *(ro,sync,no_root_squash)
    2.8 Other configuration The host name configuration on the

    server : still take c1 as an example, the IP address is 192.168.1.3. At the top of the desktop environment, select "Applications" - "System Settings" - "Network" in turn, select the "Host" tab, use the "New" button, and enter the IP address 192.168.1.3 in the pop-up dialog box, the host Name c1.domain, alias c1, save it. If the GUI is not installed, you can edit /etc/hosts and add the corresponding entry at the end of the file. The writing format of the entry can refer to the format of other lines in the file.

    Guess you like

    Origin http://10.200.1.11:23101/article/api/json?id=327074773&siteId=291194637