Network-Based Unattended Installation of Red Hat

Source: Internet
Author: User

This article introduces a fast Red Hat Linux installation solution on the PC platform. It is highly automated-you only need to manually start the machine and choose to start from the network to complete the installation process. This solution can save a lot of time when a large number of Red Hat Linux systems need to be installed in batches and technical support is required for Red Hat Linux installation. In addition, because no additional software and hardware equipment such as optical drive and soft drive are required, the cost also has a great advantage. All developers/testers and IT support staff who install Red Hat Linux can benefit from this article. Before reading this article, you must have the installation experience of Red Hat Linux.

1. Introduction

In general, to install Linux, you need to start the machine from the optical drive with the installation CD, and then enter the various configurations required for installation on the interactive installation interface. In the following cases, this installation method exposes the disadvantages:

1) the machine has no optical drive, the optical drive is broken (this happens frequently in reality), or the optical drive is broken, and Linux cannot be installed from the optical drive.

2) Software testers need to install a large number of Red Hat Linux testing machines when building a testing environment. In this case, the installation efficiency will be very low by using manual installation.

3) for IT support staff, it takes a lot of time to instruct a Red Hat Linux operator to install the Red Hat Linux system. Repeat such work day after day will waste valuable human resources.

This article introduces a network-based Red Hat unattended installation solution to reduce business costs and improve installation system efficiency. This solution completes a lot of installation preparation work on the server at one time, so that you do not need to repeat the work for each client during Client installation, saving time and cost and improving efficiency.

After one-time environment configuration is complete, this solution can achieve a very high degree of automation: you only need to perform a few manual steps to complete the installation. The manual and automatic steps during installation are as follows:

1) manual steps: Start the instance from the network. If your solution configuration is complex and flexible, you may need to choose the system to install. In short, there are very few manual steps.

2) Automated steps: remaining steps, including system configuration, hard disk partitioning, andProgramPackage installation will be completed automatically.

 

2. solution introduction

In this solution, you must first set a startup server and an installation server (which can be configured on the same physical machine), and then start the installation program stored on the startup server through the network. The installer automatically accesses the installation configuration file and media stored on the Installation server to complete the installation.

Technologies involved

This solution mainly applies three technologies:

1) Start the PXE protocol of the Red Hat Linux installer from the network on the PC.

2) network installation function provided by Red Hat Linux Installer (that is, access the installation media through the network)

3) unattended installation feature provided by Red Hat Linux Installer (Red Hat is called KickStart)

Technology 1) and 2) some introductions are available in References 1 and 2. This article will focus on the reference materials that do not involve partial and unattended installation functions.

Hardware and software requirements

To perform automatic installation as described in this article, you need the following hardware and software resources:

    • One pc machine is used as the startup and Installation server (Other architecture machines can also be used)
    • The network card of a PC to be installed must have PXE support
    • The above two machines have been connected to the same subnet.
    • Red Hat Linux installation media to be installed

 

Solution Principle

Figure 1 shows the principle of the network installation environment. The entire installation environment consists of a LAN and three machines connected to the LAN: boot server, Installation server, and client ). The startup 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 the machines.

Figure 1 network installation Principle

Table 1 hardware and software configurations on each machine in the network installation environment

Steps for implementing this solution

1) configure the startup Server

2) configure and install the server

3) start the machine from the network to complete installation

Steps 1) and 2) only need to be done once. For each machine that needs to install Red Hat Linux, You need to deploy the corresponding data on the startup server and the Installation server, and perform step 3 ).

The following describes how to perform these steps one by one. For simplicity, I will use an example to illustrate how to set up the startup server and the Installation server on a PC with Red Hat Enterprise Linux as 3 Update 5 installed, install Red Hat Enterprise Linux as 4 Update 2 on a PC.

 

3. Step 1: configure the startup Server

The purpose of starting the server is to help start the Red Hat Linux installer on the machine to be installed. A DHCP server and a TFTP server must be set up to start the server. The former is to assign an IP address to the machine to be installed, and the latter provides a way for the machine to download the boot image.

Configure DHCP server

1) install the DHCP server package (RPM package name: DHCPD ).

2) edit the 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 "unknown"; host testserver {hardware Ethernet 00: 0C: 29: 70: 24: 5B; fixed-address 192.168.138.30 ;}}

In this example, the defined subnet is 192.168.138.0/255.255.255.0. The host definition item testserver indicates that the IP address 192.168.138.30 will be allocated to the ethernet card 00: 0C: 29: 70: 24: 5B (the machine to be installed ), the pxelinux.0 file (in the root directory of the TFTP server) will be loaded into the memory and run as the boot image by the PXE client in the NIC Rom.

Add a host entry in DHCPD. conf for each machine to be installed.

3) configure an IP address for the startup server, which must be in the subnet defined by the DHCP server.

Here we use 192.168.138.1. For details about how to configure IP addresses for Red Hat Linux systems, refer to reference 3.

4) Start the DHCP service.

[Root @ bsvr] # service DHCPD restart

Configure the TFTP Server

1) install the TFTP server package (RPM package name: TFTPD ).

2) edit the configuration file/etc/xinetd. d/TFTP of the TFTP server. 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,/tftpboot is selected as the root directory of the TFTP server.

3) copy the Linux Installer's kernel/root file system file to the root directory of the TFTP server. This operation is required for each Red Hat Linux version to be installed.

The first installation CD in Red Hat Linux/isolinux directory contains the kernel/root file system file of the Linux installation program. The following command copies these 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 root directory of the TFTP server.

You can obtain the Boot Image pxelinux.0 in the syslinux installation package. After installing the syslinux installation package, copy pxelinux.0 to the root directory of the TFTP server.

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

5) edit the configuration file of pxelinux.0 so that pxelinux can correctly load the Red Hat Linux installer. This operation is required for each Red Hat Linux version to be installed.

When the image pxelinux.0 file is started, the configuration file is read to determine which Linux kernel file should be loaded for running. All configuration files are stored in the/tftpboot/pxelinux. cfg/directory of the startup server. Pxelinux.0 searches for appropriate configuration file names based on certain rules. For example, for the IP address 192.168.138.30 (in hexadecimal format, c0a88a1e) 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 to say, if the c0a88a1e file exists, it is the configuration file that pxelinux.0 will load. Otherwise, continue searching. If the c0a88a1 file exists, it is the configuration file that pxelinux.0 will load. If no file starting with C exists, pxelinux.0 tries to read the configuration from the default file. For an installation server that supports many machines, it is not flexible to write the configuration in the file corresponding to the IP address. It is a good idea to centralize all configurations in the default file, which can reduce the maintenance burden on the configuration file.

You can write all the configurations of Red Hat Linux in the default file to support multiple Red Hat Linux versions at the same time, as shown below (for a specific Red Hat Linux version, for how to write the corresponding lines, refer to the configuration file/isolinux in the installation disk. 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 you to select a specific installation version by entering a certain version of the label (for example, the rhel4u2-i386. In order to know which options are available during installation, you can ask pxelinux.0 to display a list before prompting you to select a user. This is achieved by specifying the display option in default. In the preceding example, all the alternative Red Hat Linux versions are listed in the pxelinux. cfg/list file. The content of these versions is displayed by pxelinux.0.

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

Choose one of the following Linux distributions for your installation: Name distribution arch. installation media workflow rhel3u6-i386 RHEL 3 as U6 i386 192.168.138.1:/instsvr/i386/Alibaba rhel3u6-x86_64 RHEL 3 as U6 x86_64 192.168.138.1:/instsvr/x86_64/Alibaba 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 and install the server

The Installation server provides access to the Linux installation media and unattended installation configuration files during installation. The installation media is stored in a directory on the server and can be accessed using various network protocols, such as HTTP, FTP, and NFS. Using NFS, Red Hat Linux installer supports multiple installation media directory structures, especially ISO disc image files. Here we choose to use the NFS protocol to access the installation media.

Configure NFS server

1) Prepare the ISO installation media. Place the ISO files of Red Hat Linux installation media in the/instsvr directory. Do not change the file name.

[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 the NFS server configuration file/etc/exports to allow other machines to access the/instsrv directory through NFS. The content of the/etc/exports file is as follows:

/Instsvr * (RO, no_root_squash, sync)

Where:

    • * Indicates that any IP Address can access this directory. For security considerations, you can also specify a specific IP address.
    • RO indicates that the remote machine has only read permission on the directory.
    • For other options, see the NFS manual.

3) restart the NFS service to make the new configuration take effect.

[Root @ bsvr] # service NFS restart

4) check whether the directory/instsrv has been correctly shared

[Root @ bsvr] # showmount-e localhost export list for localhost:/instsrv *

In this way, we have set up an installation server. Easy!

Configure kickstart Installation

Since version 5.2, Red Hat Linux has started to support a feature called KickStart, which aims to reduce human-computer interaction during installation and improve installation efficiency. To use this method, you only need to define a configuration file (usually stored on the Installation server) in advance and let the installer know the location of the configuration file, during the installation process, the installer can read the installation configuration from the file, which avoids tedious Human-Computer Interaction and achieves unattended automatic installation.

To use KickStart, you must:

1) create a kickstart configuration file.

2) Deploy the Kickstart configuration file to place the Kickstart configuration file on the Installation server and specify the position of the Kickstart configuration file in the Kernel Parameter of the installation program.

Create a kickstart configuration file

The Kickstart configuration file is a simple text file that contains a list of installation projects. Each project corresponds to an installation option, which is marked with a keyword.

You can use the following methods to generate a kickstart configuration file:

    • 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 file based on this example.
    • Every time you install a Red Hat Linux machine, the Red Hat Linux installer will create a kickstart configuration file to record your actual installation configuration. If you want to install the program like a system, you can generate your own kickstart configuration file based on the Kickstart configuration file of the system.
    • Red Hat Linux provides a graphical kickstart Configuration tool. Run this tool on any installed Red Hat Linux system to easily create your own kickstart configuration file. The Kickstart Configuration tool command is RedHat-config-kickstart (rhel3) or system-config-kickstart (RHEL4)
    • Read the manual of the Kickstart configuration file. You can use any text editor to create your own kickstart configuration file.

Here is an example of the Kickstart configuration file:

01 # Kickstart file automatically generated by Anaconda. 02 03 install 04 NFS -- Server = 192.168.138.1 -- dir =/instsvr/i386/rhel4u2 05 Lang en_US.UTF-8 06 langsupport -- default = en_US.UTF-8 en_US.UTF-8 07 keyboard us 08 xconfig -- card "VMware" -- videoram 16384 -- hsync 31.5-37.9 -- vsync 50-70 -- resolution 800x600 -- depth 16 09 Network -- device eth0 -- bootproto DHCP 10 rootpw-iscrypted 11 firewall -- disabled 12 SELinux -- Enforcing 13 authconfig -- enableshadow -- enablemd5 14 timezone Asia/Shanghai 15 bootloader -- location = MBR 16 # The following is the partition information you requested 17 # note that any partitions you deleted are not expressed 18 # Here so unless you clear all partitions first, this is 19 # not guaranteed to work 20 clearpart -- all 21 part/-- fstype ext2 -- size = 8000 22 part swap -- size = 1000 23 24% packages 25 @ admin-tools 26 @ editors 27 @ Emacs 28 @ text-Internet 29 @ legacy-Network-server 30 @ dialup 31 @ FTP-server 32 @ compat-arch-support 33 @ legacy-software-Development 34 @ SMB -server 35 @ base-x 36 @ KDE-desktop 37 @ server-CFG 38 @ development-tools 39 kernel-SMP 40 system-config-Samba 41 rsh-server 42 grub 43 Kernel -devel 44 kernel-smp-devel 45 e2fsprogs

All comments starting.

The NFS -- Server = 192.168.138.1 -- dir =/instsvr/i386/rhel4u2 option in the file tells the installer to find the installation media under the NFS shared directory of the server 192.168.138.1/instsvr/i386/rhel4u2. Red Hat Linux installer is smart enough to identify the names of ISO disc image files to be read in this directory. You do not need to specify the ISO file names here.

For more information about all the options supported by the Kickstart configuration file and their description, see section 3.

Deploy the Kickstart configuration file

First, we need to put the Kickstart configuration file on the Installation server. Put it in the/instsvr/KS directory. That is, the NFS access path of the file is:

NFS: 192.168.138.1:/instsvr/KS. cfg

Secondly, we need to let the installer know that we want it to be installed in kickstart mode, and tell it where to get the Kickstart configuration file. This can be done by adding a parameter "Ks = kickstart configuration file path" to the kernel. We only need to make some minor changes to the default file on the startup server to achieve this:

Label rhel4u2-i386 kernel vmlinuz-rhel4u2-i386 append Ks = NFS: 192.168.138.1:/instsvr/KS. cfg initrd = initrd-rhel4u2-i386.img ramdisk_size = 8192

In this way, when the installer is started, the parameter Ks = NFS: 192.168.138.1:/instsvr/KS. CFG will be passed to it, telling it to use this file as the Kickstart configuration file for kickstart installation.

 

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

After the preceding configuration is complete, we will install Red Hat Enterprise Linux as 4 Update 2 in an unattended way on the machine to be installed.

1. Start the machine to be installed and select start from the NIC. The specific method varies depending on the BIOS version. Figure 2 shows the screen for selecting the network to start from the vmwarevm.

Figure 2 select Network startup from BIOS

2. PXE In the NICCodeThe DHCP server will be contacted to obtain the IP address and boot image, and then the boot image will be loaded and run. You can see a customized Linux list 3 and select the system version you want to install.

Figure 3 pxelinux.0 prompt page after network startup

3. the installer kernel is started (figure 4 ).

Figure 4 installation program Anaconda starts running

4. the installer reads the Kickstart configuration file and starts unattended installation. During the installation process, it installs the specified Software Package Based on the installation media address specified in the Kickstart configuration file (figure 5 ).

Figure 5 package installation

5. You do not need to do anything until the installation is complete (figure 6.

Figure 6 installation successful

6. After the installation is complete, the installer prompts you to restart the machine. When you restart a machine, remember to change it from BIOS to hard disk boot. If the machine is still started from the CD, the previous Automatic Installation Steps will be repeated.

6. Summary

This article introduces an unattended Red Hat Linux installation method based on the network (Network startup + network installation. This method saves a lot of manpower when a large number of machines need to be installed and when self-installation services are required.

The example in this article only involves a Red Hat Linux version, RHEL as 4, on the PC platform. In fact, the methods in this article can be easily promoted to other Red Hat Linux versions and other hardware platforms, such:

    • 1. Other Red Hat Linux versions

      • All editions of Red Hat Enterprise Linux 3 and 4 (as, es, WS, desktop)
      • Red Hat Linux 9
      • Fedora Core 5
    • 2. Other hardware platforms
      • 64-bit intel architecture and compatible architecture server (with amd64 and emt64 processors)

 

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.