Network-based Red Hat unattended Installation

Source: Internet
Author: User
Tags documentation mkdir

This paper introduces a fast Red Hat Linux installation scheme on the PC platform. It has a high degree of automation-the user can simply start the machine manually and choose to boot from the network to complete the installation process. This can save a lot of time when you need to bulk install a large number of Red Hat Linux systems and require technical staff Red Hat Linux installation support. And because it does not require additional software and hardware such as optical drive and floppy drive, it also has a great advantage in cost. All development/testers who install Red Hat Linux, and IT support staff, can benefit from this article. Readers need to have the installation experience of Red Hat Linux before reading this article.

1. Introduction

In general, installing Linux requires booting the machine from the CD drive with the installation CD, and then entering the interactive installation interface to enter the various configurations required for installation to complete the installation. In these cases, the installation method exposes the disadvantage:

1 The machine does not have the optical drive, the optical drive is broken (this situation occurs frequently in reality) or the disc is broken, unable to install Linux from the optical drive.

2 software Testers need to install a large number of red Hat Linux test machines when they build a test environment. At this time, the use of manual installation of machine installation efficiency will be very low.

3 It will take a lot of time for IT support staff to instruct a Red Hat Linux novice to install the Red Hat Linux system. Repeating this work day in and day out will waste valuable human resources.

From the point of view of reducing business cost and increasing the efficiency of installation system, this paper introduces a scheme-network-based Red Hat unattended installation. This scenario completes a number of installation preparations on the server at once, so that you do not need to repeat these tasks for each client when installing on the client, saving time and cost and increasing efficiency.

After a one-time environmental configuration is completed, the package can achieve a very high degree of automation: users only need to perform a few manual steps to complete the installation. 

The manual steps and automatic steps in the installation process are as follows:

1 manual step: Power on, choose to boot from the network. If your solution is configured to be more complex and flexible, you may also need to choose which system to install. In short, manual steps are very small.

2 Automation steps: The remaining steps, including system configuration, hard disk partitions, and package installation, will all automatically complete.


2. Introduction to the programme

This scenario requires first setting up a boot server and an installation server (which can be configured on the same physical machine), and then booting the installer on the startup server over the network. Setup automatically accesses the installation configuration files and installation media that are stored on the installation server to complete the installation.

The technology involved

The program mainly applies three kinds of technology:

1 boot the Red Hat Linux installer PXE protocol from the network on the PC

2 The network installation feature provided by Red Hat Linux installer (i.e. access to the installation media over the network)

3 The unattended installation feature provided by Red Hat Linux installer (Red Hat is called Kickstart)

Technologies 1) and 2 are covered in sections in references 1 and 2. This article will focus on the partial and unattended installation features that are not covered in the resources.

Hardware and software requirements

To complete the automated installation as described in this article, you need the following hardware and software resources: a PC machine as a startup and installation Server (other architecture machines can also) a PC machine to be installed, its network card must have PXE support a built LAN, the two machines have been connected to the same subnet to be installed red Hat Linux installation media

Schematic diagram of scheme principle

Figure 1 is a schematic diagram of the network installation environment. The entire installation environment consists of a local area network and three machines connected to the LAN: a boot server (boot server), an installation server (installation server), and a machine to install (Client). Where the boot server and installation server can be deployed on the same physical machine. Table 1 lists the hardware and software requirements for these machines and the services and data on which they are loaded.

Fig. 1 schematic diagram of network installation
table 1 hardware and software configuration on each machine in Network installation environment

The implementation steps of the scheme

1) Configure the boot server

2) Configure the installation server

3) Boot the machine from the network to complete the installation

Steps 1 and 2) can be done only once. For each machine that needs to install Red Hat Linux, you need to deploy the appropriate data on the boot server and installation server, and perform step 3.

The following steps are taken to take you through. For simplicity, I'll use an example to illustrate how to set up a boot server and install server on a PC with Red Hat Enterprise Linux as 3 Update 5, and install Red Hat Enterprise Linux as 4 on a single PC Update 2.


3. Step 1: Configure the boot server

The purpose of starting the server is to help launch the red Hat Linux installer on the installed machine. A DHCP server and a TFTP server need to be built on the boot server. The former is to assign an IP address to the machine to be installed, and the latter is to provide a way for the machine to download the boot image.

Configuring a DHCP server

1) Install the DHCP server package (RPM package Name: DHCPD).

2) Edit DHCP server configuration file/etc/dhcp.conf. Here is an example:

Option Domain-name "MyDomain";
Ddns-update-style none;

Max-lease-time 7200;
Server-name "Bootserver";
Default-lease-time 600;

Allow booting;
Allow BOOTP;

Subnet 192.168.138.0 netmask 255.255.255.0 {
    Range 192.168.138.1 192.168.138.254;
    Deny Unknown-clients;
}

Group PXE {
    FileName "pxelinux.0";
    Host TestServer {hardware Ethernet 00:0c:29:70:24:5b; fixed-address
	192.168.138.30; }
}


In this example, the subnet defined is 192.168.138.0/255.255.255.0. The host definition entry testserver indicates that the IP address 192.168.138.30 will be assigned to the Ethernet card 00:0c:29:70:24:5b (the machine to be installed), file pxelinux.0 (in TFTP Server's root directory) will be loaded into memory and run as a boot image by the PXE client in the NIC Rom.

For each additional machine that needs to be installed, we need to add a host entry in the dhcpd.conf.

3) Configure an IP for the boot server, which must be within the subnet defined by the DHCP server.

Here we use 192.168.138.1. For information on how to configure IP addresses for the Red Hat Linux system, refer to reference 3.

4) Start the DHCP service.

[ROOT@BSVR] #service dhcpd restart


Configuring a TFTP server

1 Install the TFTP server package (RPM package Name: TFTPD).

2 Edit the TFTP server configuration file/etc/xinetd.d/tftp. The configuration file is as follows:

Service TFTP
{
    Socket_type     = Dgram
    Protocol        = UDP
    Wait            = yes
    User            = root
    Server          =/usr/sbin/in.tftpd
    Server_args     =-s/tftpboot
    Disable         = no
}


Here the/tftpboot is selected as the root directory location for the TFTP server.

3 Copy the kernel/root file system files of the Linux installer to the root directory of the TFTP server. For each red Hat Linux version to be installed, it needs to be done once.

Red Hat Linux The first installation CD-ROM/isolinux directory contains the Linux installer's kernel/root file system files. The following command copies the files to the root directory of the TFTP server and renames them by version.

[Root@bsvr] #mkdir/mnt/iso
[Root@bsvr] #mount-o loop,ro rhel4-u2-i386-as-disc1.iso  /mnt/iso
[Root@bsvr] #cp/mnt/iso/isolinux/initrd.img/tftpboot
[Root@bsvr] #cp/mnt/iso/isolinux/vmlinuz/tftpboot
[Root@bsvr] #mv/tftpboot/initrd.img/tftpboot/initrd-rhel4u2-i386.img
[Root@bsvr] #mv/tftpboot/vmlinuz/tftpboot/vmlinuz-rhel4u2-i386


4 Copy the boot image file pxelinux.0 to the TFTP server root directory.

The boot mirror pxelinux.0 can be obtained in the Syslinux installation package. After the Syslinux installation package is installed, copy the pxelinux.0 to the TFTP server root directory.

[Root@bsvr] #cp/usr/lib/syslinux/pxelinux.0/tftpboot/


5 Edit the pxelinux.0 configuration file so that pxelinux can load the Red Hat Linux installer correctly. For each red Hat Linux version to be installed, it needs to be done once.

Starting a mirrored pxelinux.0 file during execution, the configuration file is read to determine what Linux kernel files it should load into to run. All configuration files are placed in the/tftpboot/pxelinux.cfg/directory of the boot server. pxelinux.0 searches for the appropriate configuration file name according to certain rules. For example, for the IP address 192.168.138.30 (hexadecimal represented as C0A88A1E) that was previously assigned to the machine to be installed, pxelinux.0 searches for the configuration file in the following order:

c0a88a1e > C0a88a1 > ... > C0 > C > Default


That is, if the c0a88a1e file exists, it is the configuration file that pxelinux.0 will load. Otherwise, keep looking down. If the c0a88a1 file exists, it is the configuration file that pxelinux.0 will load. If none of the preceding files begin with C, then pxelinux.0 will attempt to read the configuration from the file default. For an installation server that needs to support many installation machines, it is not flexible to write the configuration in a file that corresponds to an IP address. It is a good idea to centralize all of your configuration in the default file to ease the burden of configuration file maintenance.

The configuration of the Red Hat Linux version that you can think of is written in the default file to support a variety of Red Hat Linux versions, as shown below (for a specific Red Hat Linux version, how to write the corresponding line, refer to the configuration file in its installation disk/ ISOLINUX/ISOLINUX.CFG):

DEFAULT rhel4u2-i386
DISPLAY pxelinux.cfg/list
PROMPT 1

LABEL rhel3u6-i386
KERNEL vmlinuz-rhel3u6-i386
APPEND initrd=initrd-rhel3u6-i386.img

LABEL rhel3u6-x86_64
KERNEL vmlinuz-rhel3u6-x86_64
APPEND initrd=initrd-rhel3u6-x86_64.img Devfs=nomount ramdisk_size=9216

LABEL rhel4u2-i386
KERNEL vmlinuz-rhel4u2-i386
APPEND initrd=initrd-rhel4u2-i386.img ramdisk_size=8192


This allows the user to select a specific installation version by entering a version of the label (for example, rhel4u2-i386). To be able to know what alternatives to install, you can have the pxelinux.0 prompt to display a list before the user chooses. This is done by specifying the display option in default. In the example above, we have all the alternate Red Hat Linux versions listed in the file Pxelinux.cfg/list, and its contents will be pxelinux.0 displayed.

In our example, the contents of the/tftpboot/pxelinux.cfg/list file are as follows:

Choose one of the following Linux distributions for your installation:
Name           distribution   Arch.   installation media
-------------------------------------------------------------------------
Rhel3u6-i386   RHEL 3 as U6   i386 192.168.138.1:/instsvr/i386/rhel3u6
Rhel3u6-x86_64 RHEL 3 as U6 x86_64  192.168.138.1:/instsvr/x86_64/rhel3u6
Rhel4u2-i386   RHEL 4 as U2   i386    192.168.138.1:/instsvr/i386/rhel4u2


6 Start the TFTP service.

[Root@bsvr] #service xinetd  restart

4. Step 2: Configure the installation Server

The installation server provides access to Linux installation media and unattended installation profiles during installation. 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. Using the NFS protocol, Red Hat Linux Installer can support a variety of installation media directory structures, especially for ISO disc image files. Here we choose to use the NFS protocol to access the installation media.

Configuring Server for NFS

1 Prepare ISO installation media. Place the ISO files for Red Hat Linux installation media into the/INSTSVR directory. Be careful not to change the filename.

[Root@bsvr] #mkdir/instsvr
[Root@bsvr] #mv RHEL4-U2-I386-AS-DISC1.ISO/INSTSVR/I386/RHEL4U2
[Root@bsvr] #mv RHEL4-U2-I386-AS-DISC2.ISO/INSTSVR/I386/RHEL4U2
[Root@bsvr] #mv RHEL4-U2-I386-AS-DISC3.ISO/INSTSRV/I386/RHEL4U2
[Root@bsvr] #mv RHEL4-U2-I386-AS-DISC4.ISO/INSTSRV/I386/RHEL4U2

2 Edit NFS Server configuration file/etc/exports to allow other machines to access directory/instsrv via NFS. The contents of the/etc/exports file are as follows:

/instsvr   * (Ro,no_root_squash,sync)


Where: * means that any IP address can access the directory. For security reasons, you can also specify a specific IP address. RO indicates that the remote machine has read only access to the directory. Please refer to the NFS Manual for additional options.

3 Restart the NFS service for the new configuration to take effect

[Root@bsvr]# Service NFS Restart

4 detect whether the directory/instsrv has been properly shared

[Root@bsvr] #showmount-e localhost
Export list for localhost:
/INSTSRV *


In this way, we set up a setup server. It's very simple.

Configuring Kickstart Installation

Since the 5.2 edition, Red Hat Linux has started to support a feature called Kickstart, the main purpose of which is to reduce human-computer interaction during installation and improve installation efficiency. Using this method, by simply defining one of the configuration files (usually on the installation server) and letting the installer know the location of the profile, the installer can read the installation configuration from the file itself during the installation process, thus avoiding tedious human-computer interaction and unattended automated installation.

To use Kickstart, you must:

1 Create the Kickstart configuration file.

2 Deploy the Kickstart configuration file, place the Kickstart profile on the installation server, and specify the location of the Kickstart configuration file in the kernel parameter of the installer.

Creating a Kickstart configuration file

The Kickstart configuration file is a simple text file that contains a list of installation items. Each item corresponds to an installation selection and is marked with a keyword.

There are several ways to generate Kickstart configuration files: Red hat provides a sample file. The Sample.ks file in the Rh-docs directory on the Red Hat Linux documentation CD. You can create your own configuration Kickstart files based on this sample. Every time you install a Red Hat Linux machine, Red Hat Linux installer creates a kickstart configuration file that records your actual installation configuration. If you want to implement a similar installation to a system, you can build your own kickstart configuration file based on the system's kickstart configuration file. Red Hat Linux provides a graphical kickstart configuration tool. Running the tool on any installed Red Hat Linux system makes it easy to create your own kickstart configuration file. The Kickstart Configuration Tool command reads RHEL4 profile manuals for Redhat-config-kickstart (RHEL3) or System-config-kickstart (Kickstart). You can create your own kickstart configuration file with any text editor.

Here is an example of a kickstart configuration file:

# Kickstart file automatically generated by Anaconda.
02
Install
NFS--server=192.168.138.1--DIR=/INSTSVR/I386/RHEL4U2
en_US lang. UTF-8
Langsupport--default=en_us. UTF-8 en_US. UTF-8
Modified keyboard US
Xconfig--card "VMWare"--videoram 16384--hsync 31.5-37.9--vsync 50-70
--resolution 800x600--depth 16
Network--device eth0--bootproto DHCP
Ten rootpw-iscrypted
One firewall--disabled
SELinux--enforcing
Authconfig--enableshadow--ENABLEMD5
TimeZone Asia/shanghai
Bootloader--LOCATION=MBR
The following is the partition information for you requested
# Note This any partitions your deleted are not expressed
# Here's unless you clear all partitions the
# Not guaranteed to work
Clearpart--all
Part/--fstype ext2--size=8000
--size=1000 Part Swap
23
%packages
@ admin-tools
@ editors
@ Emacs
@ text-internet
@ legacy-network-server
@ Dialup
@ ftp-server
@ compat-arch-support
@ legacy-software-development
@ smb-server
@ base-x
@ kde-desktop
Panax Notoginseng @ server-cfg
@ development-tools
Kernel-smp
System-config-samba
Rsh-server
The Grub
Kernel-devel
Kernel-smp-devel
E2fsprogs

All that start with the "#" sign are comments.

NFS--server=192.168.138.1--dir=/instsvr/i386/rhel4u2 option in file tells Installer: NFS shared directory to server 192.168.138.1/instsvr/i386/ Rhel4u2 to find the installation media. Red Hat Linux Installer is smart enough to recognize the ISO CD image file name that should be read in the directory, and you do not need to specify an ISO filename here.

Refer to reference 3 for all the options supported by the Kickstart profile and their trust instructions.

Deploying Kickstart configuration Files

First we need to put the Kickstart configuration file on the installation server. Let's put it in the/instsvr/ks directory. That is, the file's NFS access path is:

Nfs:192.168.138.1:/instsvr/ks/ks.cfg


Second, we need to let the installer know that we want it to be installed kickstart and tell it where to get the Kickstart configuration file. This can be achieved by adding a parameter "Ks=kickstart profile path" to the kernel. We can do this simply by making minor changes to the default file on the startup server:

LABEL    rhel4u2-i386
KERNEL vmlinuz-rhel4u2-i386
APPEND ks=nfs:192.168.138.1:/instsvr/ks/ks.cfg initrd=initrd-rhel4u2-i386.img   
ramdisk_size=8192


So when the installer is started, the parameter ks=nfs:192.168.138.1:/instsvr/ks/ks.cfg is passed to it, telling it to use this file as a kickstart configuration file for kickstart installation.


5. Step 3: Start the machine from the network to complete the installation

Once the previous configuration is complete, we will install red Hat Enterprise Linux as 4 Update 2 on the installation machine on an unattended basis over the network.

1. Start to install the machine, choose to boot from the NIC. The specific method differs depending on the BIOS version. Figure 2 is a screenshot of the selected network boot from the VMware virtual machine.

Figure 2 Selecting a network boot from the BIOS

2. The PXE code in the network card will contact the DHCP server to obtain the IP address and start the mirror, and then start the image to be loaded and run, you can see your own definition of a Linux list as shown in Figure 3, select the system version you need to install.

Figure 3 Prompt interface for pxelinux.0 after network startup

3. The installer kernel is started (Figure 4).

Figure 4 Setup Anaconda starts running

4. Setup will read the Kickstart configuration file and start unattended installation. During installation, it installs the specified package according to the installation media address specified in the Kickstart configuration file (Figure 5).

Figure 5 Setup is installing the package

5. You do not need to do any work until the installation is over (Figure 6).

Figure 6 Installation completed successfully

6. After the installation is complete, the installer will prompt you to reboot the machine. Remember to reboot the machine to boot from the hard drive in the BIOS. If you still start the machine from the CD, the previous automatic installation steps will be repeated.


6. Summary

This paper introduces an unattended Red Hat Linux installation method based on network (network startup + network installation). This approach can save a significant amount of manpower when a large number of machines are required and when self-service installation is required.

The examples in this article only cover a red Hat Linux version--rhel as 4 on the PC platform. In fact, the methods in this article can be easily extended to other Red Hat Linux versions and other hardware platforms, such as 1. Other Red Hat Linux versions Red Hat Enterprise Linux 3, 4 of all edition (as, ES, WS, Desktop) Red Hat Linux 9 Fedora Core 5 2. Other hardware platforms 64-bit Intel architecture and compatible architecture servers (using AMD64 and EMT64 processors)

For other Linux manufacturers, as long as the use of their unattended installation function, can also create a similar automatic installation program. For example, Novell SuSE Linux provides autoyast functionality to implement unattended installations. For specific actions on using Autoyast, see Resources 4.

Resources PXE (Pre-Boot Execution Environment) is a protocol designed by Intel to launch an Intel architecture computer from the network. An article in the IBM Developer's Corner (in Chinese) believes that the principle of PXE is introduced. An article in the Http://www-128.ibm.com/developerworks/cn/linux/l-tip-prompt/l-pex/IBM developer's Corner is a detailed description of the IBM Pseries the process of installing Linux over a network on a server. The reader can see many details of the setup server, such as how the installation media directory is organized, and which directory organizations are supported by various network access protocols. http://www-128.ibm.com/developerworks/cn/linux/es-linux-pservers/Many of the operations in this article use some of the system management commands of Rhel 3. Readers can refer to RHEL 3 Reference guide to familiarize themselves with the use of these operations. Http://www.redhat.com/docs/manuals/enterprise/RHEL-3-Manual/ref-guide/SuSE Linux provides autoyast functionality to implement unattended installations. Specific actions can refer to openSUSE's YaST autoinstallation documentation http://en.opensuse.org/YaST_Autoinstallation

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.