Rhel/centos PXE diskless Workstation

Source: Internet
Author: User

• Introduction to PXE diskless workstation systems

PXE diskless workstation system refers to a LAN system consisting of one or more " system Servers" and multiple "PXE clients (diskless workstations)" that are connected by switches.

(Figure 1: The diskless Workstation System deployment topology map)

• System server: Provides system support to diskless workstations via DHCP+TFTP+NFS service

· DHCP service: Distributes IP addresses, subnet masks, gateways, and so on to PXE clients, and specifies the server on which the boot file is launched

(TFTP server) address and PXE boot file (pxelinux.0)

· TFTP service: Transfer PXE boot files, PXE boot profiles, Linux kernel Vmlinuz to PXE clients, and

System Startup File Initrd.img

· NFS Service: A system that publishes workstations to PXE clients (clones of the entire root directory "/"); To avoid disk IO resources

Conflict, it is recommended that the cloned system be deployed on the storage server

PXE client: The PXE client does not require a hard drive, but requires a piece of NIC that supports PXE boot, but other hardware such as motherboard, memory strip, power supply, etc., must be required; Set network card startup to preferred

(Figure 2:pxe Start flowchart)

• Before you deploy, plan the working environment of your system servers and diskless workstations first

• System Environment

Operating system: CentOS Release 6.5 x86_64
Firewall: Turn off the Iptables service and disable it from starting;
Other: Configure the Yum repository: Disable the Useless boot service (sshd service and Rpcbind service cannot be disabled)

• Software Environment

Dhcp-4.1.1-49.p1.el6.centos.x86_64 Provide DHCP service, specify TFTP address and PXE boot file
Tftp-server-0.49-7.el6.x86_64 Transfer system boot files to diskless workstations, etc.
Nfs-utils-1.2.3-64.el6.x86_64 Shared Publishing Workstation System
Syslinux-4.04-3.el6.x86_64 Provide the bootloader "pxelinux.0"
Rpcbind-0.2.0-11.el6.x86_64 Dependent Programs for NFS services
Dracut-004-388.el6.noarch Used to make a boot initrd image
Dracut-network-004-388.el6.noarch dependent packages, otherwise it will cause PXE to fail to start

• Network Environment

Host Category: Host Name: IP Address: Subnet Mask: Gateway/Route:
System Server A 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 Workstations workstation/ws100~200 192.168.8.100~200 255.255.255.0 192.168.8.254/not set (Disable workstation networking)

Do all of the following on system server A and system Server B, respectively:

• Start the installation deployment, first of all, to clone a workstation's system template

1. Create a storage directory (/nodiskos/workstation) for the Workstation system template and a boot file directory (/nodiskos/tftpboot)

Mkdir/nodiskos//                               system template + Startup file storage directory Mkdir/nodiskos/tftpboot//                      Workstation system Boot file directory mkdir/nodiskos/workstation                   // Workstation System Template Storage Directory

2. Use the Rsync tool to copy the entire "/" directory to the/nodiskos/workstation directory, removing the unwanted file directory

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

3. Re-create the deleted directory, restore the directory structure of the system template

CD/NODISKOS/WORKSTATIONMKDIR PROC SYS tmp VAR/TMP

4. Adjust the device Mount profile for the system template/nodiskos/workstation/etc/fstab: Remove all local storage device mount information (such as:/and/boot), and add the Mount information for the system template. Take "System Server A" as an example (note: The IP setting for system Server B is 192.168.8. 9):

#/etc/fstab# Created by Anaconda in Fri Dec 10:58:41 2015## Accessible filesystems, by reference, is maintained under  '/dev/disk ' # See mans 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 g    id=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, modify the Hostname= parameter value to workstation

6. Finally, remove all ifcfg-eth* nic profiles, just keep 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 system server's/OPT directory for backup (for example, step 8th below to create a separate system for a single/each workstation)

Cd/nodiskostar-cvf/opt/workstation.tar Workstation

8. As described in step 7th, separate systems can be created for individual/per workstations, as required. Take ws100~110 as an example:

1) Extract the backed up system templates and copy them to the system directory of their separate workstations in batches

Cd/optfor I in $ (seq-w) > do>   tar-xvf workstation.tar>   mv workstation/nodiskos/ws$i> done

2) Finally, it is necessary to adjust the mount information of FSTAB, hostname of network and local domain name of hosts for each stand-alone workstation. The following shell scripts can be executed for bulk substitution and need to be given Execute permissions:

# take ws100~110 For example # The first for loop is the Mount information and hostname of the replacement fstab, where: # 1th sed is the mount information to replace the/nodiskos/ws###/etc/fstab # 2nd sed is the replacement hostname # 3rd sed is in ho Add native domain name resolution in STS file # The second for loop is to print out the replacement result to make it easier to check if the correct # script content is replaced as follows: #!/bin/bashfor i in $ (seq-w) 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 +) do  echo-e "Fstab: \c "&& sed-n"/nodiskos/p "/nodiskos/ws$i/etc/fstab  echo-e" network: \c "&& sed-n"/host/p "/nodisko S/ws$i/etc/sysconfig/network  echo-e "hosts: \c" && sed-n "/192.168/p"/nodiskos/ws$i/etc/hosts  Echo- E "\ n" Done

• Next, prepare the workstation to boot the required files

1. Installing the Syslinux and Dracut packages

Yum Install syslinux Dracut dracut-network

2. Copy the PXE boot file (provided by the Syslinux program)

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

3. Copy with Linux kernel file Vmlinuz

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

4. Create the image file for the system boot initrd.img (First execute command uname-r View kernel version, such as: 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. Create the default PXE boot profile "default" in/nodiskos/tftpboot/pxelinux.cfg/directory(you can also create a standalone boot profile for a single/per workstation, such as WS100)

# prompt 0 means that the workstation is started immediately, 1 indicates that the workstation is waiting to select # kernel specified kernel file # Append after the underlined is a line of content, can not wrap!!!  # Append additional parameter value explanation: # initrd= Specifies the INITRD image file for booting # root= the NFS path for the specified workstation system (Note: "System Server B" is set to 192.168.8.9) # selinux= set SELinux switch, 0 Indicates off, 1 is on, default is # RW set workstation system to read/write # Nomodeset This parameter is used together with the vga= parameter, set resolution # Vga= This parameter value is set resolution, 0x is hexadecimal, 0314 means 800*600 16-bit color; No special needs, it is recommended to delete these 2 parameters # file contents are as follows: Default AutoLabel autoprompt 0kernel 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 a separate boot profile for a single/each workstation, take ws100~110 as an example:

1) The file name of the boot configuration file is the 16-binary conversion value of the workstation's IP address. If the IP address of the WS100 is 192.168.8.100, then the file name of its profile is "c0a80864"; the control relationship is as follows: 192→c0,168→a8,8→08,100→64.

2) The file contents can be referenced by default, simply specify the root= parameter value under append as the corresponding WS100 NFS path, for example: root=nfs:192.168.8.8:/nodiskos/ws100, if/nodiskos/ WS100 need to exist.

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

# take ws100~110 as an example # for loop body Description: # line 1th: printf is to convert the ws## #的IP address into 16, and assign to the parameter ws_name# 2nd line: The default file as a template, the hexadecimal value of the IP address as the file name, for bulk copying # line 3rd: Bulk Modify the root= parameter value specifies the ws## #的nfs path # 4th line: Prints out the replaced result to make it easier to check if the correct # script content is replaced as follows: #!/bin/bashcd/nodiskos/tftpboot/pxelinux.cfg/ For I in $ (seq-w) do  ws_name=$ (printf "%02x" 192 168 8 $i)  cp default $WS _name  sed-i "s/workstation/w S$i/g "$ws _name  sed-n"/append/p "$ws _namedone

7. Finally, the following files/directories should be available in the/disklessboot/tftpboot directory:

Initrd-2.6.32-431.el6.x86_64.img INITRD image file for booting (created by 4th step)
pxelinux.0 PXE Boot file (created by 2nd step)
Pxelinux.cfg/default The default boot configuration file (created by 5th step)
pxelinux.cfg/c0a808## Custom Boot configuration files (created by 6th step)
Vmlinuz-2.6.32-431.el6.x86_64 Kernel files for booting (created by 3rd step)

• Configure DHCP Service

1. Installing the DHCP service package

Yum Install DHCP

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

# dhcpd.conf Part parameter Description: # default-lease-time//Specify the lease duration, in seconds, 1 means no Limit # Max-lease-time//Specify maximum lease duration # Authritative Deny incorrect IP address requirements # subnet Netmask {}//Set DHCP Zone # Range//provide a range of dynamically assigned IPs; If all workstations are bound fixed IP, can remove this configuration # option routers//Set the gateway/router address, multiple addresses separated by commas, if you do not want the client to surf the Internet, you can delete this configuration # Domain-name-servers//Set up DNS, if you do not want the client to surf the Internet, you can delete                In addition to this configuration, multiple addresses are separated by commas # Next-server//Tell the address of the workstation TFTP server, the TFTP service provides boot boot (note: "System Server B" is set to 192.168.8.9) # filename Informs the workstation that the PXE boot program name # host XXX {}//Here is a fixed IP address based on the MAC address of the workstation, provided that the MAC address # Hardware Ethernet//Workstation MA C address, must be lowercase # fixed-address//bound fixed IP address, and range will not conflict, priority to it as the main # configuration content as follows: Ddns-update-style None;ignore client-update S;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 114.114.114.114,202.96.209.5;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

Service dhcpd restartchkconfig dhcpd onchkconfig |grep dhcpd

• Configuring the TFTP service

1. Installing the TFTP service package

Yum Install Tftp-server

2. To edit the configuration/etc/xinetd.d/tftp, simply change the following 2:

# and to-start the installation process for some operating Systems.service tftp{.... Server_args =-s/nodis Kos/tftpboot             //change to the storage directory of the boot file Disable = no                                    //change Yes to No to activate this service ...}

3. The TFTP service is managed through the XINETD tool, so it is necessary to start, stop, restart, etc. via XINETD

Service xinetd restartchkconfig xinetd onchkconfig |grep xinetd

• Configure NFS Services

1. Installing the NFS service package

Yum Install nfs-utils Rpcbind

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

# This line is configured with the default workstation system directory
/nodiskos/workstation 192.168.8.0/24 (Rw,async,no_root_squash)
# The following section publishes a standalone system directory 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 bulk add

#!/bin/bash
Echo '/nodiskos/workstation 192.168.8.0/24 (rw,async,no_root_squash) ' >/etc/exportsfor I in $ (seq-w +) 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

Service NFS Restartchkconfig NFS Onchkconfig |grep NFS

5. At this point, all configurations are complete. Finally check that DHCP, TFTP, NFS all 3 services have been started, are set to boot

Service DHCPD statusservice xinetd statusservice NFS statuschkconfig |grep dhcpdchkconfig |grep xinetdchkconfig |grep NFS

6. Finally, the boot entry for all PXE clients is set to the preferred network adapter boot, and then the PXE client is started!!!

Rhel/centos PXE diskless Workstation

Related Article

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.