Linux System network Installation--based on Pxe+dhcp+nfs+tftp+kickstart

Source: Internet
Author: User
Tags file transfer protocol nameserver

Originally Posted: 2010-09-05

Reprinted to CU with: 2012-07-21

A. Principle Introduction

pxe (Preboot Execute environment) working on client/server network mode, Support workstations download images from remote servers over the network, and thus support the booting of operating systems from the network. During startup, the terminal is dhcp server assignment ip address, re-use tftp ( trivial File Transfer Protocol (nfs,ftp,http etc " liunx The kernel and root file system wait for the native memory and execute, thus completing the Terminal basic software setup, thus booting the terminal operating system preinstalled in the server.

Kickstart is an unattended installation method. It records the various parameters that are required for manual intervention during the typical installation process, and generates a ks.cfg file, and the installer will look for the required parameters in the subsequent installation process Kickstart files, there is no need for manual intervention to find the right parameters.

two. Environment Description

OS :

CentOS 5.4 i386

Soft :

DHCP, NFS, TFTP, Kickstart (Gnome or X-window)

can use Yum Installation:

Yum–y Install dhcp*yum–y Install nfs*yum–y install tftp*yum–y install system-config-kickstart*

IP :

eth0:192.168.1.254

three. Introduction to the installation configuration process

1. Configure dhcp

more/etc/dhcpd.conf# DHCP Server Configuration file.# see/usr/share/doc/dhcp */dhcpd.conf.sample## Location:zhangjiang idc# date:2010-08-01 ddns-update-style interim;ignore client-updates;allow Booting;allow BOOTP;        Subnet 192.168.1.0 netmask 255.255.255.0 {option routers 192.168.1.254;        Option Subnet-mask 255.255.255.0;        Option Domain-name-servers 192.168.1.254; Option time-offset-18000;        # Eastern Standard Time range DYNAMIC-BOOTP 192.168.1.10 192.168.1.250;        Default-lease-time 21600; Max-lease-time 43200;# Group The PXE bootable hosts# pxe-server configuration Direction next-server 192.168.1.254; #指向nfs服务器 filename "/pxelinux.0"; #/tftp root directory boot boot file # We want the nameserver to appear at a fixed address host ns {hardware E Thernet 00:1c:25:80:f4:58;        #张江机房的笔记本网卡mac fixed-address 192.168.1.2; }}

Restart DHCP Service:

/ETC/INIT.D/DHCPD restart

2. Configuring TFTP

MORE/ETC/XINETD.D/TFTP # default:off# description:the TFTP server serves files using the Trivial file transfer #       PR Otocol.  The TFTP protocol is often used to boot diskless #       workstations, download configuration files to Network-aware printer S, # and to       start the installation process for some operating systems.service tftp{        socket_type          = Dgram        pr Otocol                = UDP        Wait                      = yes        user                      = root        Server                   =/usr/sbin/in.tftpd        Server_args          =-U nobody-s/tftpboot  #-s Specify TFTP root        disable                  = no        #默认yes, close        per_source            = 11        cps                        = 2        flags                      = IPv4}

Restart TFTP Service:

/etc/init.d/xinetd.restart

View TFTP whether the service starts:

Chkconfig–list | grep tftp

3. Configure NFS

NFS need to RPC The registration can be called by the client, usually do port mapping Portmap is installed by default, no words can be used Yum Installation:

Yum–y Install portmap*

You can directly use the mounted image, which is copied to the server to create a directory dedicated to the common image files.

mount/dev/cdrom/mntmkdir/ios/centos_5.4cp–a/mnt/*/ios/centos_5.4

#共享tftp的根目录, users of the 192.168.1.0/24 network segment have read-only permissions echo "/tftpboot 192.168.1.0/24 (Ro,sync)" >/etc/exports# share the directory where the image files are stored, All users have read-only permissions echo "/ios/centos_5.4 * (Ro,sync)" >>/etc/exports

To see if the shared directory is active:

Showmount–e localhost

4. Configure The files required for PXE boot

Cp/usr/lib/syslinux/pxelinux.0/tftpboot

# pxelinux.0 relies on Syslinux , no installation is used Yum : yum–y Install syslinux*

# pxelinux.0 is a PXE Start boot file

Cp/ios/centos_5.4/ioslinux/vmlinuz/tftpbootcp/ios/centos_5.4/ioslinux/initrd.img/tftpboot

# Vmlinuz and the initrd.img is a different version of the system kernel and system boot files, when installing different versions of the system please use each version of the Vmlinuz and the initrd.img

Mkdir/tftpboot/pxelinux.cfgcp/ios/centos_5.4/ioslinux.cfg/tftpboot/pxelinux.cfg/default

It is now possible to install the system from the network. the test is as follows:

start the server, GeneralF12EnterPXEnetwork boot, toDHCPRequestIP,DHCPresponse containsIPAddress andPxelinuxstart the program location;PXEafter the client receives a response, requests that the file be routed to the server(pxelinux.0,Pxelinux.cfg/default,Vmlinuz,initrd.img);Client throughPxelinux.cfg/defaultsuccessful boot of the fileLinuxafter installing the kernel, the Setup program must first determine what installation media you are installingLinux, if you are installing over a network (NFS, FTP, HTTP), the network is initialized at this time and the location of the installation source is located. (AsPXEget the installation of the kernel and installation programs, and the installation program to obtain the installation of the system required by the binary package and configuration files, they need different content causedPXEThe module and the installer are relatively independent,PXEnetwork configuration is not passed to the installer for two fetchesIPaddress procedure).

5. Configuring the ks.cfg file

ks.cfg files can be generated by the following methods:

1. Each time a CentOS (RedHat)is installed, the installer automatically creates a kickstart file that records the actual installation configuration and the location /root/anaconda-ks.cfg , you can build your own needs based on this configuration . ks.cfg documents;

2. Using the graphical Kickstart Configuration tool, command:System-config-kickstart;

3. Edit with a text editor.

Here's what you've written. ks.cfg documents, for informational purposes only:

more/ios/ks.cfg# Kickstart file automatically generated by Anaconda.installnfs--server=192.168.1.254--dir=/ios/ centos_5.4# indicates the path to NFS and the location of the installation file Lang en_US. Utf-8keyboard usnetwork--device eth0--onboot Yes--bootproto dhcp--hostname test#network--device eth0--onboot Yes–bo Otproto static--ip 192.168.1.10--netmask 255.255.255.0--gateway 192.168.1.1--nameserver 8.8.8.8--hostname test# a network card received The way to address network--device eth1--onboot no--bootproto dhcp--hostname TESTROOTPW--iscrypted $1$v26j9f5v$ a7k9alsjs1gzg.qnbef6f/#加密root密码firewall--disabled #--port=22:tcpauthconfig--enableshadow--enablemd5# Use MD5 certified SELinux--disabledtimezone--UTC asia/shanghaibootloader--location=mbr--driveorder=sda# The following is the Partition information you requested# Note This any partitions you deleted is not expressed# it's unless you clear all Partitions first, this is# not guaranteed to Workclearpart--linuxpart/boot--fstype ext3--size=100--ondisk=sdapart swa P--size=2048--ondisk=sdapart/--fsType ext3--size=100–grow--ondisk=sda# partition and package is the most headache in the room, can be modified here #clearpart--linux--drives=sda#part/boot--fstype ext3-- Size=200#part Pv.2--size=0--grow--ondisk=sda#volgroup VolGroup00--pesize=32768 pv.2#logvol/--fstype ext3--name=Log Vol00--vgname=volgroup00--size=1024--grow#logvol swap--fstype swap--name=logvol01--vgname=volgroup00--size=1000- -grow--maxsize=6144# above is a demonstration of an LVM partition reboot #安装完毕后重启% packages@development-libs@development-tools@admin-tools@editors# Optional Package

Put the configured ks.cfg file in the shared directory and put it under/ios

echo "/ios 192.168.1.0/24 (Ro,sync)" >>/etc/exportsexportfs–arv

To modify the/tftpboot/pxelinux.cfg/default configuration:

More/tftpboot/pxelinux.cfg/defaultdefault ks    #默认从标签ks启动prompt 1     #显示 "boot:" Prompt timeout  # Wait Time out display boot.msg #/tftpboot/boot.msg default displays Boot.msg, can be edited according to the actual situation, F1 Boot.msgf2 options.msgf3 general.msgf4 Param.msgf5 rescue.msg label Linux #在boot: Enter Linux at the prompt (just a label), boot from the kernel indicated below kernel vmlinuz append Initrd=initrd.imglabel t Ext #在boot: Enter text at the prompt, here is the text interface installation kernel Vmlinuz append initrd=initrd.img textlabel ks #default默认, read installation information from KS.CFG, no manual intervention ke Rnel vmlinuz Append ks=nfs:192.168.1.254:/ios/ks.cfg initrd=initrd.img ksdevice=link #ksdevice =link, Read the installation file from the attached NIC label local localboot 1label mem kernel memtest Append-

6. Advanced

due to the current system installed in the computer room is RHEL4.7, RHEL4.7 x86_64, CentOS5.4, CentOS5.4 x86_64 . Four images can be placed in a dedicated directory . For example:

RHEL4.7 : /ios/rhel4.7

RHEL4.7 x86_64:/ios/rhel4.7-x86_64

CentOS5.4:/ios/centos5.4

CentOS5.4 x86_64:/ios/centos5.4-x86_64

/tftp root directory ( here is /tftpboot , each version of the kernel and boot files also need to change the location:

RHEL4.7 : /ios/rhel4.7/vmlinuz

/ios/rhel4.7/initrd.img

RHEL4.7 x86_64:/ios/rhel4.7-x86_64/vmlinuz

/ios/rhel4.7-x86_64/initrd.img

CentOS5.4:/ios/centos5.4/vmlinuz

/ios/centos5.4/initrd.img

CentOS5.4 x86_64:/ios/centos5.4-x86_64/vmlinuz

/ios/centos5.4-x86_64/initrd.img

PXE Boot file ( This is /tftpboot/pxelinux.cfg/default) Modify:

Default 3prompt 1timeout 300display boot.msgf1 boot.msgf2 options.msgf3 general.msgf4 param.msgf5 rescue.msg label 1 Kern El rhel4.7/vmlinuz append initrd=rhel4.7/initrd.imglabel 2 kernel rhel4.7-x86_64/vmlinuz append initrd=rhel4.7-x86_64/ Initrd.imglabel 3 kernel centos5.4/vmlinuz append initrd=centos5.4/initrd.imglabel 4 kernel centos5.4-x86_64/vmlinuz A Ppend Initrd=centos5.4-x86_64/initrd.imglabel 1-ks_** kernel rhel4.7/vmlinuz append ks=nfs:192.168.1.254:/ios/ Rhel4.7ks_**.cfg initrd=rhel4.7/initrd.img ksdevice=linklabel 2-ks_** kernel rhel4.7-x86_64/vmlinuz append Ks=nfs : 192.168.1.254:/ios/rhel4.7-x86_64ks_**.cfg initrd=rhel4.7-x86_64/initrd.img Ksdevice=linklabel 3-ks_** kernel Centos5.4/vmlinuz Append ks=nfs:192.168.1.254:/ios/centos5.4ks_**.cfg initrd=centos5.4/initrd.img ksdevice= LinkLabel 4-ks_** kernel centos5.4-x86_64/vmlinuz append ks=nfs:192.168.1.254:/ios/centos5.4-x86_64ks_**.cfg initrd= Centos5.4-x86_64/initrd.img Ksdevice=linklabel Local Localboot 0label Mem Kernel memtest append– 

because there are too many options, you can TFTP enabled in the root directory boot.msg with the options.msg file to describe what operating system to install and how to install the operating system. such as:

boot.msg Install rhel4.7:1install RHEL4.7 x86_64:2install centos5.4:3install CentOS5.4 x86_64:4default:graph mode. If you want to use text mode, type: [number] textF1:boot.msg F2:options.msg

options.msg Install rhel4.7:1install RHEL4.7 x86_64:2install centos5.4:3install CentOS5.4 x86_64:4default:graph mode. If you want to use text mode, type: [number] textif you want to use Kickstart, the flowing list the different OS ks.cfg:1- ks_**: rhel4.72-ks_**: RHEL4.7 x86_643-ks_**: centos5.44-ks_**: CentOS5.4 x86_64F1:boot.msg F2:options.msg

7. Summary

You can extend to multiple systems by paying attention to the corresponding relationship between the kernel and the boot file of each operating system.

Kickstart Documents can be modified on the original basis on the original basis of modification, a little time, you can form for different business Kickstart file, so it's convenient IDC Personnel Implementation Linux automated installation of the operating system.

Linux System network Installation--based on Pxe+dhcp+nfs+tftp+kickstart

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.