Linux Kickstart Unattended Installation

Source: Internet
Author: User
Tags file transfer protocol ftp protocol

In our network maintenance career, there are many friends, feel that they do a mechanical thing, in boredom, boring and helpless work. In particular, some simple repetitive operations make it easier for people to feel bored with their work. Today we will show you how to deploy Redhat Linux operating system on a large scale, avoiding the tedious manual installation. Of course, this method is also used in some special occasions, such as no optical drive or optical drive broken computer, the hands do not have the installation of CD-ROM.
During the installation of Redhat Linux Enterprise Edition, we all know that it allows network installation via NFS, HTTP, or FTP protocol. But in general we need to have a boot media (boot CD, boot floppy, USB stick, etc.), there is no way to boot the CD-ROM way to install it, and directly through the network to install it? The answer is yes, which is achieved through PXE technology.
First, the basic principle
So what exactly is PXE?
PXE (Pre-Boot execution Environment) is a protocol designed by Intel that enables a computer to boot over a network. The protocol is divided between client and server, PXE client in the Rom of the NIC, when the computer boots, the BIOS puts the PXE client into memory execution, and displays the Command menu, after the user chooses, PXE The client will place the remote operating system on the network to be downloaded to run locally.
Since it is transmitted over the network, an IP address is required, that is, during its startup, the client requests the server to assign an IP address, and then the PXE client uses the TFTP client to pass TFTP (Trivial File Transfer Protocol) protocol to download the files required to start the Setup program.
Simply speaking, the PXE network is installed, the client sends information such as the broadcast request IP address that requests the DHCP information to the network through the PXE-enabled network card, the DHCP server provides the client with IP address and other information (TFTP server, boot file, etc.), and then requests and downloads the required files for installation. In this process, a server is required to provide startup files, installation files, and auto-answer files during installation. Describes the detailed working procedures for the automated installation system in Linux:
650) this.width=650; "src=" http://192.168.88.11/wind7/attachment/Mon_1306/7_1_e5167de6d695ee7.jpg?24 "border= "0" alt= "7_1_e5167de6d695ee7.jpg?24"/>
First step: PXE client sends request to DHCP
First, the BIOS setting of the client that supports PXE network interface card (NIC) becomes the network boot, and the PXE bootrom (self-booting chip) sends a broadcast request to the DHCP server in the network for information such as IP address.
Step Two: DHCP server provides information
The DHCP server receives a request from the client, verifies that it is coming to a legitimate PXE client request, verifies that it will give the client a "provide" response, which includes the IP address assigned to the client, the Pxelinux Boot program (TFTP) location, And where the configuration file is located.
Step three: PXE client requests download boot file
After the client receives a "response" from the server, it responds with a frame to request the file to be sent for launch. These boot files include: pxelinux.0, Pxelinux.cfg/default, Vmlinuz, initrd.img, and so on.
Fourth step: Boot server responds to client requests and transmits files
After the server receives the client's request, there will be more information between the client and the server to determine the startup parameters. Bootrom The files (pxelinux.0, pxelinux.cfg/default) that are necessary to launch the Setup program from the boot server by the TFTP communication protocol. When the default file download is complete, the boot kernel of the Linux installer is started based on the boot order defined in the file.
Fifth step: Request to download the auto answer file
After the client has successfully booted the Linux installation kernel through the Pxelinux.cfg/default file, the installer must first determine what installation media you have installed to install Linux, and if it is installed over a network (NFS, FTP, HTTP), the network will be initialized at this time, and locate the installation source location. Perhaps you would say that PXE has not already acquired the IP address? Why do we need it again? This is because PXE obtains the installed kernel as well as the installer, and the Setup program obtains the binary packages and configuration files required to install the system. Because they require different content, the PXE module and the installer are relatively independent, and the PXE network configuration is not passed to the installer. This allows you to get the IP address process two times. It then reads the location of the auto answer file ks.cfg specified in the file and downloads the file based on that location request.
Sixth step: The client installs the operating system
After you download the Ks.cfg file back, locate the OS Server through the file and follow the configuration request for the file to download the packages that are required for the installation process.
After the OS server and the client establish a connection, the transfer package begins and the client begins to install the operating system. After the installation is complete, you will be prompted to reboot the computer. At this point, be sure to change the BIOS back to boot from the hard drive during the reboot, or repeat the automatic installation of the operating system.
In the description above, the PXE client is the computer that needs to install Linux, and the TFTP server, DHCP server, and NFS server are running on another Linux server. Bootstrap files, configuration files, and Linux kernels are placed under the root directory of the TFTP server on the Linux server. The Linux root file system resides in the shared Directory of NFS server.
While the PXE client is working, it requires three binaries: bootstrap, Linux kernel, and Linux root file system. The bootstrap file is an executable program that provides the user with a simple control interface and, depending on the user's choice, downloads the appropriate Linux kernel and Linux root file system.
Second, the configuration process
To configure a PXE installation, follow these steps:
① configuring DHCP to provide IP addresses and other information to clients
② Configuring the TFTP server to provide the necessary files for client PXE boot
③ Configuring Server for NFS to hold the installation tree
④ configuration Kickstart for auto-answer installation
⑤ booting a client with PXE functionality
1, the installation and configuration of DHCP
During PXE boot installation, the PXE client obtains the PXE server address through DHCP, PXE boot file name, and then the client uses the TFTP protocol to download the boot file from the TFTP server and executes it to start the computer setup program. After the boot file executes, download the installer to start the installation. RedHat Linux uses ISC's DHCPD software to complete its installation and configuration.

1) Install the DHCP package
[Email protected] server]# RPM-IVH dhcp-3.0.5-13.el5.i386.rpm
Preparing ... ########################################### [100%]
1:dhcp ########################################### [100%]

2) Configure DHCP
After the installation is complete, copy the DHCPD profile template to replace the original configuration file/etc/dhcpd.conf.
[Email protected] server]# cp/usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample/etc/dhcpd.conf
Next we need to configure the relevant information. To meet our installation requirements, it is assumed that the PXE server, the DHCP server, and the TFTP server are all installed on a single 192.168.1.1 computer.
We need to do the following:
(1) Modify the/etc/dhcpd.conf file, specify the IP address and other information.
(2) in "/etc/dhcpd.conf" to add tftp-server need to push to the client's boot file (bootstrap): filename "pxelinux.0";
Because the default directory for TFTP is/tftpboot, the absolute path to the file is:/tftpboot/pxelinux.0 "; Of course, it can be specified as a different path.
You also need to specify the Next-server parameter to tell the client where to get the remaining startup files after obtaining the pxelinux.0 file: Next-server 192.168.1.1;
The final configuration file results are as follows:
[Email protected] server]# vi/etc/dhcpd.conf
Ddns-update-style Interim;
Ignore client-updates;
Allow booting; #定义能够PXE启动
Allow BOOTP; #定义支持bootp
Subnet 192.168.1.0 netmask 255.255.255.0 {
Range 192.168.1.10 192.168.1.80;
Option routers 192.168.1.1;
Option Subnet-mask 255.255.255.0;
Default-lease-time 21600;
Max-lease-time 43200;
Next-server 192.168.1.1; IP address of the #TFTP server
FileName "pxelinux.0"; #pxelinux启动文件位置
}
After the configuration is complete, restart the DHCP service and set it to boot.
[[email protected] server]#/ETC/INIT.D/DHCPD start
Start dhcpd: [OK]
[Email protected] server]# chkconfig--level dhcpd on

2. Install and configure the TFTP server
During the PXE installation, the client uses the TFTP protocol to download the boot file from the TFTP server and executes it. We complete this process primarily by configuring the TFTP server and PXE boot configuration.
1) Install and configure the TFTP server
First, to install a TFTP server package, Redhat provides the following two packages:
Tftp-server: Service-side program
TFTP: Client program
[Email protected] server]# RPM-IVH tftp-server-0.42-3.1.i386.rpm
Preparing ... ########################################### [100%]
1:tftp-server ########################################### [100%]
[Email protected] server]#
Configuring the TFTP service
The TFTP service is managed by the XINETD service. Edit the '/etc/xinetd.d/tftp ' File and change ' disable = Yes ' to: Disable = No.
[Email protected] server]# vi/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 =-s/tftpboot
Disable = no
Per_source = 11
CPS = 100 2
Flags = IPV4
}
From here, the default selection/tftpboot is the root directory location of the TFTP server, and the XINETD service is restarted after the configuration is complete, allowing the TFTP server to take effect.
[Email protected] server]#/etc/init.d/xinetd restart
2) PXE boot configuration (bootstrap)
The PXE boot image file is provided by the Syslinux package, which is available on the RedHat Enterprise Linux CD
If you do not have this package you can go to syslinux home: http://syslinux.zytor.com/download rpm to install.
As soon as we install the syslinux, we will generate a pxelinux.0 that will pxelinux.0 this file to the '/tftpboot ' directory:
[Email protected] server]# rpm-ql syslinux |grep "pxelinux.0"
/usr/lib/syslinux/pxelinux.0
[Email protected] server]# cp/usr/lib/syslinux/pxelinux.0/tftpboot/
3) kernel files for network boot
Copy the ' images/pxeboot/{vmlinuz,initrd.img} ' boot file from the RedHat installation CD directory to an installation directory, for example: ' '/tftpboot/':
[Email protected] server]# cp/media/rhel5/images/pxeboot/{vmlinuz,initrd.img}/tftpboot/
[Email protected] server]# Cp/media/rhel5/isolinux/*.msg/tftpboot
Because multiple clients can boot from a PXE server, the PXE boot image uses a complex configuration file search method to locate the profile for the client.
If the MAC address of the client's network card is "' 88:99:aa:bb:cc:dd ', the corresponding IP address is 192.168.1.195, then the client first attempts to match the MAC address to the file name,
If it does not exist, it is looked up with an IP address. According to the above environment for this host to look for a configuration file is/tftpboot/pxelinux.cfg/01-88-99-aa-bb-cc-dd.
If the file does not exist, it will look for the configuration file based on the IP address, which is more complex, and the PXE image lookup will be based on the IP address 16 binary named client configuration file.
For example: The 192.168.1.195 corresponds to the 16 binary in the form of c0a801c3. (You can convert a 10-based IP to 16 by using the Gethostip command provided by the Syslinux package)
If the c0a801c3 file does not exist, try to find the c0a801c file, and if c0a801c does not exist, try c0a801 the file, and so on,
Until the C file is found, and if C does not exist, then finally try the default file.
In general, the order in which files are searched by Pxelinux is:
/tftpboot/pxelinux.cfg/01-88-99-aa-bb-cc-dd
/tftpboot/pxelinux.cfg/c0a801c3
/tftpboot/pxelinux.cfg/c0a801c
/tftpboot/pxelinux.cfg/c0a801
/tftpboot/pxelinux.cfg/c0a80
/tftpboot/pxelinux.cfg/c0a8
/tftpboot/pxelinux.cfg/c0a
/tftpboot/pxelinux.cfg/c0
/tftpboot/pxelinux.cfg/c
/tftpboot/pxelinux.cfg/default
For an installation server that needs to support many installation machines, it is not flexible to write the configuration in the file corresponding to the IP address. It's a good idea to centralize all the configuration in the default file.
Can alleviate the burden of configuration file maintenance. Next, create the/tftpboot/pxelinux.cfg/directory, which is used to store the client's configuration files.
[Email protected] server]# mkdir/tftpboot/pxelinux.cfg
Copy the ' isolinux/isolinux.cfg ' file in the disc to '/tftpboot/pxelinux.cfg/default '
[Email protected] server]# Cp/media/rhel5/isolinux/isolinux.cfg/tftpboot/pxelinux.cfg/default
To view the contents of the default file:
The following text is slightly modified and commented according to the original file (note: Blank lines in the file and lines beginning with "#" are ignored)
# The Boot kernel labeled "Label Linux" is launched by default
Default Linux
# show ' boot: ' Prompt. is not prompted for ' 0 ', the content specified in the ' default ' parameter will be started directly.
Prompt 1
# The time-out before the user enters the unit is 1/10 seconds.
Timeout 60
#显示某个文件的内容, note the path to the file. The default is under the/tftpboot directory. You can also refer to a path + file name similar to ' Install/rhel4.4-inst/boot.msg '.
Display Boot.msg
F1 boot.msg #按下 ' F1 ' Such a key is displayed after the file. Note the path. The default is/tftpboot. Note: Syslinux official website said that currently only use F1-F10.
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
# ' label ' specifies the keyword you entered at the ' Boot: ' Prompt.
such as
# Boot:linux[enter]
# This will launch ' label Linux ' under the tagged kernel and initrd.img files.
# There are a few other keywords defined here:
# Boot:text
# Boot:ks

The # kernel parameter specifies the kernel to start. Also note the path, which defaults to the/tftpboot directory.
# APPEND Specifies the parameters appended to the kernel, and the parameters appended to the kernel that can be used in the Gurb are also available here.
# Install with Kickstart.
# you can specify the location of the kickstart file directly after the KS parameter.
Label Linux
Kernel Vmlinuz
Append ks=nfs:192.168.1.1:/mnt/install/ks.cfg initrd=initrd.img
Label text
Kernel Vmlinuz
Append initrd=initrd.img Text
Label KS
Kernel Vmlinuz
Append KS initrd=initrd.img
... ...
3. Install and configure NFS server
The installation media is stored in a directory on the server and can be accessed using a variety of network protocols, such as HTTP,FTP, and NFS.
This is the OS Server we mentioned earlier. Here, the NFS service is used to provide the installation media, and only a copy of the system CD contents can be placed in the shared directory.
Create a shared directory and copy the contents of the disc to a shared directory:
[[email protected] Server] #mkdir/mnt/install
[[email protected] Server] #cp/media/rhel5/*/mnt/install
Install NFS and publish the shared directory
[Email protected] server]# Vi/etc/exports
/mnt/install * (Ro,sync)
~
"/etc/exports" 1L, 25C written
Restart the service for the configuration to take effect.
[Email protected] server]# service Portmap restart
Stop portmap: [OK]
Start Portmap: [OK]
[[Email protected] server]# Service NFS Start
Start NFS service: [OK]
Turn off NFS quotas: [OK]
Start the NFS daemon: [OK]
Start NFS mountd: [OK]
Check whether the directory/mnt/install is shared correctly:
[Email protected] server]# shoumount–e locahost
Export list for localhost:
/mnt/install *
[Email protected] server]# Chkconfig--level NFS on
4. Configure Kickstart Installation
In general, the process of installing the operating system requires a large number of human-computer interaction processes, reducing the interaction process, in order to improve installation efficiency Red Hat Linux began to support a feature called Kickstart.
With this approach, you simply define the good one Kickstart auto-answer configuration file (usually on the installation server) and let the installer know where the profile is located.
During the installation process, the installer can read the installation configuration from the file itself, thus avoiding tedious human-computer interaction and automating unattended installations.
There are several ways to generate a kickstart configuration file, regardless of which method you use to create an answer file, when you install a red Hat Linux machine,
The Red Hat Linux Installer creates a kickstart configuration file that records your real-world installation configuration. If you want to implement a similar installation to a system,
You can build your own kickstart profile based on the system's kickstart configuration file. The file is located in/root/anaconda-ks.cfg.
Here I directly use the file, copy this file to/mnt/install.
[Email protected] server]# cp/root/anaconda-ks.cfg/mnt/install/ks.cfg
[Email protected] server]# chmod a+rx/mnt/install/ks.cfg
# Kickstart file automatically generated by Anaconda.
Install
NFS--server=192.168.1.1--dir=/mnt/install #这个选项告诉安装程序: Looking for installation media under NFS shared directory/mnt/install Server 192.168.1.1
Key 2515DD4E215225DD
Lang Zh_cn. UTF-8
Keyboard US:
Xconfig--startxonboot
Network--device eth0--bootproto DHCP
ROOTPW--iscrypted $1$3XVZZGWZ$1JYJRH/XTXLBLT00MN3YS0
Firewall--enabled--port=22:tcp
Authconfig--enableshadow--ENABLEMD5
SELinux--enforcing
TimeZone--UTC Asia/shanghai
bootloader--location=mbr--driveorder=sda--append= "RHGB quiet"
... ...
Clearpart--all--DRIVES=SDA--initabel
Part/--fstype ext3--size=130000
Part swap--fstype swap--size=2048
Part/backup--fstype ext3--size=100--grow

%packages
@office
@admin-tools
... ...
Emacs
Gcc43-c++
Libgfortran43
Note: Turn off server-side firewalls and SELinux
5. Configuring Client PXE boot Installation
Finally set the client BIOS selection to boot from the network card. The exact method differs depending on the BIOS version.
The PXE code in the network card contacts the DHCP server to obtain the IP address and the boot image, and then the boot image is loaded and running.
After the installation is complete, the installer prompts you to restart the machine. When restarting the machine, remember to change the BIOS to boot from the hard drive. If you still boot the machine from the CD, the previous automatic installation steps are repeated.

1. Turn off firewall iptables and SELinux
Service Iptables Stop
Chkconfig iptables off
Setenforce 0
Sed-i ' s/selinux=enforcing/selinux=disabled/g '/etc/sysconfig/selinux

Kickstart Server exclusions
1, shut down the firewall, the system comes with and iptables to close
2, boot from the network card, get no IP address check if your DHCP server is powered on, use #netstat-tulnp | grep DHCPD to see if it is listening on port 67th.
3. After acquiring the IP, the step is stuck in tftp. Check your DHCP configuration file, Next-server is not referring to the correct TFTP server. Whether the TFTP server is turned on or running properly.
This method can be used in Linux to test
#tftp Your server IP is logged into
Tftp>get pxelinux.0
Tftp>quit
Check if the current directory has pxelinux.0 this file, and if so, prove that your TFTP server is normal and finally check if there are other DHCP servers in your network
3, the kernel successfully loaded, the system has completed automatic installation, requires manual intervention, it proves that your kickstart script file problems, need to regenerate one.
4, monitor the server/var/log/message file, look for the cause of the failure.

This article is from the "Small Zheng Technology Blog" blog, please be sure to keep this source http://ko178.blog.51cto.com/220419/1765209

Linux Kickstart Unattended Installation

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.