Network-based Red Hat unattended installation
This paper introduces a fast Red Hat Linux installation scheme on PC platform. It has a high degree of automation--users can complete the installation process by simply starting the machine manually and choosing to boot from the network. This can save a lot of time when you need to bulk install a large number of Red Hat Linux systems and require a technician Red Hat Linux installation support. And because there is no need for additional software and hardware devices such as optical drive and floppy drive, there is a significant cost advantage. All developers/testers who install Red Hat Linux, and IT support, can benefit from this article. Readers are required to have Red Hat Linux installation Experience before reading this article.
1. Introduction
In general, installing Linux requires booting the machine from the CD-ROM installation CD, and then entering the interactive installation interface to enter the various configurations required for installation to complete the installation. In these cases, this installation can expose a disadvantage:
1) The machine has no optical drive, the optical drive is broken (this happens frequently in the real world) or the disc is broken, unable to install Linux from the CD drive.
2) Software testers need to install a large number of red Hat Linux test machines when setting up a test environment. At this time the manual installation of machine-to-station installation efficiency will be very low.
3) It takes a lot of time for IT support to instruct a Red Hat Linux novice to install Red Hat Linux systems. Repeating this work day after day can waste valuable human resources.
From the angle of reducing the commercial cost and improving the efficiency of the installation system, this paper introduces a scheme--the network-based Red Hat unattended installation. This scenario completes many installation preparations on the server at once, so that it is not necessary to repeat the work for each client when it is installed on the client, saving time and cost and increasing efficiency.
After a one-time environment configuration has been completed, the package achieves a very high degree of automation: the user only has to perform a few manual steps to complete the installation. The manual steps and automatic steps during the installation process are as follows:
1) Manual Step: Boot, select boot from Network. If your solution is configured to be more complex and flexible, you may need to choose which system to install. In short, there are very few manual steps.
2) Automated steps: The remaining steps, including system configuration, hard disk partitioning, and package installation, will all be completed automatically.
2. Programme INTRODUCTION
This scenario requires that you first set up a boot server and an installation server (which can be configured on the same physical machine), and then start the Setup program on the boot 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 uses three kinds of technologies:
1) PXE protocol to boot the Red Hat Linux installer from the network on the PC
2) The network installation feature provided by the Red Hat Linux installer (that is, access to the installation media over the network)
3) unattended installation provided by Red Hat Linux installer (Red Hat is called Kickstart)
Technology 1) and 2) are part of the introduction in References 1 and 2. This article focuses on the non-part and unattended installation features that are not covered in 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 above two machines have connected to the same subnet
- Red Hat Linux installation media to install
Scheme principle
Figure 1 is a principle of the network installation environment. The entire installation environment consists of a local area network, and three machines connected to the LAN: Boot server (boot server), installation Server (installation server), and the machine to be installed (Client). Where the startup server and the 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.
Figure 1 Network installation principle
Table 1 hardware and software configuration on each machine in the network installation environment
The implementation steps of the program
1) Configure the boot server
2) Configure the installation server
3) boot the machine from the network to complete the installation
Step 1) and 2) just once. For each machine that needs to install Red Hat Linux, you need to deploy the appropriate data on the boot server and the installation server, and perform step 3 at a time.
Below you will be guided through these steps. For simplicity, I'll use an example to illustrate how to set up a boot server and installation 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 machine to be installed. 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, while the latter provides a way to download the boot image for the machine to be installed.
Configuring the 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";dd ns-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-address192.168.138.30;}} |
In this example, the defined subnet 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), the file pxelinux.0 (in the TFTP The 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 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 a subnet defined by the DHCP server.
Here we use 192.168.138.1. For information on how to configure an IP address for the Red Hat Linux system, refer to reference 3.
4) Start the DHCP service.
[[email protected]] #service dhcpd restart |
Configuring the 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 version of Red Hat Linux to be installed, you need to do this one time.
Red Hat Linux The first installation CD/isolinux directory will contain the kernel/root file system files of the Linux installer. The following command copies these files to the root directory of the TFTP server and renames them according to the version.
[[email protected]] #mkdir/mnt/iso[[email protected]] #mount-o loop,ro rhel4-u2-i386-as-disc1.iso /mnt/iso[[ Email protected]] #cp/mnt/iso/isolinux/initrd.img/tftpboot[[email protected]] #cp/mnt/iso/isolinux/vmlinuz/ Tftpboot[[email protected]] #mv/tftpboot/initrd.img/tftpboot/initrd-rhel4u2-i386.img[[email protected]] #mv/ Tftpboot/vmlinuz/tftpboot/vmlinuz-rhel4u2-i386 |
4) Copy the boot image file pxelinux.0 to the TFTP server root directory.
The boot image pxelinux.0 can be obtained in the Syslinux installation package. After installing the Syslinux installation package, copy the pxelinux.0 to the TFTP server root directory.
[[email protected]] #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 version of Red Hat Linux to be installed, you need to do this one time.
Boot image pxelinux.0 file during execution, the configuration file is read to determine what Linux kernel files it should load to run. All configuration files are placed in the/tftpboot/pxelinux.cfg/directory of the boot server. pxelinux.0 search for the appropriate profile name according to certain rules. For example, for an IP address 192.168.138.30 (hexadecimal representation of 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, continue looking down. If the c0a88a1 file exists, it is the configuration file that pxelinux.0 will load. If the previous file starting with C does not exist, 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 the file corresponding to the IP address. It is a good idea to centralize all the configuration in the default file, which can alleviate the burden of configuration file maintenance.
Can think of the Red Hat Linux version of the configuration is written in the default file, in order to support a variety of Red Hat Linux version, as shown below (for a specific Red hat Linux version, the corresponding line how to write, you can refer to its installation disk configuration file/ ISOLINUX/ISOLINUX.CFG):
DEFAULT rhel4u2-i386display pxelinux.cfg/listprompt 1LABEL rhel3u6-i386kernel vmlinuz-rhel3u6-i386append initrd= Initrd-rhel3u6-i386.imglabel Rhel3u6-x86_64kernel vmlinuz-rhel3u6-x86_64append initrd=initrd-rhel3u6-x86_64.img Devfs=nomount Ramdisk_size=9216label Rhel4u2-i386kernel vmlinuz-rhel4u2-i386append initrd=initrd-rhel4u2-i386.img ramdisk_size=8192 |
This allows the user to select a specific installation version by entering a certain version of the label (for example, rhel4u2-i386). In order to be able to know what alternatives are available at the time of installation, you can have pxelinux.0 prompt you to display a list before selecting the user. This is done by specifying the display option in default. In the example above, we have listed all the alternative Red Hat Linux versions in the file Pxelinux.cfg/list, and its contents are displayed pxelinux.0.
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/rhel3u6rhel3u6-x86_64 Rhel 3 as U6 x86_64 192.168.138.1:/instsvr/ X86_64/rhel3u6rhel4u2-i386 RHEL 4 as U2 i386 192.168.138.1:/instsvr/i386/rhel4u2 |
6) Start the TFTP service.
[[email protected]] #service xinetd restart |
4. Step 2: Configure the installation Server
The installation server provides access to both the Linux installation media and the unattended installation profile 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. With the NFS protocol, the 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.
Configure Server for NFS
1) Prepare the ISO installation media. Place the ISO files for the Red Hat Linux installation media in the/instsvr directory. Be careful not to change the file name.
[[email protected]] #mkdir/instsvr[[email protected]] #mv Rhel4-u2-i386-as-disc1.iso/instsvr/i386/rhel4u2[[email Protected]] #mv Rhel4-u2-i386-as-disc2.iso/instsvr/i386/rhel4u2[[email protected]] #mv Rhel4-u2-i386-as-disc3.iso/ Instsrv/i386/rhel4u2[[email protected]] #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 directory/instsrv through NFS. The contents of the/etc/exports file are as follows:
/instsvr * (Ro,no_root_squash,sync) |
which
- * Indicates that the directory can be accessed by any IP address. For security reasons, you can also specify a specific IP address.
- RO indicates that the remote machine has read access to this directory only.
- Please refer to the NFS Manual for additional options.
3) Restart the NFS service for the new configuration to take effect
[[Email protected]]# service NFS Restart |
4) Detect if the directory/instsrv has been properly shared
[[email protected]] #showmount-e localhostexport list for localhost:/instsrv * |
In this way, we set up an installation server. It's simple!
Configuring Kickstart Installation
Since version 5.2, Red Hat Linux has started to support a feature called Kickstart, whose main purpose is to reduce human-computer interaction during installation and improve installation efficiency. Using this method, you need to define the good one configuration file (usually on the installation server), 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 itself, so as to avoid cumbersome human-computer interaction, to achieve unattended automated installation.
To use Kickstart, you must:
1) Create the Kickstart configuration file.
2) Deploy the Kickstart configuration file, place the Kickstart configuration file on the installation server, and specify the location of the Kickstart configuration file in the kernel parameter of the Setup program.
Create 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, which is indicated by the keyword.
There are several ways 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 the sample.
- Every time 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.
- Red Hat Linux provides a graphical kickstart configuration tool. Running the tool on any of the installed Red Hat Linux systems makes it easy to create your own kickstart configuration file. Kickstart Configuration Tool command for Redhat-config-kickstart (RHEL3) or System-config-kickstart (RHEL4)
- Read the manual for the Kickstart configuration file. You can create your own kickstart configuration file with any text editor.
Here is a sample kickstart configuration file:
# Kickstart file automatically generated by anaconda.0203 install04 NFS--server=192.168.138.1--dir=/instsvr/i386/rhe l4u205 Lang en_US. UTF-806 Langsupport--default=en_us. UTF-8 en_US. UTF-807 keyboard us08 xconfig--card "VMWare"--videoram 16384--hsync 31.5-37.9--vsync 50-70--resolution 800x600--depth 1609 Network--device eth0--bootproto DHCP10 rootpw-iscrypted One firewall--disabled12 selinux--enforcing13 authconfig --enableshadow--enablemd514 timezone asia/shanghai15 bootloader--location=mbr16 # The following is the partition inform ation you requested17 # Note This any partitions you deleted is not EXPRESSED18 # here's unless you clear all partitions First, this IS19 # does guaranteed to WORK20 Clearpart--all21 part/--fstype ext2--size=800022 part swap--size=1000232 4%PACKAGES25 @ admin-tools26 @ editors27 @ emacs28 @ text-internet29 @ legacy-network-server30 @ dialup31 @ ftp-server32 @ compat-arch-support33 @ legacy-software-development34 @ smb-server35 @ base-x36 @ kde-desktop37 @ server-cfg38 @ development-tools39 kernel-smp40 system-config-samba41 rsh-server42 grub43 kernel-devel Kernel-smp-devel45 E2fsprogs |
All the "#" starts with a comment.
The NFS--server=192.168.138.1--dir=/instsvr/i386/rhel4u2 option in the file tells the Installer: NFS shared directory to server 192.168.138.1/instsvr/i386/ RHEL4U2 look for the installation media. The Red Hat Linux installer is smart enough to recognize the ISO disc image file name that should be read in this directory, all of which you do not need to specify an ISO file name.
See Resources 3 for all the options supported by the Kickstart configuration file and their trusted instructions.
Deploying the Kickstart configuration file
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 NFS access path for the file 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 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 can do this by simply making some minor changes to the default file on the boot server:
LABEL rhel4u2-i386kernel vmlinuz-rhel4u2-i386append ks=nfs:192.168.138.1:/instsvr/ks/ks.cfg initrd= Initrd-rhel4u2-i386.img ramdisk_size=8192 |
This way, 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 the file as a kickstart configuration file for kickstart installation.
5. Step 3: Boot 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 network unattended on the machine to be installed.
1. Start the machine to be installed and select Start from the network card. The exact method differs depending on the BIOS version. Figure 2 is a selection of network-initiated screens that are available from VMware virtual machines.
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 boot image, then the boot image is loaded and run, you can see your own definition of a Linux list 3, select the system version you need to install.
Figure 3 Prompt interface for pxelinux.0 after network startup
3. The installer kernel is booted (Figure 4).
Figure 4 Setup Anaconda start running
4. The Setup program reads the kickstart configuration file to begin an unattended installation. During installation, it installs the specified package (Figure 5) According to the installation media address specified in the Kickstart configuration file.
Figure 5 Setup installs the package
5. You do not need to do any work until the installation is finished (Figure 6).
Figure 6 Installation completed successfully
6. After the installation is complete, the installer will prompt 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.
6. Summary
This paper introduces an unattended Red Hat Linux installation method based on network (network boot + network installation). This approach can save a lot of manpower if you need to install a large number of machines, and if you need to provide self-service installation services.
The examples in this article only cover a red Hat Linux version--rhel as 4 on a 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 server (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 for unattended installations. See Resources 4 for specific operations on using Autoyast.
Network-based Red Hat unattended Installation