Linux network installation-Based on pxe + dhcp + nfs + tftp + kickstart and nfskickstart

Source: Internet
Author: User
Tags nameserver

Linux network installation-Based on pxe + dhcp + nfs + tftp + kickstart and nfskickstart

Original article published on: 2010-09-05

Reprinted to cu on: 2012-07-21

I. Overview

PXE (preboot execute environment) works in the Client/Server network mode. It supports workstation downloading images from remote servers over the network and starting operating systems from the network. During the startup process, the DHCP server allocates IP addresses to the terminal, and then downloads the IP addresses stored on the server (such as NFS, FTP, and HTTP) using protocols such as trivial file transfer protocol) the Linux kernel and the root file system are waiting in the local memory and executed. The basic software settings of the terminal are completed to guide the terminal operating system that is pre-installed on the server.

Kickstart is an unattended installation method. It records various parameters required for manual intervention during a typical installation process and generates a ks. cfg file. When a parameter is required during the subsequent installation process, the installer searches for the kickstart file and does not need manual intervention when appropriate parameters are found.

II. Environment Description

OS:

CentOS 5.4 i386

Soft:

Dhcp, nfs, tftp, kickstart (gnome or x-window)

You can use yum to install:

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

Ip:

Eth0: 192.168.1.254

Iii. Introduction to installation and configuration

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 limit 255.255.0 {option routers 192.168.1.254; option subnet-mask limit 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; # point to nfs server filename "/pxelinux.0 "; #/boot guide file under the tftp root directory # we want the nameserver to appear at a fixed address host ns {hardware ethernet 00: 1C: 25: 80: F4: 58; # mac fixed-address 192.168.1.2 ;}}

Restart the dhcp service:

/etc/init.d/dhcpd restart

 

2. ConfigurationTFTP

More/etc/xinetd. d/tftp # default: off # description: The tftp server serves files using the trivial file transfer \ # protocol. the tftp protocol is often used to boot diskless \ # workstations, download configuration files to network-aware printers, \ # and to start the installation process for some operating systems. service tftp {socket_type = dgram protocol = udp wait = yes user = root server =/usr/sbin/in. tftpd server_args =-u nobody-s/tftpboot #-s specify the tftp root directory disable = no # yes by default, disable per_source = 11 cps = 100 2 flags = IPv4}

 

Restart the tftp service:

/etc/init.d/xinetd.restart

 

Check whether the tftp service is enabled:

chkconfig –list | grep tftp

 

3. Configure NFS

NFS must be registered with RPC before it can be called by the client. Generally, portmap for port ing is installed by default. If not, you can use yum for installation:

yum –y install portmap*

 

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

 

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

 

# Share the root directory of tftp. users in the 192.168.1.0/24 network segment have the read-only permission echo "/tftpboot 192.168.1.0/24 (ro, sync) ">/etc/exports # share the directory where the image file is stored. All Users have the read-only permission echo"/ios/CentOS_5.4 * (ro, sync) ">/etc/exports

 

# Exportfs-arv # restart the service/etc/init. d/portmap restart/etc/init. d/nfs resart without restarting the nfs server

 

Check whether the shared directory is effective:

showmount –e localhost

 

4. Configure the file required for PXE startup

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

# Pxelinux.0 depends on syslinux, and yum: yum-y install syslinux * Is Not Installed *

# Pxelinux.0 is the PXE boot file

 

cp /ios/CentOS_5.4/ioslinux/vmlinuz /tftpbootcp /ios/CentOS_5.4/ioslinux/initrd.img /tftpboot

# Vmlinuz and initrd. img are system kernel and system boot files of different versions. When installing systems of different versions, use the vmlinuz and initrd. img of different versions.

 

mkdir /tftpboot/pxelinux.cfgcp /ios/CentOS_5.4/ioslinux.cfg /tftpboot/pxelinux.cfg/default

 

You can install the system from the network. The test is as follows:

Start the server. Generally, F12 enters the PXE network to start and request an IP address from DHCP. The DHCP response contains the IP address and the position of the pxelinux Startup Program. After the PXE client receives a response, send a file (pxelinux.0, pxelinux. cfg/default, vmlinuz, initrd. img); the client uses pxelinux. after the cfg/default file is successfully guided to Linux to install the kernel, the installer must first determine the installation media used to install linux. If the installation is through the network (NFS, FTP, HTTP ), at this time, the network will be initialized and the installation source location will be located. (PXE obtains the Kernel used for installation and the installer. The installer obtains the Binary Package and configuration file required for system installation, the PXE module and Installer are independent of each other because the PXE network configuration cannot be passed to the installer to obtain the IP address twice ).

 

5. Configure the ks. cfg file

The ks. cfg file can be generated using the following methods:

1. each time a CentOS (RedHat) is installed, the installer automatically creates a kickstart file that records the real installation configuration, in the/root/anaconda-ks.cfg, you can use this configuration to generate your desired ks. cfg file;

2. Use the graphical kickstart Configuration tool and command: system-config-kickstart;

3. Use a text editor for editing.

The ks. cfg file has been written as follows for your reference only:

More/ios/ks. cfg # Kickstart file automatically generated by anaconda. installnfs -- server = 192.168.1.254 -- dir =/ios/CentOS_5.4 # specifies the NFS path 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-bootproto static -- ip 192.168.1.10 -- netmask 255.255.255.0 -- gateway 192.168.1.1 -- nameserver 8.8.8.8 -- hostname test # network -- device eth1 -- onboot no -- bootproto dhcp -- hostname testrootpw -- iscrypted $1 $ V26J9f5V $ A7k9alSJs1GzG. qNBef6f/# encrypt the root password firewall -- disabled # -- port = 22: tcpauthconfig -- enableshadow -- enablemd5 # use md5 to authenticate selinux -- disabledtimezone -- utc Asia/Hangzhou -- location = mbr -- driveorder = sda # The following is the partition information you requested # Note any partitions you deleted are not expressed # here so unless you clear all partitions first, this is # not guaranteed to workclearpart -- linuxpart/boot -- fstype ext3 -- size = 100 -- ondisk = sdapart swap -- size = 2048 -- ondisk = sdapart/-- fstype ext3 -- size = 100- grow -- ondisk = sda # partitioning and package selection are the biggest headache in the data center, here you can modify # 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 = LogVol00 -- vgname = VolGroup00 -- size = 1024 -- grow # logvol swap -- fstype swap -- name = LogVol01 -- vgname = VolGroup00 -- size = 1000 -- grow -- maxsize = 6144 # The above is a demonstration reboot of an LVM partition # restart % packages @ development-libs @ development-tools @ admin-tools @ editors # select package

 

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

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

 

Modify/tftpboot/pxelinux. cfg/default Configuration:

More/tftpboot/pxelinux. cfg/defaultdefault ks # Start prompt 1 from the tag ks by default # display "boot:" prompt timeout 30 # Wait for the timeout time to display boot. msg #/tftpboot/boot. msg displays boot by default. msg, which can be edited according to the actual situation, F1 boot. msgF2 options. msgF3 general. msgF4 param. msgF5 rescue. msg label linux # Enter linux (only a label) at the boot: prompt, and start kernel vmlinuz append initrd = initrd from the kernel indicated below. imglabel text # Enter text at the boot: prompt. Here is the installation of kernel vmlinuz append initrd = initrd on the text interface. img textlabel ks # default, from ks. cfg reads the installation information without manual intervention. kernel vmlinuz append ks = nfs: 192.168.1.254:/ios/ks. cfg initrd = initrd. img ksdevice = link # ksdevice = link. Read the Installation File label local localboot 1 label mem kernel memtest append-from the connected network adapter-

 

6. Advanced

The commonly installed systems in the IDC are RHEL4.7, RHEL4.7 x86_64, CentOS5.4, and CentOS5.4 x86_64. Four types of 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, the kernel and boot file of each version 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 (here is/tftpboot/pxelinux. cfg/default) modification:

default 3prompt 1timeout 300display boot.msgF1 boot.msgF2 options.msgF3 general.msgF4 param.msgF5 rescue.msg label 1  kernel 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  append 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 enable the boot. msg and options. msg files in the tftp root directory to describe what kind of operating system to install and how to install the operating system. For example:

boot.msgInstall 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.msgInstall 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 only need to pay attention to the relationship between the kernel of each operating system and the boot file, and then you can extend it to multiple systems.

The kickstart file can be modified based on the original file. In a few days, the kickstart file for different businesses can be formed, in this way, IDC personnel can be conveniently installed automatically on the Linux operating system.

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.