RHEL/CentOS PXE diskless workstation, rhelcentospxe diskless workstation

Source: Internet
Author: User

RHEL/CentOS PXE diskless workstation, rhelcentospxe diskless workstation

 

• Introduction to PXE diskless workstation Systems

 

A pxe diskless workstation system is a LAN system consisting of one or more "system servers" and multiple "PXE clients (diskless workstation)" connected by a switch.

(Figure 1: topology of diskless workstation system deployment)

 

• System server: Provides system support to diskless workstation through DHCP + TFTP + NFS service

· DHCP service: the IP address, subnet mask, and gateway are distributed to the PXE client, and the IP address of the server (TFTP Server) where the boot guide file is located and the PXE Startup File (pxelinux.0) are specified)

· TFTP service: the PXE Startup File, PXE boot configuration file, Linux kernel vmlinuz, and System Startup File initrd. img are transmitted to the PXE client.

· NFS service: Release the workstation system to the PXE client (clone of the entire root directory "/"). To avoid disk IO resource conflicts, we recommend that you deploy the cloned system on the storage server.

 

• PXE client: the PXE client does not require a hard disk, but requires a NIC that supports PXE startup. However, other hardware such as the motherboard, memory stick, and power supply are required; set "enable nic" as the preferred option

(Figure 2: PXE startup flowchart)

 

 

 

 

• Before deployment, you must plan the operating environment of the system server and diskless workstation.

 

• System Environment

Operating System: CentOS release 6.5 x86_64
Firewall: Disable the iptables service and disable auto-start upon startup; Disable selinux
Others: Configure YUM Repository: Disable useless auto-start services (sshd and rpcbind services cannot be disabled)

 

 

 

• Software environment

Dhcp-4.1.1-49.P1.el6.centos.x86_64 // Provides DHCP service; specifies the TFTP address and PXE Startup File
Tftp-server-0.49-7.el6.x86_64 // Transfer system startup files to diskless workstation
Nfs-utils-1.2.3-64.el6.x86_64 // Shared publishing workstation System
Syslinux-4.04-3.el6.x86_64 // Provides the Bootstrap program "pxelinux.0"
Rpcbind-0.2.0-11.el6.x86_64 // Dependency for NFS service
Dracut-004-388.el6.noarch // Used to create an initrd Image
Dracut-network-004-388.el6.noarch // Dependency package. Otherwise, PXE cannot be started.

 

 

 

 

 

 

• Network Environment

Host type: Host Name: IP Address: Subnet Mask: Gateway/route:
System server HostServerA 192.168.8.8 255.255.255.0 192.168.8.254
System server B HostServerB 192.168.8.9 255.255.255.0 192.168.8.254
Diskless workstation WorkStation/WS100 ~ 200 192.168.8.100 ~ 200 255.255.255.0 192.168.8.254/not set (wks are prohibited)

 

 

 

 

 

 

Perform the following operations on system server A and system server B respectively:

 

• Start installation and deployment. First, clone the system template of the workstation.

 

1. Create a directory for storing the wks system template (/nodiskos/workstation) and a directory for storing boot files (/nodiskos/tftpboot)

Mkdir/nodiskos // system template + Startup File storage directory mkdir/nodiskos/tftpboot // mkdir/nodiskos/workstation // workstation system template storage directory

 

2. Use rsync to copy the entire "/" directory to the/nodiskos/workstation directory to remove unnecessary file directories.

rsync -av --exclude='/proc' --exclude='/sys' --exclude='/tmp' --exclude='/var/tmp' --exclude='/etc/mtab' --exclude='/nodiskos' /* /nodiskos/workstation

 

3. Recreate the deleted directory and restore the directory structure of the system template.

cd /nodiskos/workstationmkdir proc sys tmp var/tmp

 

4. adjust the device mounting configuration file/nodiskos/workstation/etc/fstab in the system template to delete all mounting information (such as // and/boot) of local storage devices ); add mounting information for the system template. Take "system server A" as an example (note: the IP address of system server B is set to 192.168.8.9):

# /etc/fstab# Created by anaconda on Fri Dec 25 10:58:41 2015## Accessible filesystems, by reference, are maintained under '/dev/disk'# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info#192.168.8.8:/nodiskos/workstation  /  nfs    defaults      0 0tmpfs      /dev/shm           tmpfs   defaults      0 0devpts      /dev/pts          devpts  gid=5,mode=620   0 0sysfs       /sys             sysfs   defaults      0 0proc       /proc             proc    defaults       0 0

 

5. Modify the Host Name of the system template, such as WorkStation

Edit the configuration file/nodiskos/workstation/etc/sysconfig/network and change the HOSTNAME = parameter value to WorkStation.

 

6. Finally, delete all ifcfg-eth * Nic configuration files. You only need to retain ifcfg-lo

rm -f /nodiskos/workstation/etc/sysconfig/network-scripts/ifcfg-eth*

 

7. finally, the entire workstation system template is packaged and backed up to the/opt directory of the system server for backup (for example, in step 1 below, an independent system is created for a single or each workstation)

cd /nodiskostar -cvf /opt/workstation.tar workstation

 

8. As described in step 1, you can create an independent system for a single or each workstation as needed. Take WS100 ~ 110 For example:

1) decompress the backup system templates and copy them to the System directories of independent workstations in batches.

cd /optfor i in $(seq -w 100 110)> do>   tar -xvf workstation.tar>   mv workstation /nodiskos/WS$i> done

2) Finally, you need to adjust the mount information of fstab, the network host name, and the local domain name resolution of hosts for each independent workstation. You can execute the following shell scripts to replace them in batches. You need to grant the execution permission:

# Use WS100 ~ 110 for example # The first for loop is to replace the mounting information and Host Name of fstab, where: # 1st sed replace/nodiskos/WS ### mount information of/etc/fstab # 2nd sed replace host name # 3rd sed replace host name in hosts file resolution # The second for loop prints the result after replacement, to check whether the replacement is correct # The Script content is as follows :#! /Bin/bashfor I in $ (seq-w 100 110) do sed-I "/nodiskos/s/workstation/WS $ I/g"/nodiskos/WS $ I/etc/fstab sed-I "s/WorkStation/WS $ I/ g "/nodiskos/WS $ I/etc/sysconfig/network sed-I" 1a 192.168.8. $ I WS $ I "/nodiskos/WS $ I/etc/hostsdonefor I in $ (seq-w 100 110) do echo-e" fstab: \ c "& sed-n"/nodiskos/p "/nodiskos/WS $ I/etc/fstab echo-e" network: \ c "& sed-n"/HOST/p "/nodiskos/WS $ I/etc/sysconfig/network echo-e" hosts: \ c "& sed-n"/192.168/p "/nodiskos/WS $ I/etc/hosts echo-e" \ n "done

 

 

 

• Prepare the files required for the wks boot guide.

 

1. Install syslinux and dracut packages

yum install syslinux dracut dracut-network

 

2. Copy the PXE Startup File (provided by syslinux)

cp /usr/share/syslinux/pxelinux.0 /nodiskos/tftpboot

 

3. Copy the Linux Kernel File vmlinuz

cp /boot/vmlinuz-2.6.32-431.el6.x86_64 /nodiskos/tftpboot

 

4. Create the initrd. img image file for the system to start (first execute the commandUname-rView the kernel version, for example, 2.6.32-431. el6.x86 _ 64)

dracut initrd-2.6.32-431.el6.x86_64.img 2.6.32-431.el6.x86_64chmod 644 initrd-2.6.32-431.el6.x86_64.imgmv initrd-2.6.32-431.el6.x86_64.img /nodiskos/tftpboot

 

5. In/nodiskos/tftpboot/Pxelinux. cfg/Create the default PXE boot configuration file under the directory"Default"(You can also create independent boot configuration files for a single or each workstation, such as WS100)

# Prompt 0 indicates that the workstation is started immediately. 1 indicates that the workstation is waiting for selection. # specify the kernel file in the kernel. # A line of content is underlined after the append. line breaks are not allowed !!! # Description of append parameter values: # initrd = specifies the initrd image file to be booted # root = specifies the nfs path of the workstation system (Note: Set "system server B" to 192.168.8.9) # selinux = set selinux switch. 0 indicates that selinux is disabled. 1 indicates that selinux is enabled. The default value is 1 # rw indicates that the workstation system is read/write. # nomodeset is used together with vga =, set Resolution # vga = this parameter value is set resolution, 0x indicates hexadecimal, 0314 indicates 800*600 16-bit color # The file content is as follows: default autolabel autoprompt 0 kernel vmlinuz-2.6.32-431.el6.x86_64append initrd = initrd-2.6.32-431.el6.x86_64.img root = nfs: 192.168.8.8:/nodiskos/workstation selinux = 0 ip = dhcp rw nomodeset vga = 0x0314

 

6. To create an independent boot configuration file for a single or each workstation ~ 110 For example:

1) the file name of the boot configuration file is the hexadecimal conversion value of the IP address of the workstation. For example, if the IP address of WS100 is 192.168.8.100, the configuration file name is "C0A80864". The comparison is as follows: 192 → C0, 168 → A8, 8 → 08,100 → 64.

2) For file content, refer to default. You only need to specify the root = parameter value under append as the nfs path of the corresponding WS100, for example: root = nfs: 192.168.8.8:/nodiskos/WS100, the premise is that/nodiskos/WS100 must exist.

3) For convenience, the following shell scripts can be used for batch creation and modification by referring to the default configuration file default:

# Use WS100 ~ 110 for example # for Loop subject description: # 1st row: printf converts the IP address of WS ### into hexadecimal format and assigns the value to ws_name # 2nd row: use the default file as the template and the hexadecimal value of the IP address as the file name for batch copy # Row 3rd: batch modify the nfs path # 4th row of the specified WS ### root = parameter value: print the replaced result to check whether the replacement is correct # The Script content is as follows :#! /Bin/bashcd/nodiskos/tftpboot/pxelinux. cfg/for I in $ (seq-w 100 110) do ws_name = $ (printf "% 02X" 192 168 8 $ I) cp default $ ws_name sed-I "s/workstation/WS $ I/g" $ ws_name sed-n "/append/p" $ ws_namedone

 

7. Finally, the/disklessboot/tftpboot directory should contain the following files/directories:

Initrd-2.6.32-431.el6.x86_64.img // The initrd image file used for booting (Created in step 1)
Pxelinux.0 // PXE boot file (Created in step 1)
Pxelinux. cfg/default // Default boot configuration file (Created in step 1)
Pxelinux. cfg/C0A808 ## // Custom boot configuration file (Created in step 1)
Vmlinuz-2.6.32-431.el6.x86_64 // The Kernel File used for booting (Created in step 1)

 

 

 

 

 

 

 

• Configure the DHCP service

 

1. Install the DHCP service package

yum install dhcp

 

2. Edit the configuration file/etc/dhcp/dhcpd. conf.

 

# Dhcpd. conf parameter description: # default-lease-time // specify the lease validity period, in seconds, -1 indicates unlimited # max-lease-time // specify the maximum lease duration # authritative // reject incorrect IP address requirements # subnet netmask {} // set dhcp region # range // provides a range for dynamically allocating IP addresses; if all workstations are bound with a fixed IP address, delete this configuration # option routers // set the gateway/router address. Separate multiple IP addresses with commas. If you do not want the client to access the Internet, you can delete this configuration # domain-name-servers // you can delete this configuration if you do not want the client to access the Internet; separate multiple addresses with commas # next-server // inform the workstation of the address of the TFTP server. The TFTP service provides boot Guide (note: "system server B" is set to 192.168.8.9) # filename // inform the workstation of the PXE boot program name # host XXX {} // a fixed IP address is bound according to the workstation's MAC address, the premise is to know the MAC address # the MAC address of the hardware ethernet // workstation. It must be in lowercase # fixed-address // bound to a fixed IP address, which does not conflict with the range, focuses on it first # The configuration content is as follows: ddns-update-style none; ignore client-updates; default-lease-time-1; max-lease-time-1; authritative; subnet 192.168.8.0 netmask 255.255.255.0 {range 192.168.8.100 192.168.8.200; option routers 192.168.8.254; option domain-name-servers parameters, rules; next-server 192.168.8.8; filename "pxelinux.0"; host WS100 {hardware ethernet 12: 34: 56: 78: AB: cd; fixed-address 192.168.8.100;} host WS101 {hardware ethernet 12: 34: 56: 90: AB: 00; fixed-address 192.168.8.101 ;}}

 

3. Restart the DHCP service and set the DHCP service to start automatically

service dhcpd restartchkconfig dhcpd onchkconfig |grep dhcpd

 

 

 

• Configure the TFTP service

 

1. Install the TFTP service package

yum install tftp-server

 

2. Edit the configuration/etc/xinetd. d/tftp. You only need to change the configuration as follows:

# And to start the installation process for some operating systems. service tftp {.............. server_args =-s/nodiskos/tftpboot // change to the directory where the Startup File is stored. Disable = no // change yes to no, to activate this service ..............}

 

3. the TFTP service is managed through the xinetd tool. Therefore, you must start, stop, and restart the service through xinetd.

service xinetd restartchkconfig xinetd onchkconfig |grep xinetd

 

 

 

• Configure the NFS service

 

1. Install the NFS service package

yum install nfs-utils rpcbind

 

2. Edit the configuration file/etc/exports and add the following content:

# This line is the default workstation system directory.
/Nodiskos/workstation 192.168.8.0/24 (rw, async, no_root_squash)
# The following are independent system directories for workstations/nodiskos/WS100 192.168.8.100 (rw, async, no_root_squash)/nodiskos/WS101 192.168.8.101 (rw, async, no_root_squash) /nodiskos/WS102 192.168.8.102 (rw, async, no_root_squash)/nodiskos/WS103 192.168.8.103 (rw, async, no_root_squash)/nodiskos/WS104 192.168.8.104 (rw, async, no_root_squash )............

 

3. If the number of independent workstations is large, you can use the following shell script to add them in batches.

#!/bin/bash
echo '/nodiskos/workstation 192.168.8.0/24(rw,async,no_root_squash)'>/etc/exportsfor i in $(seq -w 100 110)do sed -i "\$a \/nodiskos\/WS$i 192.168.8.$i(rw,async,no_root_squash)" /etc/exportsdonecat /etc/exports

 

4. Restart the NFS service and set the NFS service to start automatically.

service nfs restartchkconfig nfs onchkconfig |grep nfs

 

5. Now, all configurations have been completed. Finally, check whether the DHCP, TFTP, and NFS services have been started, and whether all services have been set to self-started upon startup.

service dhcpd statusservice xinetd statusservice nfs statuschkconfig |grep dhcpdchkconfig |grep xinetdchkconfig |grep nfs

 

6. Finally, set the startup items of all PXE clients to the preferred Nic startup, and then start the PXE client !!!

 

 

 

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.